Skip to content

Instantly share code, notes, and snippets.

@BenEddy
Created August 27, 2013 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenEddy/6348320 to your computer and use it in GitHub Desktop.
Save BenEddy/6348320 to your computer and use it in GitHub Desktop.
describe UserSearch do
describe "#results" do
before { User.stub(scoped: MockActiveRelation.new) }
def results(options={})
described_class.new(options).results
end
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("Laura")
end
it "scopes by email" do
expect(results(email: "roslin@bing.com")).to be_scoped_by_email("roslin@bing.com")
end
context "multiple options are specifed" do
let(:compound_results) { results(name: "Laura", email: "roslin@bing.com") }
it "scopes by name" do
expect(compound_results).to be_scoped_by_name("Laura")
end
it "scopes by email" do
expect(compound_results).to be_scoped_by_email("roslin@bing.com")
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment