Hello,
I must be doing something dumb, but here it goes...
why does this work?
before(:each) do
@work = Work.new
end
#for testing validates_presence_of :title
it "should require a title" do
@work.title = nil
@work.should_not be_valid
end
while this doesn''t:
def valid_work_attributes
{
:title => "guernica",
:description => "lorem ipsum lorem ipsum",
:date => Date.today,
:category => Category.new(:name => "belle epoque")
}
end
before(:each) do
@work = Work.new
end
it "should require a title" do
@work.attributes = valid_work_attributes.except(:title)
@work.should_not be_valid
end
the latter example fails with "expected valid? to return false, got
true" for
@work.should_not be_valid
doesn''t make sense to me, and I''ve been stuck for a while
already :P
any help greatly appreciated, please bear with the newbie :)
Oliver
Here is a very good example by Luke, which I think you should follow - http://www.lukeredpath.co.uk/2006/8/29/developing-a-rails-model-using-bdd-and-rspec-part-1 fyi, Namrata -- Posted via http://www.ruby-forum.com/.
Hi Namrata, thanks, that''s a great resource and I ended up beefing my tests based on the recommendations there. actually though, the problem I was having was that validations weren''t being recognized by the test suite. later I found out that when regenerating the scaffold for the app a while back, the database.yml used the sqlite adapter instead of mysql (I''d forgotten about this) - once I switched back to mysql, where the database was prepared, the flunking tests starting passing. :P - Oliver 2008/3/4, Namrata Tiwari <lists at ruby-forum.com>:> Here is a very good example by Luke, which I think you should follow - > > http://www.lukeredpath.co.uk/2006/8/29/developing-a-rails-model-using-bdd-and-rspec-part-1 > > fyi, > Namrata > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Possibly Parallel Threads
- Peculiar Hpricot error in Rails app
- Variable assigned to grep output - missing letter n!
- Splitting a DF into rows according to a column
- replace a few strings in a text file
- [Bug 1714] New: Stack smash: libnftables does not enforce string length limits for log prefixes