Sha256: 383a6d07e131b5b406450daf0aa55238bf2fd50b895deb93bf8b00ea6ba935a4

Contents?: true

Size: 1.2 KB

Versions: 10

Compression:

Stored size: 1.2 KB

Contents

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

10 entries across 10 versions & 3 rubygems

Version Path
doorkeeper-5.0.3 spec/lib/request/strategy_spec.rb
doorkeeper-5.1.0.rc2 spec/lib/request/strategy_spec.rb
doorkeeper-5.1.0.rc1 spec/lib/request/strategy_spec.rb
doorkeeper-5.0.2 spec/lib/request/strategy_spec.rb
doorkeeper-mongodb-5.0.0 spec/lib/request/strategy_spec.rb
doorkeeper-5.0.1 spec/lib/request/strategy_spec.rb
doorkeeper-sequel-2.0.0 spec/lib/request/strategy_spec.rb
doorkeeper-5.0.0 spec/lib/request/strategy_spec.rb
doorkeeper-5.0.0.rc2 spec/lib/request/strategy_spec.rb
doorkeeper-5.0.0.rc1 spec/lib/request/strategy_spec.rb