Sha256: 45b321b27219c93bf1033ef1356437f1b29fe42f9cc488ed0fdcd43d15ff5332

Contents?: true

Size: 677 Bytes

Versions: 2

Compression:

Stored size: 677 Bytes

Contents

require 'spec_helper'
require 'authenticate/model/email'


describe Authenticate::Model::Email do

  it 'validates email' do
    user = build(:user, :without_email)
    user.save
    expect(user.errors.count).to be(2)
    expect(user.errors.messages[:email]).to include('is invalid')
    expect(user.errors.messages[:email]).to include("can't be blank")
  end

  it 'extracts credentials from params' do
    params = {session:{email:'foo', password:'bar'}}
    expect(User.credentials(params)).to match_array(%w(foo bar))
  end

  it 'authenticates from credentials' do
    user = create(:user)
    expect(User.authenticate([user.email, user.password])).to eq(user)
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
authenticate-0.2.3 spec/model/email_spec.rb
authenticate-0.2.2 spec/model/email_spec.rb