Sha256: 8178ec2a415319d82aaf2f56e332063b683821fadb0ff24bf9bd998398365d25

Contents?: true

Size: 1.55 KB

Versions: 28

Compression:

Stored size: 1.55 KB

Contents

require 'spec_helper'
require 'pact_broker/api/resources/latest_pact'
require 'rack/test'

module PactBroker::Api

  module Resources

    describe LatestPact do

      include Rack::Test::Methods

      let(:app) { PactBroker::API }

      describe "GET" do

        context "Accept: text/html" do

          let(:json_content) { 'json_content' }
          let(:pact) { double("pact", json_content: json_content)}
          let(:html) { 'html' }
          let(:pact_id_params) { {:provider_name=>"provider_name", :consumer_name=>"consumer_name"} }

          before do
            allow(PactBroker::Pacts::Service).to receive(:find_latest_pact).and_return(pact)
            allow(PactBroker.configuration.html_pact_renderer).to receive(:call).and_return(html)
          end

          subject { get "/pacts/provider/provider_name/consumer/consumer_name/latest",{}, {'HTTP_ACCEPT' => "text/html"} }

          it "find the pact" do
            expect(PactBroker::Pacts::Service).to receive(:find_latest_pact).with(pact_id_params)
            subject
          end

          it "uses the configured HTML renderer" do
            expect(PactBroker.configuration.html_pact_renderer).to receive(:call).with(pact)
            subject
          end

          it "returns a HTML body" do
            subject
            expect(last_response.body).to eq html
          end

          it "returns a content type of HTML" do
            subject
            expect(last_response.headers['Content-Type']).to eq 'text/html;charset=utf-8'
          end

        end
      end

    end
  end

end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
pact_broker-2.0.3 spec/lib/pact_broker/api/resources/latest_pact_spec.rb
pact_broker-2.0.2 spec/lib/pact_broker/api/resources/latest_pact_spec.rb
pact_broker-2.0.1 spec/lib/pact_broker/api/resources/latest_pact_spec.rb
pact_broker-2.0.0 spec/lib/pact_broker/api/resources/latest_pact_spec.rb
pact_broker-2.0.0.beta.8 spec/lib/pact_broker/api/resources/latest_pact_spec.rb
pact_broker-2.0.0.beta.7 spec/lib/pact_broker/api/resources/latest_pact_spec.rb
pact_broker-2.0.0.beta.6 spec/lib/pact_broker/api/resources/latest_pact_spec.rb
pact_broker-1.18.0 spec/lib/pact_broker/api/resources/latest_pact_spec.rb
pact_broker-2.0.0.beta.5 spec/lib/pact_broker/api/resources/latest_pact_spec.rb
pact_broker-1.18.0.beta.1 spec/lib/pact_broker/api/resources/latest_pact_spec.rb
pact_broker-1.17.2 spec/lib/pact_broker/api/resources/latest_pact_spec.rb
pact_broker-1.17.1 spec/lib/pact_broker/api/resources/latest_pact_spec.rb
pact_broker-2.0.0.beta.4 spec/lib/pact_broker/api/resources/latest_pact_spec.rb
pact_broker-2.0.0.beta.3 spec/lib/pact_broker/api/resources/latest_pact_spec.rb
pact_broker-2.0.0.beta.2 spec/lib/pact_broker/api/resources/latest_pact_spec.rb
pact_broker-2.0.0.beta.1 spec/lib/pact_broker/api/resources/latest_pact_spec.rb
pact_broker-1.17.0 spec/lib/pact_broker/api/resources/latest_pact_spec.rb
pact_broker-1.16.0 spec/lib/pact_broker/api/resources/latest_pact_spec.rb
pact_broker-1.15.0 spec/lib/pact_broker/api/resources/latest_pact_spec.rb
pact_broker-1.14.0 spec/lib/pact_broker/api/resources/latest_pact_spec.rb