Sha256: 73c92475291d3927f09e694835315e83cf340f4099f08a6218744cacfa4c60bf

Contents?: true

Size: 1.49 KB

Versions: 9

Compression:

Stored size: 1.49 KB

Contents

require 'spec_helper'

module Pact::Consumer
  describe AppManager do
    before do
      AppManager.instance.clear_all
    end

    describe "start_service_for" do
      before do
        allow_any_instance_of(AppRegistration).to receive(:spawn) # Don't want process actually spawning during the tests
      end
      let(:name) { 'some_service'}
      context "for http://localhost" do
        let(:url) { 'http://localhost:1234'}
        it "starts a mock service at the given port on localhost" do
          expect_any_instance_of(AppRegistration).to receive(:spawn)
          AppManager.instance.register_mock_service_for name, url
          AppManager.instance.spawn_all
        end

        it "registers the mock service as running on the given port" do
          AppManager.instance.register_mock_service_for name, url
          expect(AppManager.instance.app_registered_on?(1234)).to eq true
        end
      end
      context "for https://" do
        let(:url) { 'https://localhost:1234'}
        it "should throw an unsupported error" do
          expect { AppManager.instance.register_mock_service_for name, url }.to raise_error "Currently only http is supported"
        end
      end
      context "for a host other than localhost" do
        let(:url) { 'http://aserver:1234'}
        it "should throw an unsupported error" do
          expect { AppManager.instance.register_mock_service_for name, url }.to raise_error "Currently only services on localhost are supported"
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pact-1.4.0.rc4 spec/lib/pact/consumer/app_manager_spec.rb
pact-1.4.0.rc3 spec/lib/pact/consumer/app_manager_spec.rb
pact-1.4.0.rc2 spec/lib/pact/consumer/app_manager_spec.rb
pact-1.3.3 spec/lib/pact/consumer/app_manager_spec.rb
pact-1.3.2 spec/lib/pact/consumer/app_manager_spec.rb
pact-1.3.1 spec/lib/pact/consumer/app_manager_spec.rb
pact-1.3.0 spec/lib/pact/consumer/app_manager_spec.rb
pact-1.2.1.rc2 spec/lib/pact/consumer/app_manager_spec.rb
pact-1.2.1.rc1 spec/lib/pact/consumer/app_manager_spec.rb