Reputation: 1993
I'm writing some automated tests for an app using rails 3.1. One of my tests is failing and at the point of failure I want to be able to jump into the rails console and inspect the state of things. Leading up to this assertion a lot of objects were created and states were changed.
After the test suite finishes running the test database is cleared.
I remember there was some way to insert a breakpoint in the test file or something similar which would throw me into the console. I've done a ton of googling and can't find it.
Anyone?
Upvotes: 1
Views: 329
Reputation: 13906
Require ruby-debug on your Gemfile.
If on 1.8:
gem 'ruby-debug'
If on 1.9:
gem 'ruby-debug19', :require => 'ruby-debug'
Note that if you're on 1.9.3 requires a few tweaks.
Finally, put a debugger
statement where you want to debug, and run your tests. It should popup a console.
I'd also recommend taking a look at pry, as Amadan stated.
Upvotes: 4
Reputation: 198418
Use Pry, and say binding.pry
as a breakpoint.
You might like this Railscast.
Upvotes: 2