Sha256: 389914921d8b19fc790ded3baa88c96365176d28d0623c746b6a4eebb2da21bc

Contents?: true

Size: 1.87 KB

Versions: 1

Compression:

Stored size: 1.87 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|
	if type=="GET"
		create_get(type, path)
	else
		@path = path
		@mockservice.store_msg(type, path, DEFAULT_MESSAGE)
	end
end

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

def create_get(type, path, message = DEFAULT_MESSAGE)
	@path = path.split('?')[0]
	if path.split('?').length==1
		@mockservice.store_msg("GET", @path, message)
	else
		@mockservice.store_get_query(path)
	end
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
	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 "GET" from the web service with the parameters$/) do |table|
	@response = @restbaby.get({}, nil, table.rows_hash)
end

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

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

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

Then(/^I receive a message with "(.*?)"$/) do |message|
	@response.code.should eq('200')
	@response.body.should eq(message)
end

Version data entries

1 entries across 1 versions & 1 rubygems

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