Sha256: 7a8f8907605272e82acef2e858d1da14e3955d735f0706f72529e0a316810197

Contents?: true

Size: 676 Bytes

Versions: 2

Compression:

Stored size: 676 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.3.1 spec/model/email_spec.rb
authenticate-0.3.0 spec/model/email_spec.rb