Permalink
Browse files

fixing user validation tests in nifty:authentication (thanks apocalyp…

…tiq) - closes #87
  • Loading branch information...
1 parent 5ffbf7a commit ac2c0ff548418aa4d5c96eadd35c9e181cfb4684 @ryanb committed Feb 14, 2011
@@ -3,6 +3,7 @@ Feature: Nifty Authentication Generator
As a rails developer
I want to generate some user authentication
+ @focus
Scenario: Generate default authentication
Given a new Rails app
When I insert "root :to => 'users#new'" into "config/routes.rb" after line 1
@@ -21,37 +21,37 @@ def setup
end
should "require username" do
- assert new_<%= user_singular_name %>(:username => '').errors[:username]
+ assert_equal ["can't be blank"], new_<%= user_singular_name %>(:username => '').errors[:username]
end
should "require password" do
- assert new_<%= user_singular_name %>(:password => '').errors[:password]
+ assert_equal ["can't be blank"], new_<%= user_singular_name %>(:password => '').errors[:password]
end
should "require well formed email" do
- assert new_<%= user_singular_name %>(:email => 'foo@bar@example.com').errors[:email]
+ assert_equal ["is invalid"], new_<%= user_singular_name %>(:email => 'foo@bar@example.com').errors[:email]
end
should "validate uniqueness of email" do
new_<%= user_singular_name %>(:email => 'bar@example.com').save!
- assert new_<%= user_singular_name %>(:email => 'bar@example.com').errors[:email]
+ assert_equal ["has already been taken"], new_<%= user_singular_name %>(:email => 'bar@example.com').errors[:email]
end
should "validate uniqueness of username" do
new_<%= user_singular_name %>(:username => 'uniquename').save!
- assert new_<%= user_singular_name %>(:username => 'uniquename').errors[:username]
+ assert_equal ["has already been taken"], new_<%= user_singular_name %>(:username => 'uniquename').errors[:username]
end
should "not allow odd characters in username" do
- assert new_<%= user_singular_name %>(:username => 'odd ^&(@)').errors[:username]
+ assert_equal ["should only contain letters, numbers, or .-_@"], new_<%= user_singular_name %>(:username => 'odd ^&(@)').errors[:username]
end
should "validate password is longer than 3 characters" do
- assert new_<%= user_singular_name %>(:password => 'bad').errors[:password]
+ assert_equal ["is too short (minimum is 4 characters)"], new_<%= user_singular_name %>(:password => 'bad').errors[:password]
end
should "require matching password confirmation" do
- assert new_<%= user_singular_name %>(:password_confirmation => 'nonmatching').errors[:password]
+ assert_equal ["doesn't match confirmation"], new_<%= user_singular_name %>(:password_confirmation => 'nonmatching').errors[:password]
end
should "generate password hash and salt on create" do
@@ -21,37 +21,37 @@ def test_valid
end
def test_require_username
- assert new_<%= user_singular_name %>(:username => '').errors[:username]
+ assert_equal ["can't be blank"], new_<%= user_singular_name %>(:username => '').errors[:username]
end
def test_require_password
- assert new_<%= user_singular_name %>(:password => '').errors[:password]
+ assert_equal ["can't be blank"], new_<%= user_singular_name %>(:password => '').errors[:password]
end
def test_require_well_formed_email
- assert new_<%= user_singular_name %>(:email => 'foo@bar@example.com').errors[:email]
+ assert_equal ["is invalid"], new_<%= user_singular_name %>(:email => 'foo@bar@example.com').errors[:email]
end
def test_validate_uniqueness_of_email
new_<%= user_singular_name %>(:email => 'bar@example.com').save!
- assert new_<%= user_singular_name %>(:email => 'bar@example.com').errors[:email]
+ assert_equal ["has already been taken"], new_<%= user_singular_name %>(:email => 'bar@example.com').errors[:email]
end
def test_validate_uniqueness_of_username
new_<%= user_singular_name %>(:username => 'uniquename').save!
- assert new_<%= user_singular_name %>(:username => 'uniquename').errors[:username]
+ assert_equal ["has already been taken"], new_<%= user_singular_name %>(:username => 'uniquename').errors[:username]
end
def test_validate_odd_characters_in_username
- assert new_<%= user_singular_name %>(:username => 'odd ^&(@)').errors[:username]
+ assert_equal ["should only contain letters, numbers, or .-_@"], new_<%= user_singular_name %>(:username => 'odd ^&(@)').errors[:username]
end
def test_validate_password_length
- assert new_<%= user_singular_name %>(:password => 'bad').errors[:password]
+ assert_equal ["is too short (minimum is 4 characters)"], new_<%= user_singular_name %>(:password => 'bad').errors[:password]
end
def test_require_matching_password_confirmation
- assert new_<%= user_singular_name %>(:password_confirmation => 'nonmatching').errors[:password]
+ assert_equal ["doesn't match confirmation"], new_<%= user_singular_name %>(:password_confirmation => 'nonmatching').errors[:password]
end
def test_generate_password_hash_and_salt_on_create

0 comments on commit ac2c0ff

Please sign in to comment.