You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 3, 2021. It is now read-only.
Chapter 3 : Model specs - Testing class methods and scopes
File - spec/models/contact_spec.rb
Test case :
Context - context "matching letters" do
it "returns a sorted array of results that match" do
expect(Contact.by_letter("J")).to eq [@johnson, @jones]
end
end
Contact.by_letter("J") returns Active record relation object and not an array.
Hence we have to change Contact.by_letter("J") to Contact.by_letter("J") .pluck(:lastname) in the test case or change the model code.
The text was updated successfully, but these errors were encountered:
Chapter 3 : Model specs - Testing class methods and scopes
File - spec/models/contact_spec.rb
Test case :
Context - context "matching letters" do
it "returns a sorted array of results that match" do
expect(Contact.by_letter("J")).to eq [@johnson, @jones]
end
end
Contact.by_letter("J") returns Active record relation object and not an array.
Hence we have to change Contact.by_letter("J") to Contact.by_letter("J") .pluck(:lastname) in the test case or change the model code.
The text was updated successfully, but these errors were encountered: