Sha256: 408fcf8e5f736def002b9b83083f4832f2c15b1ca8d66694ec5723c11692afe9

Contents?: true

Size: 680 Bytes

Versions: 1

Compression:

Stored size: 680 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(['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

1 entries across 1 versions & 1 rubygems

Version Path
authenticate-0.2.1 spec/model/email_spec.rb