カスタマーテーブルにフィールド名が有効です。これはcustomer.rbに以下のように検証:rspecではfalseがnilとみなされますか?
validates :active, :presence => true
ここフィールドSHORT_NAMEテストするRSpecのコードされる:SHORT_NAMEため
it "should be OK with duplicate short_name in different active status" do
customer = Factory(:customer, :active => false, :short_name => "test user")
customer1 = Factory.build(:customer, :active => true, :short_name => "Test user")
customer1.should be_valid
end
検証は、次のとおり
validates :short_name, :presence => true, :uniqueness => { :scope => :active }
上記コード原因エラー:
1) Customer data integrity should be OK with duplicate short_name in different active status
Failure/Error: customer = Factory(:customer, :active => false, :short_name => "test user")
ActiveRecord::RecordInvalid:
Validation failed: Active can't be blank
# ./spec/models/customer_spec.rb:62:in `block (3 levels) in <top (required)>'
フィールドactiveに割り当てられたfalse値がrspecによって空白またはnilとみなされ、データ検証チェックに失敗したようです。 falseに0を使用しようとしましたが、同じエラーが発生します。 field activeの検証を削除すると、rspecケースは成功します。
あなたは正しいです。ありがとう。 – user938363