Sha256: c2debb6f82ef41e5a7c08e698ba79010f8bf486188e8fb833ec8789cd809ff1d

Contents?: true

Size: 1.23 KB

Versions: 22

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

require "spec_helper"

module Doorkeeper
  module Request
    describe Strategy do
      let(:server) { double }
      subject(:strategy) { Strategy.new(server) }

      describe :initialize do
        it "sets the server attribute" do
          expect(strategy.server).to eq server
        end
      end

      describe :request do
        it "requires an implementation" do
          expect { strategy.request }.to raise_exception NotImplementedError
        end
      end

      describe "a sample Strategy subclass" do
        let(:fake_request) { double }

        let(:strategy_class) do
          subclass = Class.new(Strategy) do
            class << self
              attr_accessor :fake_request
            end

            def request
              self.class.fake_request
            end
          end

          subclass.fake_request = fake_request
          subclass
        end

        subject(:strategy) { strategy_class.new(server) }

        it "provides a request implementation" do
          expect(strategy.request).to eq fake_request
        end

        it "authorizes the request" do
          expect(fake_request).to receive :authorize
          strategy.authorize
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 3 rubygems

Version Path
doorkeeper-5.1.2 spec/lib/request/strategy_spec.rb
doorkeeper-5.2.6 spec/lib/request/strategy_spec.rb
doorkeeper-5.3.3 spec/lib/request/strategy_spec.rb
doorkeeper-5.1.1 spec/lib/request/strategy_spec.rb
doorkeeper-5.2.5 spec/lib/request/strategy_spec.rb
doorkeeper-5.3.2 spec/lib/request/strategy_spec.rb
doorkeeper-5.4.0.rc1 spec/lib/request/strategy_spec.rb
doorkeeper-mongodb-5.2.1 spec/lib/request/strategy_spec.rb
doorkeeper-mongodb-5.2.0 spec/lib/request/strategy_spec.rb
doorkeeper-sequel-2.2.0 spec/lib/request/strategy_spec.rb
doorkeeper-5.2.4 spec/lib/request/strategy_spec.rb
doorkeeper-5.3.1 spec/lib/request/strategy_spec.rb
doorkeeper-5.3.0 spec/lib/request/strategy_spec.rb
doorkeeper-5.2.3 spec/lib/request/strategy_spec.rb
doorkeeper-5.2.2 spec/lib/request/strategy_spec.rb
doorkeeper-sequel-2.1.0 spec/lib/request/strategy_spec.rb
doorkeeper-5.2.1 spec/lib/request/strategy_spec.rb
doorkeeper-5.2.0 spec/lib/request/strategy_spec.rb
doorkeeper-5.2.0.rc3 spec/lib/request/strategy_spec.rb
doorkeeper-5.2.0.rc2 spec/lib/request/strategy_spec.rb