forked from saurabh/orbit4-5
46 lines
1.1 KiB
Ruby
46 lines
1.1 KiB
Ruby
#this is a class to test the signup
|
|
require 'test_helper'
|
|
require 'minitest/autorun'
|
|
|
|
class UserTest < ActiveSupport::TestCase
|
|
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
|