Created
August 27, 2013 00:23
-
-
Save BenEddy/6348327 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe UserSearch do | |
describe "#results" do | |
let(:relation) { MockActiveRelation.new(:name_matching, :email_matching) } | |
def results(options = {}) | |
described_class.new(options).results | |
end | |
before { User.stub(scoped: relation) } | |
it "does not scope results by default" do | |
expect(results).to_not be_scoped | |
end | |
it "scopes by name" do | |
expect(results(name: "Laura")).to be_scoped_by(:name_matching, "Laura") | |
end | |
it "scopes by email" do | |
expect(results(email: "[email protected]")).to be_scoped_by(:email_matching, "[email protected]") | |
end | |
context "multiple options are specifed" do | |
let(:compound_results) { results(name: "Laura", email: "[email protected]") } | |
it "scopes by name" do | |
expect(compound_results).to be_scoped_by(:name_matching, "Laura") | |
end | |
it "scopes by email" do | |
expect(compound_results).to be_scoped_by(:email_matching, "[email protected]") | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment