Sha256: f716f9f2143dfa4b97e7a0a3012cf6ffdebcb3193545862c210775eee76662fd

Contents?: true

Size: 1.16 KB

Versions: 16

Compression:

Stored size: 1.16 KB

Contents

require 'pact_broker/api/resources/base_resource'

module PactBroker
  module Api
    module Resources
      describe BaseResource do
        let(:request) { double('request', uri: uri) }
        let(:response) { double('response') }
        let(:uri) { URI('http://example.org/path?query') }

        subject { BaseResource.new(request, response) }

        its(:resource_url) { is_expected.to eq 'http://example.org/path' }

        describe "options" do
          subject { options "/"; last_response }

          it "returns a list of allowed methods" do
            expect(subject.headers['Access-Control-Allow-Methods']).to eq "GET, OPTIONS"
          end
        end
      end

      ALL_RESOURCES = ObjectSpace.each_object(::Class).select {|klass| klass < BaseResource }

      ALL_RESOURCES.each do | resource |
        describe resource do
          let(:request) { double('request', uri: URI("http://example.org")) }
          let(:response) { double('response') }

          it "includes OPTIONS in the list of allowed_methods" do
            expect(resource.new(request, response).allowed_methods).to include "OPTIONS"
          end
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
pact_broker-2.30.0 spec/lib/pact_broker/api/resources/base_resource_spec.rb
pact_broker-2.29.0 spec/lib/pact_broker/api/resources/base_resource_spec.rb
pact_broker-2.27.6 spec/lib/pact_broker/api/resources/base_resource_spec.rb
pact_broker-2.27.5 spec/lib/pact_broker/api/resources/base_resource_spec.rb
pact_broker-2.27.4 spec/lib/pact_broker/api/resources/base_resource_spec.rb
pact_broker-2.27.3 spec/lib/pact_broker/api/resources/base_resource_spec.rb
pact_broker-2.27.2 spec/lib/pact_broker/api/resources/base_resource_spec.rb
pact_broker-2.27.0 spec/lib/pact_broker/api/resources/base_resource_spec.rb
pact_broker-2.26.1 spec/lib/pact_broker/api/resources/base_resource_spec.rb
pact_broker-2.26.0 spec/lib/pact_broker/api/resources/base_resource_spec.rb
pact_broker-2.25.0 spec/lib/pact_broker/api/resources/base_resource_spec.rb
pact_broker-2.24.0 spec/lib/pact_broker/api/resources/base_resource_spec.rb
pact_broker-2.23.4 spec/lib/pact_broker/api/resources/base_resource_spec.rb
pact_broker-2.23.3 spec/lib/pact_broker/api/resources/base_resource_spec.rb
pact_broker-2.23.2 spec/lib/pact_broker/api/resources/base_resource_spec.rb
pact_broker-2.23.1 spec/lib/pact_broker/api/resources/base_resource_spec.rb