Greg Donald wrote: > On Mon, Aug 23, 2010 at 2:09 PM, Marnen Laibow-Koser > <[email protected]> wrote: >> ...and you've conveniently left out the hard-to-read assert statements. > > test "should have a first name" do > count = User.count( :all ) > u = User.new( :email => '[email protected]', :password => > 'xxxxxxxx', :lname => 'foobar', :last_login => Time.now ) > assert !u.valid? > assert_not_nil u.errors[:fname] > assert_equal count, User.count( :all ) > u.fname = 'foo' > assert u.save > assert_equal count + 1, User.count( :all ) > end > > test "user can login" do > get :login > assert_response :success > post :login, { :login => { :email => '[email protected]', > :password => 'changeme' } } > assert_redirected_to '/' > assert_not_nil session[:user_id] > end > > What's so hard to read? > >
Just about every line of that is hard to read IMHO. I find assert_equal a, b to look cryptic and require me to stop and think every time I see it. By contrast, a.should == b reads more like English (or idiomatic Ruby) and reads quickly and easily for me. (It's also less typing than the Test::Unit version.) I'll post an RSpec version for comparison when I'm not typing on my phone. I don't know why you continue to torture yourself with assert_ syntax. :) > -- > Greg Donald > destiney.com | gregdonald.com Best, -- Marnen Laibow-Koser http://www.marnen.org [email protected] Sent from my iPhone -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

