Skip to content

Instantly share code, notes, and snippets.

@noel
Created June 30, 2011 22:16
Show Gist options
  • Save noel/1057418 to your computer and use it in GitHub Desktop.
Save noel/1057418 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe User do
let(:user) do
Factory(:user, :username=>"gomezn")
end
let(:role) do
Factory(:role)
end
before(:each) do
end
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
anouther_user = User.new(:username=>user.username)
anouther_user.should_not be_valid
end
it "should have ldap params" do
email = user.email
email.should eql "gomezn@mycompany.com"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment