Right now if I run my test suite using rake spec
I get an error:
1) SegmentsController GET 'index' should work Failure/Error: get 'index' undefined method `locale' for # # ./spec/controllers/segments_controller_spec.rb:14: in `block (3 levels) in '
This is normal as I do have an error :)
The problem is that the trace isn't very helpful. I know it broke in segments_controller_spec.rb
, line 14, but this is just where I call the test:
### segments_controller_spec.rb:14 get 'index'
I would prefer to have the actual line breaking and the complete trace, not the part in the spec folder.
Running with --trace
doesn't help.
I use the database_cleaner gem to scrub my test database before each test runs, ensuring a clean slate and stable baseline every time. By default, RSpec will actually do this for you, running every test with a database transaction and then rolling back that transaction after it finishes.
Open your terminal, cd into the project directory, and run rspec spec . The spec is the folder in which rspec will find the tests. You should see output saying something about “uninitialized constant Object::Book”; this just means there's no Book class.
Running tests by their file or directory names is the most familiar way to run tests with RSpec. RSpec can take a file name or directory name and run the file or the contents of the directory. So you can do: rspec spec/jobs to run the tests found in the jobs directory.
You must run rspec with -b
option to see full backtraces
Another (easier) alternative is to edit the .rspec
file, and add the backtrace
option. It should look somewhat like this:
--colour --backtrace
That will give you the full backtrace. Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With