Running a single test

So I can run the full test suite:

bundle exec rake
/usr/bin/ruby25 -I/home/cassius/.gem/ruby/2.5.0/gems/rspec-core-3.8.0/lib:/home/cassius/.gem/ruby/2.5.0/gems/rspec-support-3.8.0/lib /home/cassius/.gem/ruby/2.5.0/gems/rspec-core-3.8.0/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb

Randomized with seed 46666
 2325/2325 |================================================= 100 ==================================================>| Time: 00:02:49                                                                           |  ETA: 00:02:55 
Pending: (Failures listed here are expected and do not affect your suite's status)

But if I just try to run a single test, I get a Chewy failure:

bundle exec rake spec SPEC=spec/controllers/settings/profile_controller_spec.rb
/usr/bin/ruby25 -I/home/cassius/.gem/ruby/2.5.0/gems/rspec-core-3.8.0/lib:/home/cassius/.gem/ruby/2.5.0/gems/rspec-support-3.8.0/lib /home/cassius/.gem/ruby/2.5.0/gems/rspec-core-3.8.0/exe/rspec spec/controllers/settings/profile_controller_spec.rb
                                                                                                                                      
An error occurred while loading ./spec/controllers/settings/profile_controller_spec.rb.
Failure/Error: __send__(method, file)

LoadError:
  cannot load such file -- /home/cassius/src/mastodon/spec/controllers/settings/profile_controller_spec.rb
# /home/cassius/.gem/ruby/2.5.0/gems/rspec-core-3.8.0/lib/rspec/core/configuration.rb:2034:in `load'
# /home/cassius/.gem/ruby/2.5.0/gems/rspec-core-3.8.0/lib/rspec/core/configuration.rb:2034:in `load_file_handling_errors'
# /home/cassius/.gem/ruby/2.5.0/gems/rspec-core-3.8.0/lib/rspec/core/configuration.rb:1560:in `block in load_spec_files'
# /home/cassius/.gem/ruby/2.5.0/gems/rspec-core-3.8.0/lib/rspec/core/configuration.rb:1558:in `each'
# /home/cassius/.gem/ruby/2.5.0/gems/rspec-core-3.8.0/lib/rspec/core/configuration.rb:1558:in `load_spec_files'
# /home/cassius/.gem/ruby/2.5.0/gems/rspec-core-3.8.0/lib/rspec/core/runner.rb:98:in `setup'
# /home/cassius/.gem/ruby/2.5.0/gems/rspec-core-3.8.0/lib/rspec/core/runner.rb:86:in `run'
# /home/cassius/.gem/ruby/2.5.0/gems/rspec-core-3.8.0/lib/rspec/core/runner.rb:71:in `run'
# /home/cassius/.gem/ruby/2.5.0/gems/rspec-core-3.8.0/lib/rspec/core/runner.rb:45:in `invoke'
# /home/cassius/.gem/ruby/2.5.0/gems/rspec-core-3.8.0/exe/rspec:4:in `<main>'
# 
#   Showing full backtrace because every line was filtered out.
#   See docs for RSpec::Configuration#backtrace_exclusion_patterns and
#   RSpec::Configuration#backtrace_inclusion_patterns for more information.
No examples found.                                                                                                                    
 0/0 |==================================================== 100 =====================================================>| Time: 00:00:00 
                                                                                                                                      
An error occurred in a `before(:suite)` hook.
Failure/Error: Chewy.strategy(:bypass)

NameError:
  uninitialized constant Chewy
# ./spec/spec_helper.rb:30:in `block (2 levels) in <top (required)>'
                                                                                                                                      
An error occurred in an `after(:suite)` hook.
Failure/Error: FileUtils.rm_rf(Dir["#{Rails.root}/spec/test_files/"])

NameError:
  uninitialized constant Rails
# ./spec/spec_helper.rb:35:in `block (2 levels) in <top (required)>'

Finished in 0.01083 seconds (files took 0.27243 seconds to load)
0 examples, 0 failures, 3 errors occurred outside of examples
Coverage report generated for RSpec to /home/cassius/src/mastodon/coverage. 0 / 19308 LOC (0.0%) covered.
/usr/bin/ruby25 -I/home/cassius/.gem/ruby/2.5.0/gems/rspec-core-3.8.0/lib:/home/cassius/.gem/ruby/2.5.0/gems/rspec-support-3.8.0/lib /home/cassius/.gem/ruby/2.5.0/gems/rspec-core-3.8.0/exe/rspec spec/controllers/settings/profile_controller_spec.rb failed

How do you guys run individual tests when working on single components?

I have not ever had a problem running a single test. I’m guessing your issue has to do with manually specifying library paths, instead of using bundler?

That was rake adding in the paths. Gargron helped me out. Turns out it works if you call rspec directly (instead of via rake). The following works:

bundle exec rspec spec/controllers/settings/profiles_controller_spec.rb

That was rake adding in the path. Gargron helped me out. Turns out I needed to call rspec directly instead of via rake:

bundle exec rspec spec/controllers/settings/profiles_controller_spec.rb

I saw the same issue here, but it seems it’s a lot of unrelated failures, the real error is this:

$ bundle exec rspec spec/controllers/settings/profile_controller_spec.rb 

An error occurred while loading ./spec/controllers/settings/profile_controller_spec.rb.
Failure/Error: __send__(method, file)

LoadError:
 cannot load such file -- /home/renatolond/sources/mastodon/spec/controllers/settings/profile_controller_spec.rb

Everything after it, it’s probably a side effect of this one.
The issue is that the name of the file is: spec/controllers/settings/profiles_controller_spec.rb, you’re missing an s there :slight_smile:

Do you still have the issue with the correct filename?