orbit4-5/test/models/user_test.rb

46 lines
1.1 KiB
Ruby
Raw Normal View History

2014-04-10 04:01:34 +00:00
#this is a class to test the signup
require 'test_helper'
2014-04-10 04:01:34 +00:00
require 'minitest/autorun'
class UserTest < ActiveSupport::TestCase
2014-04-10 04:01:34 +00:00
def valid_params
{ user_name: "johndoe", email: "john@example.com", password: "password123", password_confirmation: "password123" }
end
let(:user) { User.new valid_params }
it "should fail when password and password confirmation do not match" do
def user.password_confirmation
"password456"
end
user.wont_be :valid?
end
it "should not pass when email not supplied" do
def user.email
nil
end
user.wont_be :valid?
user.errors[:email].must_be :present?
end
it "should not pass when user_name not supplied" do
def user.user_name
nil
end
user.wont_be :valid?
user.errors[:user_name].must_be :present?
end
it "should pass when password and password confirmation are same" do
assert user.must_be :valid?, "Can't create with valid params: #{user.errors.messages}"
end
it "should check the email format" do
def user.email
"fsdnjgsjk@lo;;sdfd"
end
user.wont_be :valid?
end
end