[rspec-users] autotest debugger?

Scott Taylor mailing_lists at railsnewbie.com
Thu Nov 1 12:53:56 EDT 2007

On Nov 1, 2007, at 6:18 AM, Jamal Soueidan wrote:

> Hi,
> I keep facing problems with autotest, and I don't know what's  
> happening
> in the background, is there anyway to know what's happening while
> testing?
> Example:
> @user = User.new
> @user.email = "testcom"
> @user.errors.on(:email).should_not be_empty
> ...throws error failure

This is not an autotest problem, this is a test problem.

Usually I start adding extra tests:

it "should not raise an error with a new user (exploratory test)" do
	lambda {
	}.should_not raise_error

If that one fails...then it's a problem with my setup (before 
(:each))...and so on.

If I really have no idea what's going on, I'll insert the following  
snippet to the top of the spec:

require 'rubygems'; require 'ruby-debug'; debugger;

(I use textmate, and have a snippet setup so that I can type "debug"  
tab, and the full line gets inserted)

The next time autotest runs, it will drop me into the debugger (make  
sure you have the ruby-debug gem installed).

Hope that helps,


> - You have a nil object when you didn't expect it!
> - You might have expected an instance of Array.
> - The error occurred while evaluating nil.empty?
> ...but when I type this in ./script/console
>>> @user = User.new
> => #<User id: nil, email: nil, nickname: nil, password: nil,  
> logged_at:
> nil, created_at: nil>
>>> @user.valid?
> => false
>>> @user.email = "asd@"
>>> @user.errors.on 'email'
> => "is invalid"
> So how do you guys test things out and see what's happening behind?  
> I'm
> lost :(
> Thanks in advance :)
> -- 
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list