If you have a problem with some failing specs it is enough to just print out some variables and statements. But sometimes the problem is a little bit more complicated to handled this way. There the ruby debugger could by of help. Here is how you can do use it within your specs:
ruby-debug gem if you haven't already. But problably you do not need it. Then start
-d parameter to allow debugging and in your code, just add
debugger at the point you want to set the breakpoint. That's it.
# my_test.spec.rb describe "test me" do it "does something" do some_var = "print me" debugger false.should be true end end
Running the test would now open a debugger command line where you can put in the usual ruby-debug commands, here are some, to get you started:
l= # will print the ruby code of the line you are in # including some lines before and after to give # more context p some_var # would print the value of some_var c # would continue the test as usual n # would go to the next step s # would step into the method you are about to call
And here you get more infos about ruby-debug including a list of all available commands.