Permalink
Browse files

fix RSpec tests to accommodate new longer Devise password default

  • Loading branch information...
1 parent 12936f5 commit 16a925c41fc630eaee27336423560b46a7f73233 @DanielKehoe DanielKehoe committed Jan 20, 2013
Showing with 18 additions and 18 deletions.
  1. +18 −18 spec/models/user_spec.rb
View
@@ -1,54 +1,54 @@
require 'spec_helper'
describe User do
-
+
before(:each) do
- @attr = {
+ @attr = {
:name => "Example User",
:email => "user@example.com",
- :password => "foobar",
- :password_confirmation => "foobar"
+ :password => "changeme",
+ :password_confirmation => "changeme"
}
end
-
+
it "should create a new instance given a valid attribute" do
User.create!(@attr)
end
-
+
it "should require an email address" do
no_email_user = User.new(@attr.merge(:email => ""))
no_email_user.should_not be_valid
end
-
+
it "should accept valid email addresses" do
addresses = %w[user@foo.com THE_USER@foo.bar.org first.last@foo.jp]
addresses.each do |address|
valid_email_user = User.new(@attr.merge(:email => address))
valid_email_user.should be_valid
end
end
-
+
it "should reject invalid email addresses" do
addresses = %w[user@foo,com user_at_foo.org example.user@foo.]
addresses.each do |address|
invalid_email_user = User.new(@attr.merge(:email => address))
invalid_email_user.should_not be_valid
end
end
-
+
it "should reject duplicate email addresses" do
User.create!(@attr)
user_with_duplicate_email = User.new(@attr)
user_with_duplicate_email.should_not be_valid
end
-
+
it "should reject email addresses identical up to case" do
upcased_email = @attr[:email].upcase
User.create!(@attr.merge(:email => upcased_email))
user_with_duplicate_email = User.new(@attr)
user_with_duplicate_email.should_not be_valid
end
-
+
describe "passwords" do
before(:each) do
@@ -63,7 +63,7 @@
@user.should respond_to(:password_confirmation)
end
end
-
+
describe "password validations" do
it "should require a password" do
@@ -75,21 +75,21 @@
User.new(@attr.merge(:password_confirmation => "invalid")).
should_not be_valid
end
-
+
it "should reject short passwords" do
short = "a" * 5
hash = @attr.merge(:password => short, :password_confirmation => short)
User.new(hash).should_not be_valid
end
-
+
end
-
+
describe "password encryption" do
-
+
before(:each) do
@user = User.create!(@attr)
end
-
+
it "should have an encrypted password attribute" do
@user.should respond_to(:encrypted_password)
end
@@ -100,4 +100,4 @@
end
-end
+end

0 comments on commit 16a925c

Please sign in to comment.