Sha256: ff0189cdb5a7418dafa30e330941d9934ea6ddb3e48cae70bfe2812fcba60972

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

require 'sqlite3'
require 'sequel'

DB = Sequel.sqlite

RSpec.describe(OmniAuth::Identity::Models::Sequel, sqlite3: true) do
  before(:all) do
    # Connect to an in-memory sqlite3 database.
    DB.create_table :sequel_test_identities do
      primary_key :id
      String :email, null: false
      String :password_digest, null: false
    end
  end

  before do
    sequel_test_identity = Class.new(Sequel::Model(:sequel_test_identities)) do
      include ::OmniAuth::Identity::Models::Sequel
      auth_key :email
    end
    stub_const('SequelTestIdentity', sequel_test_identity)
  end

  describe 'model', type: :model do
    subject(:model_klass) { SequelTestIdentity }

    include_context 'persistable model'

    describe '::locate' do
      it 'delegates to the where query method' do
        allow(model_klass).to receive(:where).with('email' => 'open faced',
                                                   'category' => 'sandwiches').and_return(['wakka'])
        expect(model_klass.locate('email' => 'open faced', 'category' => 'sandwiches')).to eq('wakka')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-identity-3.0.9 spec/omniauth/identity/models/sequel_spec.rb