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
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to