Sha256: c24568ce7280da6c174c8e9e7e208026fb7b43aa79e711e97eaa4c8656d88e29

Contents?: true

Size: 1.05 KB

Versions: 22

Compression:

Stored size: 1.05 KB

Contents

RSpec.shared_examples 'Nyauth::Authenticatable' do |klass|
  it_behaves_like 'Nyauth::PasswordDigestAbility', klass
  let!(:instance) { create(klass.name.downcase.to_sym, email: email, password: password) }

  describe '.authenticate' do
    let(:email) { 'correct@example.com' }
    let(:password) { 'password' }
    subject { klass.authenticate(given_email, given_password) }

    context 'when correct email' do
      let(:given_email) { email }
      context 'and correct password' do
        let(:given_password) { password }
        it { is_expected.to eq instance }
      end

      context 'and wrong password' do
        let(:given_password) { 'invalid' }
        it { is_expected.to be_nil }
      end
    end

    context 'when wrong email' do
      let(:given_email) { 'wrong@example.com' }
      context 'and correct password' do
        let(:given_password) { password }
        it { is_expected.to be_nil }
      end

      context 'and wrong password' do
        let(:given_password) { 'invalid' }
        it { is_expected.to be_nil }
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
nyauth-0.7.2 spec/support/models/nyauth/authenticatable.rb
nyauth-0.7.1 spec/support/models/nyauth/authenticatable.rb
nyauth-0.7.0 spec/support/models/nyauth/authenticatable.rb
nyauth-0.6.2 spec/support/models/nyauth/authenticatable.rb
nyauth-0.6.1 spec/support/models/nyauth/authenticatable.rb
nyauth-0.6.0 spec/support/models/nyauth/authenticatable.rb
nyauth-0.5.0 spec/support/models/nyauth/authenticatable.rb
nyauth-0.4.0 spec/support/models/nyauth/authenticatable.rb
nyauth-0.3.0 spec/support/models/nyauth/authenticatable.rb
nyauth-0.2.8 spec/support/models/nyauth/authenticatable.rb
nyauth-0.2.7 spec/support/models/nyauth/authenticatable.rb
nyauth-0.2.6 spec/support/models/nyauth/authenticatable.rb
nyauth-0.2.5 spec/support/models/nyauth/authenticatable.rb
nyauth-0.2.4 spec/support/models/nyauth/authenticatable.rb
nyauth-0.2.3 spec/support/models/nyauth/authenticatable.rb
nyauth-0.2.2 spec/support/models/nyauth/authenticatable.rb
nyauth-0.2.1 spec/support/models/nyauth/authenticatable.rb
nyauth-0.2.0 spec/support/models/nyauth/authenticatable.rb
nyauth-0.1.0 spec/support/models/nyauth/authenticatable.rb
nyauth-0.0.3 spec/support/models/nyauth/authenticatable.rb