Created
August 27, 2013 00:20
-
-
Save BenEddy/6348306 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 User do | |
describe ".name_matching" do | |
let!(:user) { User.create!(first_name: "Gaius", last_name: "Baltar") } | |
it "scopes to Users with matching first names" do | |
expect(User.name_matching("Gaius")).to eq([user]) | |
end | |
it "scopes to Users with matching last names" do | |
expect(User.name_matching("Baltar")).to eq([user]) | |
end | |
it "is case insensitive" do | |
expect(User.name_matching("gAIUS")).to eq([user]) | |
end | |
it "partially matches names" do | |
expect(User.name_matching("Gai")).to eq([user]) | |
end | |
it "excludes Users lacking matching names" do | |
expect(User.name_matching("Saul")).to be_empty | |
end | |
end | |
describe ".email_matching" do | |
let!(:user) { User.create!(email: "baltar@caprica.gov") } | |
it "scopes to Users with matching emails" do | |
expect(User.email_matching("baltar@caprica.gov")).to eq([user]) | |
end | |
it "is case insensitive" do | |
expect(User.email_matching("bAlTaR@CaPrIca.gov")).to eq([user]) | |
end | |
it "partially matches emails" do | |
expect(User.email_matching("baltar")).to eq([user]) | |
end | |
it "excludes Users lacking matching emails" do | |
expect(User.name_matching("saul@aol.com")).to be_empty | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment