Rails3、rspec2 ActiveRecord#规格中的更改错误

发布于 2024-11-08 12:10:50 字数 638 浏览 1 评论 0原文

我正在将 Rails 2 应用程序升级到 Rails 3。我在测试套件中使用 rspec、shoulda 和 Factory Girl。

一种特定的模式导致了一个错误,我在研究和解决方面都遇到了很大的困难。

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

我得到了这个规范失败:

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

调用 #times 方法是安全的(当我输入 2.times { put "hi" } 时不会抛出任何错误),但我不知道如何 #此处正在调用更改。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深居我梦 2024-11-15 12:10:50

您有一个名为“更改”的专栏吗?我怀疑它与 ActiveRecord 冲突,您可能需要重命名它。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文