Sha256: 069a172cf9c77c00fa63cd82e2f96a2e6050a652a3474257c5b1decfb7bd9690

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 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
    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

2 entries across 2 versions & 1 rubygems

Version Path
omniauth-identity-3.0.8 spec/omniauth/identity/models/sequel_spec.rb
omniauth-identity-3.0.7 spec/omniauth/identity/models/sequel_spec.rb