Skip to content

Instantly share code, notes, and snippets.

@roykolak
Created November 12, 2010 21:06
Show Gist options
  • Save roykolak/674689 to your computer and use it in GitHub Desktop.
Save roykolak/674689 to your computer and use it in GitHub Desktop.
describe "#generate_login" do
context "when the user's name is available as a login" do
it "sets the login to a combination of user's name" do
user.generate_login
user.login.should == 'jdoe'
end
end
context "when the user's name is not available as a login" do
let(:user_with_same_name) {Factory.build(:user)}
it "sets the login to a combination of user's name with a 2 on the end when it is the 2nd login for that name" do
user.save
user_with_same_name.generate_login
user_with_same_name.login.should == 'jdoe2'
end
it "sets the login to a combination of user's name with a N on the end when it is the Nth login for that name" do
Factory.create(:user) && Factory.create(:user) && Factory.create(:user)
user_with_same_name.generate_login
user_with_same_name.login.should == 'jdoe4'
end
end
end
describe "#generate_password" do
it "sets the password to the user's last name plus 123" do
user.generate_password
user.password.should == "#{user.last_name.downcase}123"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment