Skip to content

Instantly share code, notes, and snippets.

@joshuaclayton
Created July 15, 2009 21:17
Show Gist options
  • Save joshuaclayton/148003 to your computer and use it in GitHub Desktop.
Save joshuaclayton/148003 to your computer and use it in GitHub Desktop.
class UserTest < ActiveSupport::TestCase
should_belong_to :customer
context "Clearance tests" do
setup do
User.any_instance.stubs(:generate_random_password)
end
include Clearance::Test::Unit::UserTest
end
context "A user instance" do
setup { @user = Factory(:email_confirmed_user) }
should "correctly generate a random password" do
ActiveSupport::SecureRandom.expects(:hex).with(6).returns("random password")
@user.expects(:password=).with("random password")
@user.expects(:password_confirmation=).with("random password")
@user.generate_random_password
end
# etc.
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment