Skip to content

Instantly share code, notes, and snippets.

@raine
Forked from noel/gist:1057418
Created June 30, 2011 22:19
Show Gist options
  • Save raine/1057422 to your computer and use it in GitHub Desktop.
Save raine/1057422 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe User do
it "should create a new user given a username" do
User.create!(:username => "rmcenroe")
end
it "should not create a new user given a bad username" do
bad_user = User.new(:username => "not_real")
bad_user.should_not be_valid
end
it "should return false for bad username" do
User.valid_username?("bad_username").should be_false
end
it "should return true for good username" do
User.valid_username?("gomezn").should be_true
end
it "should not allow for multiple users with the same username" do
user = Factory(:user)
user.should be_valid
second_user = Factory(:user, :username => user.username)
second_user.should_not be_valid
second_user.errors[:username].should_not be_blank # not sure about this, some people seem to like it
end
it "should have ldap params" do
user = Factory(:user, :username =>"gomezn")
user.email.should == "[email protected]"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment