Sha256: b49f54ff030bf38b4ae8e8fe6913e9941818b51419c0b665e6952a79b9ad198b
Contents?: true
Size: 1.53 KB
Versions: 20
Compression:
Stored size: 1.53 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
20 entries across 20 versions & 1 rubygems