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 | |
parent | d19e748ab10c0f119a84a0d7c9a1560e246b7505 (diff) |
cuke: drop jsonpath, use simple keys instead
Also fixed the test for login_required
-rw-r--r-- | Gemfile | 1 | ||||
-rw-r--r-- | Gemfile.lock | 3 | ||||
-rw-r--r-- | features/config.feature | 2 | ||||
-rw-r--r-- | features/step_definitions/api_steps.rb | 24 | ||||
-rw-r--r-- | features/unauthenticated.feature | 6 |
5 files changed, 13 insertions, 23 deletions
@@ -58,7 +58,6 @@ group :test do # we use cucumber to document and test the api gem 'cucumber-rails', require: false - gem 'jsonpath', require: false end group :test, :development do diff --git a/Gemfile.lock b/Gemfile.lock index a286d6f..38a8793 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -144,8 +144,6 @@ GEM railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) json (1.8.1) - jsonpath (0.5.6) - multi_json kaminari (0.13.0) actionpack (>= 3.0.0) activesupport (>= 3.0.0) @@ -278,7 +276,6 @@ DEPENDENCIES i18n-missing_translations jquery-rails json - jsonpath kaminari (= 0.13.0) launchy leap_web_billing! 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" |