Skip to content

Instantly share code, notes, and snippets.

@dmitryrck
Forked from dannluciano/user.rb
Last active August 29, 2015 14:06
Show Gist options
  • Save dmitryrck/54952f4c2a3554fccb1e to your computer and use it in GitHub Desktop.
Save dmitryrck/54952f4c2a3554fccb1e to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
validates :username, presence: :true
validates :password_digest, presence: :true
has_secure_password
end
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