Sha256: 5e731afea732b8c3094d1556dddb8f550ddf0dcae2b68a8eaa66eb8c8bf83f4c

Contents?: true

Size: 1.85 KB

Versions: 33

Compression:

Stored size: 1.85 KB

Contents

require 'spec_helper'
require 'pact/consumer/configuration'

module Pact::Consumer::Configuration

   describe MockService do
      before do
         Pact.clear_configuration
         Pact::Consumer::AppManager.instance.stub(:register_mock_service_for)
      end

      describe "configure_consumer_contract_builder" do
         let(:consumer_name) {'consumer'}
         subject {
            MockService.build :mock_service, consumer_name, provider_name do
               port 1234
               standalone true
               verify true
            end
         }

         let(:provider_name) { 'Mock Provider'}
         let(:consumer_contract_builder) { instance_double('Pact::Consumer::ConsumerContractBuilder')}
         let(:url) { "http://localhost:1234"}

         it "adds a verification to the Pact configuration" do
            Pact::Consumer::ConsumerContractBuilder.stub(:new).and_return(consumer_contract_builder)
            subject.finalize
            consumer_contract_builder.should_receive(:verify)
            Pact.configuration.provider_verifications.first.call
         end

         context "when standalone" do
            it "does not register the app with the AppManager" do
               Pact::Consumer::AppManager.instance.should_not_receive(:register_mock_service_for)
               subject.finalize
            end
         end
         context "when not standalone" do
            subject {
               MockService.build :mock_service, consumer_name, provider_name do
                  port 1234
                  standalone false
                  verify true
               end
            }
            it "registers the app with the AppManager" do
               Pact::Consumer::AppManager.instance.should_receive(:register_mock_service_for).with(provider_name, url)
               subject.finalize
            end
         end
      end
   end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
pact-1.1.1 spec/lib/pact/consumer/configuration_spec.rb
pact-1.1.0 spec/lib/pact/consumer/configuration_spec.rb
pact-1.1.0.rc5 spec/lib/pact/consumer/configuration_spec.rb
pact-1.1.0.rc4 spec/lib/pact/consumer/configuration_spec.rb
pact-1.1.0.rc3 spec/lib/pact/consumer/configuration_spec.rb
pact-1.0.39 spec/lib/pact/consumer/configuration_spec.rb
pact-1.1.0.rc2 spec/lib/pact/consumer/configuration_spec.rb
pact-1.0.38 spec/lib/pact/consumer/configuration_spec.rb
pact-1.1.0.rc1 spec/lib/pact/consumer/configuration_spec.rb
pact-1.0.37 spec/lib/pact/consumer/configuration_spec.rb
pact-1.0.36 spec/lib/pact/consumer/configuration_spec.rb
pact-1.0.35 spec/lib/pact/consumer/configuration_spec.rb
pact-1.0.34 spec/lib/pact/consumer/configuration_spec.rb
pact-1.0.33 spec/lib/pact/consumer/configuration_spec.rb
pact-1.0.32 spec/lib/pact/consumer/configuration_spec.rb
pact-1.0.31 spec/lib/pact/consumer/configuration_spec.rb
pact-1.0.30 spec/lib/pact/consumer/configuration_spec.rb
pact-1.0.29 spec/lib/pact/consumer/configuration_spec.rb
pact-1.0.28 spec/lib/pact/consumer/configuration_spec.rb
pact-1.0.27 spec/lib/pact/consumer/configuration_spec.rb