Revisions

gist: 148003 Download_button fork
public
Public Clone URL: git://gist.github.com/148003.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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