Gemfile を更新して rspec 3 に移行したため、多くのテストで次のエラーが発生しました:
it "should reject attribute that are too short" do
short = "a" * 3
hash = @attr.merge(:details => short)
Deal.new(hash).should have(1).error_on(:details)
end
次のエラーが表示されます。
Failure/Error: Deal.new(hash).should have(1).error_on(:details)
NoMethodError:
undefined method `have' for #<RSpec::ExampleGroups::Deal_2::TestsOnDealsModelsValidations>
shouldの代わりに「expect」を使用する必要があることを読みましたが、ここではhave(1).error_on
、rspec 3に準拠するにはどのように記述すればよいですか?
次のことを試しましたが、まだ機能しません。
it "should reject attribute that are too short" do
short = "a" * 3
hash = @attr.merge(:details => short)
expect(Deal.new(hash).error_on(:details).size).to eq(1)
end