Rails - 验证包含在rake测试中失败:集成

时间:2011-12-04 22:30:37

标签: ruby-on-rails validation rake integration

在运行'rake test'和运行'rake test:integration'时,我看到了不同的结果。

当使用'rake test'运行所有测试时,所有测试都通过。 运行'rake test:integration'时,我的测试失败,因为我的模型在保存之前无法验证是否包含了属性。

我的模型看起来像:

class Order < ActiveRecord::Base
  belongs_to :payment_type
  validates :payment_type, :inclusion => PaymentType.all
  ...
end

PaymentType是一个查找表,我有一个夹具。

在Order模型中调试save方法时,我发现它没有通过包含验证(再次,仅在运行集成测试时), 但是

PaymentType.all.include?(payment_type) 

评估为'true'。

为什么在仅运行集成测试时失败的想法?

0 个答案:

没有答案