Sha256: 7e1b3aea0a4bb7055c39894db76ada6924d90589afe80741f8fb34c63fe5a5fb

Contents?: true

Size: 1.08 KB

Versions: 26

Compression:

Stored size: 1.08 KB

Contents

require 'json'
require 'pact/provider/rspec'
# pact_helper for rake pact:tests

module Pact
	module Test
		class TestApp
			def call env
				if env['PATH_INFO'] == '/weather'
					[200, {'Content-Type' => 'application/json'}, [{message: WEATHER[:current_state]}.to_json]]
				elsif env['PATH_INFO'] == '/sometext'
					[200, {'Content-Type' => 'text/plain'}, ['some text']]
				else
					raise "unexpected path #{env['PATH_INFO']}!!!"
				end
			end
		end

		Pact.configure do | config |
			config.logger.level = Logger::DEBUG
		end

		Pact.service_provider "Some Provider" do
			app { TestApp.new }

			honours_pact_with 'some-test-consumer' do
				pact_uri './spec/support/test_app_pass.json'
			end
		end


		#one with a top level consumer
		Pact.provider_states_for 'some-test-consumer' do
			provider_state "the weather is sunny" do
				set_up do
					WEATHER ||= {}
					WEATHER[:current_state] = 'sunny'
				end
			end
		end

		#one without a top level consumer
		Pact.provider_state "the weather is cloudy" do
			set_up do
				WEATHER ||= {}
				WEATHER[:current_state] = 'cloudy'
			end
		end
	end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
pact-1.1.0.rc1 spec/support/pact_helper.rb
pact-1.0.37 spec/support/pact_helper.rb
pact-1.0.36 spec/support/pact_helper.rb
pact-1.0.35 spec/support/pact_helper.rb
pact-1.0.34 spec/support/pact_helper.rb
pact-1.0.33 spec/support/pact_helper.rb
pact-1.0.32 spec/support/pact_helper.rb
pact-1.0.31 spec/support/pact_helper.rb
pact-1.0.30 spec/support/pact_helper.rb
pact-1.0.29 spec/support/pact_helper.rb
pact-1.0.28 spec/support/pact_helper.rb
pact-1.0.27 spec/support/pact_helper.rb
pact-1.0.26 spec/support/pact_helper.rb
pact-1.0.25 spec/support/pact_helper.rb
pact-1.0.24 spec/support/pact_helper.rb
pact-1.0.23 spec/support/pact_helper.rb
pact-1.0.22 spec/support/pact_helper.rb
pact-1.0.21 spec/support/pact_helper.rb
pact-1.0.20 spec/support/pact_helper.rb
pact-1.0.19 spec/support/pact_helper.rb