Sha256: 57d7dc77c1dc3b0847aee35b297dd8b9235f82f563867c24c3f3310c96f1bc5a

Contents?: true

Size: 800 Bytes

Versions: 3

Compression:

Stored size: 800 Bytes

Contents

require 'json'
# 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]]
				else
					raise "unexpected path #{env['PATH_INFO']}!!!"
				end
			end
		end

		Pact.service_provider "Some Provider" do
			app { TestApp.new }
		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

3 entries across 3 versions & 1 rubygems

Version Path
pact-1.0.5 spec/support/pact_helper.rb
pact-1.0.4 spec/support/pact_helper.rb
pact-1.0.3 spec/support/pact_helper.rb