cucumber-api-steps 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cucumber/api_steps.rb +14 -4
- data/lib/cucumber/api_steps/version.rb +1 -1
- metadata +3 -3
data/lib/cucumber/api_steps.rb
CHANGED
@@ -43,13 +43,23 @@ Then /^the response status should be "([^\"]*)"$/ do |status|
|
|
43
43
|
end
|
44
44
|
|
45
45
|
Then /^the JSON response should have "([^\"]*)" with the text "([^\"]*)"$/ do |json_path, text|
|
46
|
-
json
|
47
|
-
JsonPath.new(json_path).on(json).to_a.map(&:to_s)
|
46
|
+
json = JSON.parse(page.driver.last_response.body)
|
47
|
+
results = JsonPath.new(json_path).on(json).to_a.map(&:to_s)
|
48
|
+
if page.respond_to? :should
|
49
|
+
results.should include(text)
|
50
|
+
else
|
51
|
+
assert results.include?(text)
|
52
|
+
end
|
48
53
|
end
|
49
54
|
|
50
55
|
Then /^the JSON response should not have "([^\"]*)" with the text "([^\"]*)"$/ do |json_path, text|
|
51
|
-
json
|
52
|
-
JsonPath.new(json_path).on(json).to_a.map(&:to_s)
|
56
|
+
json = JSON.parse(page.driver.last_response.body)
|
57
|
+
results = JsonPath.new(json_path).on(json).to_a.map(&:to_s)
|
58
|
+
if page.respond_to? :should
|
59
|
+
results.should_not include(text)
|
60
|
+
else
|
61
|
+
assert !results.include?(text)
|
62
|
+
end
|
53
63
|
end
|
54
64
|
|
55
65
|
Then /^the XML response should have "([^\"]*)" with the text "([^\"]*)"$/ do |xpath, text|
|
metadata
CHANGED