diff options
author | Azul <azul@leap.se> | 2014-07-17 11:55:31 +0200 |
---|---|---|
committer | Azul <azul@leap.se> | 2014-07-17 11:58:10 +0200 |
commit | e86cccb4b89540f3bd403110d051b2723be781b9 (patch) | |
tree | d16f7e3bf15c45dc8f54a735e710573b532fa8e9 /features | |
parent | d19e748ab10c0f119a84a0d7c9a1560e246b7505 (diff) |
cuke: drop jsonpath, use simple keys instead
Also fixed the test for login_required
Diffstat (limited to 'features')
-rw-r--r-- | features/config.feature | 2 | ||||
-rw-r--r-- | features/step_definitions/api_steps.rb | 24 | ||||
-rw-r--r-- | features/unauthenticated.feature | 6 |
3 files changed, 13 insertions, 19 deletions
diff --git a/features/config.feature b/features/config.feature index 066d4c4..6adaed9 100644 --- a/features/config.feature +++ b/features/config.feature @@ -29,7 +29,7 @@ Feature: Download Provider Configuration Scenario: Missing provider config When I send a GET request to "/provider.json" Then the response status should be "404" - And the response should have ".error" with the text "not_found" + And the response should have "error" with "not_found" Scenario: Fetch list of available configs When I send a GET request to "/1/configs.json" 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 diff --git a/features/unauthenticated.feature b/features/unauthenticated.feature index b810bea..120274b 100644 --- a/features/unauthenticated.feature +++ b/features/unauthenticated.feature @@ -24,8 +24,6 @@ Feature: Unauthenticated API endpoints Scenario: Authentication required for all other API endpoints When I send a GET request to "/1/configs" Then the response status should be "401" - And the response should be: - """ - {"error": "Please log in to perform that action."} - """ + And the response should have "error" with "not_authorized_login" + And the response should have "message" |