cucumber-api-steps 0.3 → 0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cucumber/api_steps.rb +10 -3
- data/lib/cucumber/api_steps/version.rb +1 -1
- metadata +3 -3
data/lib/cucumber/api_steps.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'jsonpath'
|
2
|
+
|
1
3
|
World(Rack::Test::Methods)
|
2
4
|
|
3
5
|
Given /^I send and accept XML$/ do
|
@@ -42,7 +44,7 @@ Then /^the response status should be "([^\"]*)"$/ do |status|
|
|
42
44
|
if page.respond_to? :should
|
43
45
|
page.driver.last_response.status.should == status.to_i
|
44
46
|
else
|
45
|
-
|
47
|
+
assert_equal status.to_i, page.driver.last_response.status
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
@@ -69,6 +71,11 @@ end
|
|
69
71
|
Then /^the XML response should have "([^\"]*)" with the text "([^\"]*)"$/ do |xpath, text|
|
70
72
|
parsed_response = Nokogiri::XML(last_response.body)
|
71
73
|
elements = parsed_response.xpath(xpath)
|
72
|
-
|
73
|
-
|
74
|
+
if page.respond_to? :should
|
75
|
+
elements.should_not be_empty, "could not find #{xpath} in:\n#{last_response.body}"
|
76
|
+
elements.find { |e| e.text == text }.should_not be_nil, "found elements but could not find #{text} in:\n#{elements.inspect}"
|
77
|
+
else
|
78
|
+
assert !elements.empty?, "could not find #{xpath} in:\n#{last_response.body}"
|
79
|
+
assert elements.find { |e| e.text == text }, "found elements but could not find #{text} in:\n#{elements.inspect}"
|
80
|
+
end
|
74
81
|
end
|
metadata
CHANGED