Sha256: c7eebd62d3af7ba4511bd1dca6f86334329440eb13f4510445da2f8d0d1fb962

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

require 'spec_helper'
require 'pact/configuration'
require 'pact/consumer/dsl'
require 'pact/consumer/configuration_dsl'
require 'pact/producer/configuration_dsl'

describe "configure" do

 before do
    Pact.clear_configuration
    Pact::Consumer::AppManager.instance.clear_all

    Pact.configure do | config |
      config.consumer do
        name "My Consumer"
      end
    end

    Pact.with_producer "My Service" do
      mock_service :my_service do
        port 1234
        standalone true
      end
    end

    Pact.with_producer "My Other Service" do
      mock_service :my_other_service do
        port 1235
        standalone false
      end
    end
  end

  describe "configuration" do
    it "should return the same configuration object each time" do
      expect(Pact.configuration).to equal(Pact.configuration)
    end
  end

  describe "consumer" do
    it "should be configured" do
      Pact.configuration.consumer.name.should eq "My Consumer"
    end
  end

  describe "producers" do
    include Pact::Consumer::ConsumerContractBuilders

    it "should have defined methods in MockServices for the producers" do
      my_service.should be_instance_of Pact::Consumer::ConsumerContractBuilder
    end

    context "when standalone is true" do
      it "is not registerd with the AppManager" do
        Pact::Consumer::AppManager.instance.app_registered_on?(1234).should be_false
      end
    end

    context "when standalone is false" do
      it "should register the MockServices on their given ports if they are not" do
        Pact::Consumer::AppManager.instance.app_registered_on?(1235).should be_true
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pact-0.1.28 spec/integration/pact/configuration_spec.rb