Sha256: baa1371a5fbb03cd0f2e6a79ece569a1dbc5dcd45f58f8290fdec3b58f21154b

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

DEFAULT_MESSAGE = "{'Answer': 'What did you expect?'}"

Given(/^I have a web service$/) do
	@protocol = 'http'
	@server = FigNewton.server
	@port = FigNewton.port
  @mockservice = MockRestService.new(@server, @port, @protocol)
end

Given(/^I have "(GET|PUT|POST|DELETE)" service for "(.*?)"$/) do |type, path|
	@path = path
	@mockservice.store_msg(type, path, DEFAULT_MESSAGE)
end

Given(/^I have "(GET|PUT|POST|DELETE)" service for "(.*?)" as follows$/) do |type, path, message|
	@path = path
	@mockservice.store_msg(type, path, message)
end

Given(/^I am a rest client$/) do
	@restbaby = Client.new("#{@protocol}://#{@server}:#{@port}#{@path}")
end

When(/^I "(GET|DELETE)" from the web service$/) do |type|
	case type.downcase
	when 'get'
		@response = @restbaby.get
	when 'delete'
		# @response = @restbaby.delete(@path)
		@response = @restbaby.delete
	end
end

When(/^I "(PUT|POST)" to the web service with the following$/) do |type, message|
	case type.downcase
	when 'put'
		@response = @restbaby.put(message)
	when 'post'
		@response = @restbaby.post(message)
	end
end

When(/^I pause$/) do
  pause()
end

Then(/^I receive the expected message$/) do
	expect(@response.code).to eq('200')
	expect(@response.body).to eq(DEFAULT_MESSAGE)
end

Then(/^I receive the following$/) do |message|
	expect(@response.code).to eq('200')
	expect(@response.body).to eq(message)
end

Then(/^the response prints like the following$/) do |response|
  expect(@restbaby.print_last_response).to eq(response)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rest_baby-0.2 features/step_definitions/rest_client_steps.rb