0

I'm upgrading my rails 2 app to rails 3. I use rspec, shoulda and factory girl in the test suite.

One particular pattern is causing an error I'm having a really hard time both researching and solving.

  # cart controller spec
  @cart = Factory.build(:cart, :payment_status => "authorized", :user_id => @user.id)
  2.times { Factory(:cart_item, :cart => @cart) }

And I get this spec failure:

changes is defined by ActiveRecord
./spec/controllers/cart_controller_spec.rb:41
./spec/controllers/cart_controller_spec.rb:41:in `times'
./spec/controllers/cart_controller_spec.rb:41

calling the #times method is safe ( no error are thrown when I just put 2.times { puts "hi" } ) but I'm not able to see how #changes is being invoked here.

brycemcd
  • 4,343
  • 3
  • 26
  • 29

1 Answers1

2

Do you have a column called 'changes'? I suspect it's clashing with ActiveRecord, you may need to rename it.

Andy Waite
  • 10,785
  • 4
  • 33
  • 47
  • see also http://stackoverflow.com/questions/1510875/how-can-i-use-activerecord-on-a-database-that-has-a-column-named-valid-danger – zetetic May 21 '11 at 16:46