summaryrefslogtreecommitdiff
path: root/features/step_definitions/api_steps.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2014-07-17 11:55:31 +0200
committerAzul <azul@leap.se>2014-07-17 11:58:10 +0200
commite86cccb4b89540f3bd403110d051b2723be781b9 (patch)
treed16f7e3bf15c45dc8f54a735e710573b532fa8e9 /features/step_definitions/api_steps.rb
parentd19e748ab10c0f119a84a0d7c9a1560e246b7505 (diff)
cuke: drop jsonpath, use simple keys instead
Also fixed the test for login_required
Diffstat (limited to 'features/step_definitions/api_steps.rb')
-rw-r--r--features/step_definitions/api_steps.rb24
1 files changed, 10 insertions, 14 deletions
diff --git a/features/step_definitions/api_steps.rb b/features/step_definitions/api_steps.rb
index 3a24d68..a4f369c 100644
--- a/features/step_definitions/api_steps.rb
+++ b/features/step_definitions/api_steps.rb
@@ -1,5 +1,3 @@
-require 'jsonpath'
-
if defined?(Rack)
# Monkey patch Rack::MockResponse to work properly with response debugging
@@ -76,39 +74,37 @@ Then /^the response status should be "([^"]*)"$/ do |status|
end
end
-Then /^the response should (not)?\s?have "([^"]*)"$/ do |negative, json_path|
+Then /^the response should (not)?\s?have "([^"]*)"$/ do |negative, key|
json = JSON.parse(last_response.body)
- results = JsonPath.new(json_path).on(json).to_a.map(&:to_s)
if self.respond_to?(:should)
if negative.present?
- results.should be_empty
+ json[key].should be_blank
else
- results.should_not be_empty
+ json[key].should be_present
end
else
if negative.present?
- assert results.empty?
+ assert json[key].blank?
else
- assert !results.empty?
+ assert json[key].present?
end
end
end
-Then /^the response should (not)?\s?have "([^"]*)" with the text "([^"]*)"$/ do |negative, json_path, text|
+Then /^the response should (not)?\s?have "([^"]*)" with(?: the text)? "([^"]*)"$/ do |negative, key, text|
json = JSON.parse(last_response.body)
- results = JsonPath.new(json_path).on(json).to_a.map(&:to_s)
if self.respond_to?(:should)
if negative.present?
- results.should_not include(text)
+ json[key].should_not == text
else
- results.should include(text)
+ results.should == text
end
else
if negative.present?
- assert !results.include?(text)
+ assert ! json[key] == text
else
- assert results.include?(text)
+ assert_equal text, json[key]
end
end
end