From e86cccb4b89540f3bd403110d051b2723be781b9 Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 17 Jul 2014 11:55:31 +0200 Subject: cuke: drop jsonpath, use simple keys instead Also fixed the test for login_required --- features/step_definitions/api_steps.rb | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'features/step_definitions') 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 -- cgit v1.2.3