summaryrefslogtreecommitdiff
path: root/features/step_definitions/common_steps.rb
blob: f5668eedeefe0077aa6ee995f250a6926bcdf0f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Given /^Content-Type is (.*)/ do |content_type|
	@content_type = content_type
end

When /^I post (.*) to the (.*) webservice$/ do |data,component|
	#puts @@config[:services].to_yaml
	#puts @@config[:services]["opentox-#{component}"]
	case data
	when /^file:/
		data = File.read(File.join(File.dirname(File.expand_path(__FILE__)),"../data",data.sub(/file:\s+/,'')))
		@data = data
	end
	@uri = RestClient.post @@config[:services]["opentox-#{component}"], data, :content_type => @content_type
	@resources << @uri unless /compound|feature/ =~ component
end

Then /^I should receive a valid URI$/ do
	#puts @uri
	@response = RestClient.get @uri, :accept => '*/*'
	#puts @response.to_yaml
end

Then /^the URI should contain (.+)$/ do |result|
	#puts @uri
	regexp = /#{Regexp.escape(URI.encode(result))}/
	assert regexp =~ @uri, true
end

Then /^the URI response should be (.+)$/ do |data|
	case data
	when /^file:/
		data = @data
	end
	assert data == @response, true
end