Sha256: 519e2d6aa98e7601d3b3fc78d3c9e0749705dabe59024da17d375a0eff55b3d5
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 KB
Contents
require 'spec_helper' require 'volt/models/user' class FakeConfig def public self end def auth self end def use_username true end end describe Volt::User do describe '.login_field' do subject { Volt::User.login_field } describe 'when use_username is set to true' do before do allow(Volt).to receive(:config).and_return FakeConfig.new end it 'returns :username' do expect(subject).to eq :username end end describe 'when use_username is not set' do it 'returns :email' do expect(subject).to eq :email end end end describe '#password=' do let!(:user) { Volt::User.new } subject { user.password = 'test' } if RUBY_PLATFORM != 'opal' describe 'when it is a Volt server' do before do allow(BCrypt::Password).to receive(:create).with('test') .and_return 'hashed-password' end it 'encrypts password' do subject expect(BCrypt::Password).to have_received :create end it 'sets _hashed_password to passed value' do subject expect(user._hashed_password).to eq 'hashed-password' end end end describe 'when it is not a Volt server' do before do allow(Volt).to receive(:server?).and_return false end subject { user.password = 'a valid test password' } it 'sets _password to passed value' do subject expect(user._password).to eq('a valid test password') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
volt-0.9.2 | spec/models/user_spec.rb |