Skip to content
This repository has been archived by the owner on Aug 3, 2021. It is now read-only.

Active Record Relation query returns Relation Object not an Array #54

Open
rabinprithvi opened this issue Mar 30, 2015 · 1 comment
Open

Comments

@rabinprithvi
Copy link

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.

@ruralocity
Copy link
Member

I can't reproduce this. What version of Rails are you using?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants