Running ruby debug in rspec?
You will get what you want by including require 'ruby-debug'
at the top of your spec:
# spec/models/user_spec.rbrequire 'spec_helper'require 'ruby-debug'describe User do it "should be valid" do debugger User.new.should be_valid endend
You would then run rake spec
or rspec
as normal
NOTE: I now prefer Ruby 2.0+ and pry. It is pretty much the same process:
require 'spec_helper'require 'pry-debugger'describe User do it "should be valid" do binding.pry expect(User.new).to be_valid endend
Also, I generally put requires like this in my spec_helper file, so that pry-debugger is available to all of my specs.
You can create an .rspec
configuration file in the root of your project and include the line:
--debug
For Ruby >= 1.9.2
You should install the debugger gem instead of ruby-debug19. It you use bundler, you just put this in your Gemfile:
group :test do gem "debugger"end
After that you can just put
rspec < 3.0
--debug
rspec >= 3.0
-rdebugger
in your .rspec
file
Then you can just run
bundle exec rake spec
without any additional arguments. There is no need to modify your source code either (not even your test source code)