factory_girl_rails と rspec を使用していますが、問題が発生し、次のエラーが発生します
1) WebsiteLink when link is external
Failure/Error: website_link.external should be false
expected #<FalseClass:0> => false
got #<WebsiteLink:100584240> => #<WebsiteLink id: nil, website_id: nil, link: nil, external: nil, checked: nil, click_count: nil, transition_count: nil, created_at: nil, updated_at: nil, link_description: nil>
Compared using equal?, which compares object identity,
but expected and actual are not the same object. Use
`expect(actual).to eq(expected)` if you don't care about
object identity in this example.
それはspec.rbファイルの私のコードです
it "when link is external" do
website = FactoryGirl.create(:website,site_address: "www.socpost.ru")
website_link = FactoryGirl.create(:website_link, link: "www.google.com", website: website)
website_link.external should be true
end
factory_girl 工場
FactoryGirl.define do
factory :website do
sequence(:site_name){ |i| "Facebook#{i}" }
sequence(:site_address){ |i| "www.facebook_#{i}.com" }
sequence(:website_key){ |i| (1234567 + i).to_s }
end
factory :website_link do
sequence(:link){ |i| "www.facebook.com/test_#{i}" }
external false
checked false
click_count 1
transition_count 1
link_description "Hello"
website
end
end