-
-
Save dmitryrck/54952f4c2a3554fccb1e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
validates :username, presence: :true | |
validates :password_digest, presence: :true | |
has_secure_password | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec/helper' | |
describe User do | |
subject do | |
User.new :username => 'dmitrynix', :password_digest => "any string" | |
end | |
it { should be_valid } | |
it 'should not be valid without username' do | |
subject.username = nil | |
expect(subject).to_not be_valid | |
end | |
it 'should not be valid without password_digest' do | |
subject.password_digest = nil | |
expect(subject).to_not be_valid | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment