From 3c371fa93dfded9e21e92402d2626be929caa733 Mon Sep 17 00:00:00 2001 From: ganszkyb Date: Thu, 17 Nov 2022 11:38:05 +0100 Subject: [PATCH 01/11] add head and options methods --- README.markdown | 2 +- lib/rest-assured/application.rb | 2 +- lib/rest-assured/models/double.rb | 2 +- spec/functional/response_spec.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.markdown b/README.markdown index 4b918d4..17271db 100644 --- a/README.markdown +++ b/README.markdown @@ -77,7 +77,7 @@ You can also [![Deploy](https://www.herokucdn.com/deploy/button.png)](https://he ## Usage -REST-assured can do two things: respond to a particular path and method (e.g. GET /stuff/v2?thing=1) and redirect requests based on a pattern (e.g. all /foo\* will redirect to http://example.com/bar). Both of these are available to create/read/delete in runtime via api. +REST-assured can do two things: respond to a particular path and method (e.g. GET /stuff/v2?thing=1) and redirect requests based on a pattern (e.g. all /foo\* will redirect to http://example.com/bar). Both of these are available to create/read/delete/head/options in runtime via api. ### Ruby API diff --git a/lib/rest-assured/application.rb b/lib/rest-assured/application.rb index 9dccd46..96a18e5 100644 --- a/lib/rest-assured/application.rb +++ b/lib/rest-assured/application.rb @@ -35,7 +35,7 @@ def browser? include DoubleRoutes include RedirectRoutes - %w{get post put delete patch}.each do |verb| + %w{get post put delete patch options head}.each do |verb| send verb, /.*/ do Response.perform(self) end diff --git a/lib/rest-assured/models/double.rb b/lib/rest-assured/models/double.rb index 79274df..50e406f 100644 --- a/lib/rest-assured/models/double.rb +++ b/lib/rest-assured/models/double.rb @@ -6,7 +6,7 @@ module Models class Double < ActiveRecord::Base serialize :response_headers, Hash - VERBS = %w{GET POST PUT DELETE HEAD PATCH} + VERBS = %w{GET POST PUT DELETE HEAD PATCH HEAD OPTIONS} STATUSES = Net::HTTPResponse::CODE_TO_OBJ.keys.map(&:to_i) MAX_DELAY = 30 diff --git a/spec/functional/response_spec.rb b/spec/functional/response_spec.rb index 58745f0..631e2d5 100644 --- a/spec/functional/response_spec.rb +++ b/spec/functional/response_spec.rb @@ -3,7 +3,7 @@ module RestAssured describe Response do - [:get, :post, :put, :delete, :patch].each do |verb| + [:get, :post, :put, :delete, :patch, :options, :head].each do |verb| it "processes a #{verb.to_s.upcase} request" do expect(Response).to receive(:perform).with(an_instance_of(RestAssured::Application)) From 523c09df9cf0dbba0f98bd578aa3a713dccc6e8c Mon Sep 17 00:00:00 2001 From: ganszkyb Date: Thu, 17 Nov 2022 12:31:17 +0100 Subject: [PATCH 02/11] remove duplication --- lib/rest-assured/models/double.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest-assured/models/double.rb b/lib/rest-assured/models/double.rb index 50e406f..cb44d6b 100644 --- a/lib/rest-assured/models/double.rb +++ b/lib/rest-assured/models/double.rb @@ -6,7 +6,7 @@ module Models class Double < ActiveRecord::Base serialize :response_headers, Hash - VERBS = %w{GET POST PUT DELETE HEAD PATCH HEAD OPTIONS} + VERBS = %w{GET POST PUT DELETE HEAD PATCH OPTIONS} STATUSES = Net::HTTPResponse::CODE_TO_OBJ.keys.map(&:to_i) MAX_DELAY = 30 From b0ea7ed58a15adda09448fb198a506d09a8a7fb0 Mon Sep 17 00:00:00 2001 From: balasubuicentric Date: Mon, 21 Nov 2022 13:57:47 +0000 Subject: [PATCH 03/11] MSPA-2678: add support for OPTIONS method to REST-assured ruby library --- features/rest_api/doubles.feature | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/features/rest_api/doubles.feature b/features/rest_api/doubles.feature index 33aa3a4..557b05e 100644 --- a/features/rest_api/doubles.feature +++ b/features/rest_api/doubles.feature @@ -97,6 +97,11 @@ Feature: use doubles via api When I "GET" "/api/something" Then I should get 404 in response status + Scenario: request full path that matches more than one path pattern + Given there is double with "^.*$" as pathpattern and "test content" as response content + When I "OPTIONS" "/api/sam" + Then I should get 204 in response status + Scenario: clear doubles Given there are some doubles When I delete all doubles From 5eb2e71a666f474a6aa8c967db0bed90b5983905 Mon Sep 17 00:00:00 2001 From: Andrew Wheat Date: Wed, 23 Nov 2022 16:23:49 +0000 Subject: [PATCH 04/11] Bundle update for 'modern' dependencies --- Gemfile.lock | 268 ++++++++++++++++++++++++++++----------------------- 1 file changed, 148 insertions(+), 120 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 809da3e..05a96cc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -13,184 +13,212 @@ PATH GEM remote: https://rubygems.org/ specs: - activemodel (5.2.0) - activesupport (= 5.2.0) + activemodel (5.2.8.1) + activesupport (= 5.2.8.1) activemodel-serializers-xml (1.0.2) activemodel (> 5.x) activesupport (> 5.x) builder (~> 3.1) - activerecord (5.2.0) - activemodel (= 5.2.0) - activesupport (= 5.2.0) + activerecord (5.2.8.1) + activemodel (= 5.2.8.1) + activesupport (= 5.2.8.1) arel (>= 9.0) - activeresource (5.0.0) - activemodel (>= 5.0, < 6) + activeresource (5.1.1) + activemodel (>= 5.0, < 7) activemodel-serializers-xml (~> 1.0) - activesupport (>= 5.0, < 6) - activesupport (5.2.0) + activesupport (>= 5.0, < 7) + activesupport (5.2.8.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - addressable (2.5.2) - public_suffix (>= 2.0.2, < 4.0) + addressable (2.8.1) + public_suffix (>= 2.0.2, < 6.0) anticipate (0.1.1) - archive-tar-minitar (0.6.1) - minitar (~> 0.6) - minitar-cli (~> 0.6) - archive-zip (0.11.0) + archive-tar-minitar (0.8) + minitar (~> 0.8) + minitar-cli (~> 0.8) + archive-zip (0.12.0) io-like (~> 0.3.0) arel (9.0.0) - awesome_print (1.8.0) - backports (3.11.3) - builder (3.2.3) - byebug (10.0.2) - capybara (3.0.3) + awesome_print (1.9.2) + builder (3.2.4) + byebug (11.1.3) + capybara (3.38.0) addressable + matrix mini_mime (>= 0.1.3) nokogiri (~> 1.8) rack (>= 1.6.0) rack-test (>= 0.6.3) - xpath (~> 3.0) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) childprocess (0.9.0) ffi (~> 1.0, >= 1.0.11) - chromedriver-helper (1.2.0) + chromedriver-helper (2.1.1) archive-zip (~> 0.10) nokogiri (~> 1.8) cliver (0.3.2) - coderay (1.1.2) - concurrent-ruby (1.0.5) - cucumber (3.1.0) - builder (>= 2.1.2) - cucumber-core (~> 3.1.0) - cucumber-expressions (~> 5.0.4) - cucumber-wire (~> 0.0.1) - diff-lcs (~> 1.3) - gherkin (~> 5.0) - multi_json (>= 1.7.5, < 2.0) - multi_test (>= 0.1.2) - cucumber-core (3.1.0) - backports (>= 3.8.0) - cucumber-tag_expressions (~> 1.1.0) - gherkin (>= 5.0.0) - cucumber-expressions (5.0.17) - cucumber-tag_expressions (1.1.1) - cucumber-wire (0.0.1) - daemons (1.2.6) - database_cleaner (1.7.0) - diff-lcs (1.3) - docile (1.3.0) - domain_name (0.5.20180417) + coderay (1.1.3) + concurrent-ruby (1.1.10) + cucumber (8.0.0) + builder (~> 3.2, >= 3.2.4) + cucumber-ci-environment (~> 9.0, >= 9.0.4) + cucumber-core (~> 11.0, >= 11.0.0) + cucumber-cucumber-expressions (~> 15.1, >= 15.1.1) + cucumber-gherkin (~> 23.0, >= 23.0.1) + cucumber-html-formatter (~> 19.1, >= 19.1.0) + cucumber-messages (~> 18.0, >= 18.0.0) + diff-lcs (~> 1.5, >= 1.5.0) + mime-types (~> 3.4, >= 3.4.1) + multi_test (~> 1.1, >= 1.1.0) + sys-uname (~> 1.2, >= 1.2.2) + cucumber-ci-environment (9.1.0) + cucumber-core (11.0.0) + cucumber-gherkin (~> 23.0, >= 23.0.1) + cucumber-messages (~> 18.0, >= 18.0.0) + cucumber-tag-expressions (~> 4.1, >= 4.1.0) + cucumber-cucumber-expressions (15.2.0) + cucumber-gherkin (23.0.1) + cucumber-messages (~> 18.0, >= 18.0.0) + cucumber-html-formatter (19.2.0) + cucumber-messages (~> 18.0, >= 18.0.0) + cucumber-messages (18.0.0) + cucumber-tag-expressions (4.1.0) + daemons (1.4.1) + database_cleaner (2.0.1) + database_cleaner-active_record (~> 2.0.0) + database_cleaner-active_record (2.0.1) + activerecord (>= 5.a) + database_cleaner-core (~> 2.0.0) + database_cleaner-core (2.0.1) + diff-lcs (1.5.0) + docile (1.4.0) + domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) - eventmachine (1.2.6) - ffi (1.9.23) - gherkin (5.0.0) - haml (5.0.4) + eventmachine (1.2.7) + ffi (1.15.5) + haml (5.2.2) temple (>= 0.8.0) tilt - hashie (3.5.7) - http-cookie (1.0.3) + hashie (5.0.0) + http-accept (1.7.0) + http-cookie (1.0.5) domain_name (~> 0.5) - i18n (1.0.1) + i18n (1.12.0) concurrent-ruby (~> 1.0) - io-like (0.3.0) - json (2.1.0) - launchy (2.4.3) - addressable (~> 2.3) - method_source (0.9.0) - mime-types (3.1) + io-like (0.3.1) + json (2.6.2) + launchy (2.5.0) + addressable (~> 2.7) + matrix (0.4.2) + method_source (1.0.0) + mime-types (3.4.1) mime-types-data (~> 3.2015) - mime-types-data (3.2016.0521) - mini_mime (1.0.0) - mini_portile2 (2.3.0) - minitar (0.6.1) - minitar-cli (0.6.1) - minitar (~> 0.6.0) + mime-types-data (3.2022.0105) + mini_mime (1.1.2) + mini_portile2 (2.8.0) + minitar (0.8) + minitar-cli (0.8) + minitar (~> 0.8.0) powerbar (~> 1.0) - minitest (5.11.3) - multi_json (1.13.1) - multi_test (0.1.2) - mustermann (1.0.2) + minitest (5.16.3) + multi_test (1.1.0) + mustermann (2.0.2) + ruby2_keywords (~> 0.0.1) netrc (0.11.0) - nio4r (2.3.1) - nokogiri (1.8.2) - mini_portile2 (~> 2.3.0) - pg (1.0.0) - poltergeist (1.18.0) + nio4r (2.5.8) + nokogiri (1.13.9) + mini_portile2 (~> 2.8.0) + racc (~> 1.4) + pg (1.4.5) + poltergeist (1.18.1) capybara (>= 2.1, < 4) cliver (~> 0.3.1) websocket-driver (>= 0.2.0) powerbar (1.0.18) hashie (>= 1.1.0) - pry (0.11.3) - coderay (~> 1.1.0) - method_source (~> 0.9.0) - pry-byebug (3.6.0) - byebug (~> 10.0) - pry (~> 0.10) - public_suffix (3.0.2) - puma (4.3.1) + pry (0.14.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-byebug (3.10.1) + byebug (~> 11.0) + pry (>= 0.13, < 0.15) + public_suffix (5.0.0) + puma (6.0.0) nio4r (~> 2.0) - rack (2.0.5) - rack-protection (2.0.1) + racc (1.6.0) + rack (2.2.4) + rack-protection (2.2.2) rack - rack-test (1.0.0) - rack (>= 1.0, < 3) - rake (12.3.1) + rack-test (2.0.2) + rack (>= 1.3) + rake (13.0.6) + regexp_parser (2.6.1) relish (0.7.1) archive-tar-minitar (>= 0.5.2) json (>= 1.4.6) rest-client (>= 1.7.2) - rest-client (2.0.2) + rest-client (2.1.0) + http-accept (>= 1.7.0, < 2.0) http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - rspec (3.7.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-core (3.7.1) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) + rexml (3.2.5) + rspec (3.12.0) + rspec-core (~> 3.12.0) + rspec-expectations (~> 3.12.0) + rspec-mocks (~> 3.12.0) + rspec-core (3.12.0) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-mocks (3.7.0) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.1) - rubyzip (1.2.1) - selenium-webdriver (3.11.0) - childprocess (~> 0.5) - rubyzip (~> 1.2) - simplecov (0.16.1) + rspec-support (~> 3.12.0) + rspec-support (3.12.0) + ruby2_keywords (0.0.5) + rubyzip (2.3.2) + selenium-webdriver (4.6.1) + childprocess (>= 0.5, < 5.0) + rexml (~> 3.2, >= 3.2.5) + rubyzip (>= 1.2.2, < 3.0) + websocket (~> 1.0) + simplecov (0.21.2) docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) - sinatra (2.0.1) - mustermann (~> 1.0) - rack (~> 2.0) - rack-protection (= 2.0.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.12.3) + simplecov_json_formatter (0.1.4) + sinatra (2.2.2) + mustermann (~> 2.0) + rack (~> 2.2) + rack-protection (= 2.2.2) tilt (~> 2.0) sinatra-flash (0.3.0) sinatra (>= 1.0.0) - sqlite3 (1.3.13) - temple (0.8.0) - thin (1.7.2) + sqlite3 (1.5.4) + mini_portile2 (~> 2.8.0) + sys-uname (1.2.2) + ffi (~> 1.1) + temple (0.9.1) + thin (1.8.1) daemons (~> 1.0, >= 1.0.9) eventmachine (~> 1.0, >= 1.0.4) rack (>= 1, < 3) thread_safe (0.3.6) - tilt (2.0.8) - tzinfo (1.2.5) + tilt (2.0.11) + tzinfo (1.2.10) thread_safe (~> 0.1) unf (0.1.4) unf_ext - unf_ext (0.0.7.5) - websocket-driver (0.7.0) + unf_ext (0.0.8.2) + websocket (1.2.9) + websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.3) - xpath (3.0.0) + websocket-extensions (0.1.5) + xpath (3.2.0) nokogiri (~> 1.8) PLATFORMS @@ -219,4 +247,4 @@ DEPENDENCIES sqlite3 BUNDLED WITH - 1.15.1 + 1.16.0.pre.2 From 6eeb165b54ea8572f3fa65ee9c14f30762843795 Mon Sep 17 00:00:00 2001 From: Andrew Wheat Date: Wed, 23 Nov 2022 16:25:54 +0000 Subject: [PATCH 05/11] Change to a sqlite3 database; allow 1 second for queries to timeout. --- lib/rest-assured/config.rb | 3 ++- spec/spec_helper.rb | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/rest-assured/config.rb b/lib/rest-assured/config.rb index 0756e84..df14f99 100644 --- a/lib/rest-assured/config.rb +++ b/lib/rest-assured/config.rb @@ -126,7 +126,8 @@ def self.build_db_config adapter = RUBY_PLATFORM == "java" ? 'jdbcsqlite3' : 'sqlite3' { :adapter => adapter, - :database => AppConfig.database || default_database + :database => AppConfig.database || default_database, + :timeout => 1000 } elsif AppConfig.adapter =~ /postgres|mysql/i adapter = $&.downcase diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6049f53..dacb46b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -21,10 +21,7 @@ require 'rest-assured/config' DB_OPTS = { - adapter: 'postgres', - dbhost: ENV.fetch('DB_HOST', 'localhost'), - dbport: ENV.fetch('DB_PORT', 5432), - dbuser: ENV.fetch('DB_USER', 'postgres') + adapter: 'sqlite3', } RestAssured::Config.build(DB_OPTS) From 16f8acd887e2d119a26e8c629794e8b6b2157e2c Mon Sep 17 00:00:00 2001 From: balasubuicentric Date: Mon, 28 Nov 2022 10:22:29 +0000 Subject: [PATCH 06/11] MSPA-2678: fix component tests --- Gemfile | 1 + Gemfile.lock | 250 --------------------- cucumber.yml | 2 +- features/step_definitions/doubles_steps.rb | 2 +- features/support/env.rb | 5 +- spec/functional/double_routes_spec.rb | 2 +- 6 files changed, 5 insertions(+), 257 deletions(-) delete mode 100644 Gemfile.lock diff --git a/Gemfile b/Gemfile index ca1cc8b..a24b43b 100644 --- a/Gemfile +++ b/Gemfile @@ -21,6 +21,7 @@ group :test do gem 'simplecov' gem 'awesome_print' gem 'puma' + gem 'phantomjs', :require => 'phantomjs/poltergeist' end # skipped for heroku and travis diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 05a96cc..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,250 +0,0 @@ -PATH - remote: . - specs: - rest-assured (4.0.0) - activerecord (~> 5.0, >= 4.0) - activeresource (~> 5.0, >= 4.0) - childprocess (~> 0.3) - haml (~> 5.0, >= 4.0) - sinatra (~> 2.0, >= 1.4.0) - sinatra-flash - thin (~> 1.6) - -GEM - remote: https://rubygems.org/ - specs: - activemodel (5.2.8.1) - activesupport (= 5.2.8.1) - activemodel-serializers-xml (1.0.2) - activemodel (> 5.x) - activesupport (> 5.x) - builder (~> 3.1) - activerecord (5.2.8.1) - activemodel (= 5.2.8.1) - activesupport (= 5.2.8.1) - arel (>= 9.0) - activeresource (5.1.1) - activemodel (>= 5.0, < 7) - activemodel-serializers-xml (~> 1.0) - activesupport (>= 5.0, < 7) - activesupport (5.2.8.1) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - addressable (2.8.1) - public_suffix (>= 2.0.2, < 6.0) - anticipate (0.1.1) - archive-tar-minitar (0.8) - minitar (~> 0.8) - minitar-cli (~> 0.8) - archive-zip (0.12.0) - io-like (~> 0.3.0) - arel (9.0.0) - awesome_print (1.9.2) - builder (3.2.4) - byebug (11.1.3) - capybara (3.38.0) - addressable - matrix - mini_mime (>= 0.1.3) - nokogiri (~> 1.8) - rack (>= 1.6.0) - rack-test (>= 0.6.3) - regexp_parser (>= 1.5, < 3.0) - xpath (~> 3.2) - childprocess (0.9.0) - ffi (~> 1.0, >= 1.0.11) - chromedriver-helper (2.1.1) - archive-zip (~> 0.10) - nokogiri (~> 1.8) - cliver (0.3.2) - coderay (1.1.3) - concurrent-ruby (1.1.10) - cucumber (8.0.0) - builder (~> 3.2, >= 3.2.4) - cucumber-ci-environment (~> 9.0, >= 9.0.4) - cucumber-core (~> 11.0, >= 11.0.0) - cucumber-cucumber-expressions (~> 15.1, >= 15.1.1) - cucumber-gherkin (~> 23.0, >= 23.0.1) - cucumber-html-formatter (~> 19.1, >= 19.1.0) - cucumber-messages (~> 18.0, >= 18.0.0) - diff-lcs (~> 1.5, >= 1.5.0) - mime-types (~> 3.4, >= 3.4.1) - multi_test (~> 1.1, >= 1.1.0) - sys-uname (~> 1.2, >= 1.2.2) - cucumber-ci-environment (9.1.0) - cucumber-core (11.0.0) - cucumber-gherkin (~> 23.0, >= 23.0.1) - cucumber-messages (~> 18.0, >= 18.0.0) - cucumber-tag-expressions (~> 4.1, >= 4.1.0) - cucumber-cucumber-expressions (15.2.0) - cucumber-gherkin (23.0.1) - cucumber-messages (~> 18.0, >= 18.0.0) - cucumber-html-formatter (19.2.0) - cucumber-messages (~> 18.0, >= 18.0.0) - cucumber-messages (18.0.0) - cucumber-tag-expressions (4.1.0) - daemons (1.4.1) - database_cleaner (2.0.1) - database_cleaner-active_record (~> 2.0.0) - database_cleaner-active_record (2.0.1) - activerecord (>= 5.a) - database_cleaner-core (~> 2.0.0) - database_cleaner-core (2.0.1) - diff-lcs (1.5.0) - docile (1.4.0) - domain_name (0.5.20190701) - unf (>= 0.0.5, < 1.0.0) - eventmachine (1.2.7) - ffi (1.15.5) - haml (5.2.2) - temple (>= 0.8.0) - tilt - hashie (5.0.0) - http-accept (1.7.0) - http-cookie (1.0.5) - domain_name (~> 0.5) - i18n (1.12.0) - concurrent-ruby (~> 1.0) - io-like (0.3.1) - json (2.6.2) - launchy (2.5.0) - addressable (~> 2.7) - matrix (0.4.2) - method_source (1.0.0) - mime-types (3.4.1) - mime-types-data (~> 3.2015) - mime-types-data (3.2022.0105) - mini_mime (1.1.2) - mini_portile2 (2.8.0) - minitar (0.8) - minitar-cli (0.8) - minitar (~> 0.8.0) - powerbar (~> 1.0) - minitest (5.16.3) - multi_test (1.1.0) - mustermann (2.0.2) - ruby2_keywords (~> 0.0.1) - netrc (0.11.0) - nio4r (2.5.8) - nokogiri (1.13.9) - mini_portile2 (~> 2.8.0) - racc (~> 1.4) - pg (1.4.5) - poltergeist (1.18.1) - capybara (>= 2.1, < 4) - cliver (~> 0.3.1) - websocket-driver (>= 0.2.0) - powerbar (1.0.18) - hashie (>= 1.1.0) - pry (0.14.1) - coderay (~> 1.1) - method_source (~> 1.0) - pry-byebug (3.10.1) - byebug (~> 11.0) - pry (>= 0.13, < 0.15) - public_suffix (5.0.0) - puma (6.0.0) - nio4r (~> 2.0) - racc (1.6.0) - rack (2.2.4) - rack-protection (2.2.2) - rack - rack-test (2.0.2) - rack (>= 1.3) - rake (13.0.6) - regexp_parser (2.6.1) - relish (0.7.1) - archive-tar-minitar (>= 0.5.2) - json (>= 1.4.6) - rest-client (>= 1.7.2) - rest-client (2.1.0) - http-accept (>= 1.7.0, < 2.0) - http-cookie (>= 1.0.2, < 2.0) - mime-types (>= 1.16, < 4.0) - netrc (~> 0.8) - rexml (3.2.5) - rspec (3.12.0) - rspec-core (~> 3.12.0) - rspec-expectations (~> 3.12.0) - rspec-mocks (~> 3.12.0) - rspec-core (3.12.0) - rspec-support (~> 3.12.0) - rspec-expectations (3.12.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-mocks (3.12.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-support (3.12.0) - ruby2_keywords (0.0.5) - rubyzip (2.3.2) - selenium-webdriver (4.6.1) - childprocess (>= 0.5, < 5.0) - rexml (~> 3.2, >= 3.2.5) - rubyzip (>= 1.2.2, < 3.0) - websocket (~> 1.0) - simplecov (0.21.2) - docile (~> 1.1) - simplecov-html (~> 0.11) - simplecov_json_formatter (~> 0.1) - simplecov-html (0.12.3) - simplecov_json_formatter (0.1.4) - sinatra (2.2.2) - mustermann (~> 2.0) - rack (~> 2.2) - rack-protection (= 2.2.2) - tilt (~> 2.0) - sinatra-flash (0.3.0) - sinatra (>= 1.0.0) - sqlite3 (1.5.4) - mini_portile2 (~> 2.8.0) - sys-uname (1.2.2) - ffi (~> 1.1) - temple (0.9.1) - thin (1.8.1) - daemons (~> 1.0, >= 1.0.9) - eventmachine (~> 1.0, >= 1.0.4) - rack (>= 1, < 3) - thread_safe (0.3.6) - tilt (2.0.11) - tzinfo (1.2.10) - thread_safe (~> 0.1) - unf (0.1.4) - unf_ext - unf_ext (0.0.8.2) - websocket (1.2.9) - websocket-driver (0.7.5) - websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.5) - xpath (3.2.0) - nokogiri (~> 1.8) - -PLATFORMS - ruby - -DEPENDENCIES - anticipate - awesome_print - capybara - chromedriver-helper - cucumber - database_cleaner - launchy - pg - poltergeist - pry - pry-byebug - puma - rack-test - rake - relish - rest-assured! - rspec - selenium-webdriver - simplecov - sqlite3 - -BUNDLED WITH - 1.16.0.pre.2 diff --git a/cucumber.yml b/cucumber.yml index 0072875..08c7cb8 100644 --- a/cucumber.yml +++ b/cucumber.yml @@ -1,3 +1,3 @@ -default: --tags ~@long +default: --tags 'not @long' long: --tags @long wip: --tags @wip diff --git a/features/step_definitions/doubles_steps.rb b/features/step_definitions/doubles_steps.rb index de1ac06..750d01e 100644 --- a/features/step_definitions/doubles_steps.rb +++ b/features/step_definitions/doubles_steps.rb @@ -21,7 +21,7 @@ Then /^I should be able to get json representation of that double from response$/ do d = RestAssured::Models::Double.last - JSON.load( @create_a_double_response ).should == MultiJson.load( d.to_json ) + JSON.load( @create_a_double_response ).should == JSON.load( d.to_json ) end Then /^I should get {int} in response status$/ do |status| diff --git a/features/support/env.rb b/features/support/env.rb index f2a7a2a..5b3c61c 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -36,10 +36,7 @@ def browser.env=(env) require 'rest-assured/config' db_opts = { - adapter: 'postgres', - dbhost: ENV.fetch('DB_HOST', 'localhost'), - dbport: ENV.fetch('DB_PORT', 5432), - dbuser: ENV.fetch('DB_USER', 'postgres') + adapter: 'sqlite3' } RestAssured::Config.build(db_opts) diff --git a/spec/functional/double_routes_spec.rb b/spec/functional/double_routes_spec.rb index 05dc44d..20c9edf 100644 --- a/spec/functional/double_routes_spec.rb +++ b/spec/functional/double_routes_spec.rb @@ -79,7 +79,7 @@ module RestAssured it "reports failure when creating with invalid parameters" do post '/doubles', invalid_params - + puts last_response.inspect expect(last_response).to be_ok expect(last_response.body).to match(/Crumps!.*Exactly one of fullpath or pathpattern must be present/) end From ecbb0c9cc0d2dbeb73f5868c7a3fe9b1b6454149 Mon Sep 17 00:00:00 2001 From: shanekelly-bbc Date: Wed, 30 Nov 2022 14:51:51 +0000 Subject: [PATCH 07/11] MSPA-2678 trying to get the bundle and spec scripts working --- Gemfile | 2 -- features/support/env.rb | 7 +++++++ spec/functional/double_routes_spec.rb | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index a24b43b..dba6276 100644 --- a/Gemfile +++ b/Gemfile @@ -2,8 +2,6 @@ source "https://rubygems.org" gemspec -gem 'pg' - # skipped for heroku group :test do gem 'cucumber' diff --git a/features/support/env.rb b/features/support/env.rb index 5b3c61c..0122874 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -10,6 +10,7 @@ require 'anticipate' require 'awesome_print' require 'rest-assured/utils/port_explorer' +require 'phantomjs' require File.dirname(__FILE__) + '/world_helpers' ENV['RACK_ENV'] = 'test' @@ -27,8 +28,14 @@ def browser.env=(env) end end +Capybara.register_driver :poltergeist do |app| + Capybara::Poltergeist::Driver.new(app, :phantomjs => Phantomjs.path) +end + Capybara.register_driver :selenium do |app| Capybara::Selenium::Driver.new(app, :browser => :chrome) + + # Capybara::Poltergeist::Driver.new(app, :phantomjs => Phantomjs.path) end Capybara.javascript_driver = ENV['FF'] ? :selenium : :poltergeist diff --git a/spec/functional/double_routes_spec.rb b/spec/functional/double_routes_spec.rb index 20c9edf..232bcf6 100644 --- a/spec/functional/double_routes_spec.rb +++ b/spec/functional/double_routes_spec.rb @@ -68,6 +68,8 @@ module RestAssured it "creates double" do post '/doubles', valid_params + puts last_response.inspect + follow_redirect! expect(last_request.fullpath).to eq('/doubles') From bfc3b44743f8957686d150c27fa4ee9fee1c21b8 Mon Sep 17 00:00:00 2001 From: shanekelly-bbc Date: Fri, 2 Dec 2022 11:07:57 +0000 Subject: [PATCH 08/11] MSPA-2678 adding 'use unsafe load' call to activerecord singlton so that psych can load Sinatra classes --- lib/rest-assured/models/double.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/rest-assured/models/double.rb b/lib/rest-assured/models/double.rb index cb44d6b..d63762e 100644 --- a/lib/rest-assured/models/double.rb +++ b/lib/rest-assured/models/double.rb @@ -9,6 +9,8 @@ class Double < ActiveRecord::Base VERBS = %w{GET POST PUT DELETE HEAD PATCH OPTIONS} STATUSES = Net::HTTPResponse::CODE_TO_OBJ.keys.map(&:to_i) MAX_DELAY = 30 + # needed for spec test TODO: possibly move out to test specific env/world class + ActiveRecord::Base.use_yaml_unsafe_load=true validate :fullpath_or_pattern validate :pattern_is_regex From 98ccbd719441a88cc2841f74e6dda95917262852 Mon Sep 17 00:00:00 2001 From: shanekelly-bbc Date: Fri, 2 Dec 2022 15:42:57 +0000 Subject: [PATCH 09/11] MSPA-2678 getting component tests to work and also tidy up of previous work --- features/rest_api/doubles.feature | 2 +- lib/rest-assured/application.rb | 1 + lib/rest-assured/models/double.rb | 2 -- spec/functional/double_routes_spec.rb | 2 -- 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/features/rest_api/doubles.feature b/features/rest_api/doubles.feature index 557b05e..2bc37b6 100644 --- a/features/rest_api/doubles.feature +++ b/features/rest_api/doubles.feature @@ -98,7 +98,7 @@ Feature: use doubles via api Then I should get 404 in response status Scenario: request full path that matches more than one path pattern - Given there is double with "^.*$" as pathpattern and "test content" as response content + Given there is double with "^.*$" as pathpattern, "test content" as response content, "OPTIONS" as request verb and "204" as status When I "OPTIONS" "/api/sam" Then I should get 204 in response status diff --git a/lib/rest-assured/application.rb b/lib/rest-assured/application.rb index 96a18e5..12cecd6 100644 --- a/lib/rest-assured/application.rb +++ b/lib/rest-assured/application.rb @@ -12,6 +12,7 @@ module RestAssured class Application < Sinatra::Base + ActiveRecord::Base.use_yaml_unsafe_load=true include Config diff --git a/lib/rest-assured/models/double.rb b/lib/rest-assured/models/double.rb index d63762e..cb44d6b 100644 --- a/lib/rest-assured/models/double.rb +++ b/lib/rest-assured/models/double.rb @@ -9,8 +9,6 @@ class Double < ActiveRecord::Base VERBS = %w{GET POST PUT DELETE HEAD PATCH OPTIONS} STATUSES = Net::HTTPResponse::CODE_TO_OBJ.keys.map(&:to_i) MAX_DELAY = 30 - # needed for spec test TODO: possibly move out to test specific env/world class - ActiveRecord::Base.use_yaml_unsafe_load=true validate :fullpath_or_pattern validate :pattern_is_regex diff --git a/spec/functional/double_routes_spec.rb b/spec/functional/double_routes_spec.rb index 232bcf6..450b461 100644 --- a/spec/functional/double_routes_spec.rb +++ b/spec/functional/double_routes_spec.rb @@ -68,7 +68,6 @@ module RestAssured it "creates double" do post '/doubles', valid_params - puts last_response.inspect follow_redirect! @@ -81,7 +80,6 @@ module RestAssured it "reports failure when creating with invalid parameters" do post '/doubles', invalid_params - puts last_response.inspect expect(last_response).to be_ok expect(last_response.body).to match(/Crumps!.*Exactly one of fullpath or pathpattern must be present/) end From 430ba1141883ef8b5599bc2743dee7c5988dc121 Mon Sep 17 00:00:00 2001 From: shanekelly-bbc Date: Mon, 5 Dec 2022 11:00:35 +0000 Subject: [PATCH 10/11] MSPA-2678 adding gemfile --- Gemfile.lock | 247 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 247 insertions(+) create mode 100644 Gemfile.lock diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..a6a7c5e --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,247 @@ +PATH + remote: . + specs: + rest-assured (4.0.0) + activerecord (~> 5.0, >= 4.0) + activeresource (~> 5.0, >= 4.0) + childprocess (~> 0.3) + haml (~> 5.0, >= 4.0) + sinatra (~> 2.0, >= 1.4.0) + sinatra-flash + thin (~> 1.6) + +GEM + remote: https://rubygems.org/ + specs: + activemodel (5.2.8.1) + activesupport (= 5.2.8.1) + activemodel-serializers-xml (1.0.2) + activemodel (> 5.x) + activesupport (> 5.x) + builder (~> 3.1) + activerecord (5.2.8.1) + activemodel (= 5.2.8.1) + activesupport (= 5.2.8.1) + arel (>= 9.0) + activeresource (5.1.1) + activemodel (>= 5.0, < 7) + activemodel-serializers-xml (~> 1.0) + activesupport (>= 5.0, < 7) + activesupport (5.2.8.1) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + addressable (2.8.1) + public_suffix (>= 2.0.2, < 6.0) + anticipate (0.1.1) + archive-tar-minitar (0.8) + minitar (~> 0.8) + minitar-cli (~> 0.8) + archive-zip (0.12.0) + io-like (~> 0.3.0) + arel (9.0.0) + awesome_print (1.9.2) + builder (3.2.4) + byebug (11.1.3) + capybara (3.38.0) + addressable + matrix + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) + childprocess (0.9.0) + ffi (~> 1.0, >= 1.0.11) + chromedriver-helper (2.1.1) + archive-zip (~> 0.10) + nokogiri (~> 1.8) + cliver (0.3.2) + coderay (1.1.3) + concurrent-ruby (1.1.10) + cucumber (8.0.0) + builder (~> 3.2, >= 3.2.4) + cucumber-ci-environment (~> 9.0, >= 9.0.4) + cucumber-core (~> 11.0, >= 11.0.0) + cucumber-cucumber-expressions (~> 15.1, >= 15.1.1) + cucumber-gherkin (~> 23.0, >= 23.0.1) + cucumber-html-formatter (~> 19.1, >= 19.1.0) + cucumber-messages (~> 18.0, >= 18.0.0) + diff-lcs (~> 1.5, >= 1.5.0) + mime-types (~> 3.4, >= 3.4.1) + multi_test (~> 1.1, >= 1.1.0) + sys-uname (~> 1.2, >= 1.2.2) + cucumber-ci-environment (9.1.0) + cucumber-core (11.0.0) + cucumber-gherkin (~> 23.0, >= 23.0.1) + cucumber-messages (~> 18.0, >= 18.0.0) + cucumber-tag-expressions (~> 4.1, >= 4.1.0) + cucumber-cucumber-expressions (15.2.0) + cucumber-gherkin (23.0.1) + cucumber-messages (~> 18.0, >= 18.0.0) + cucumber-html-formatter (19.2.0) + cucumber-messages (~> 18.0, >= 18.0.0) + cucumber-messages (18.0.0) + cucumber-tag-expressions (4.1.0) + daemons (1.4.1) + database_cleaner (2.0.1) + database_cleaner-active_record (~> 2.0.0) + database_cleaner-active_record (2.0.1) + activerecord (>= 5.a) + database_cleaner-core (~> 2.0.0) + database_cleaner-core (2.0.1) + diff-lcs (1.5.0) + docile (1.4.0) + domain_name (0.5.20190701) + unf (>= 0.0.5, < 1.0.0) + eventmachine (1.2.7) + ffi (1.15.5) + haml (5.2.2) + temple (>= 0.8.0) + tilt + hashie (5.0.0) + http-accept (1.7.0) + http-cookie (1.0.5) + domain_name (~> 0.5) + i18n (1.12.0) + concurrent-ruby (~> 1.0) + io-like (0.3.1) + json (2.6.2) + launchy (2.5.0) + addressable (~> 2.7) + matrix (0.4.2) + method_source (1.0.0) + mime-types (3.4.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2022.0105) + mini_mime (1.1.2) + minitar (0.8) + minitar-cli (0.8) + minitar (~> 0.8.0) + powerbar (~> 1.0) + minitest (5.16.3) + multi_test (1.1.0) + mustermann (2.0.2) + ruby2_keywords (~> 0.0.1) + netrc (0.11.0) + nio4r (2.5.8) + nokogiri (1.13.9-x86_64-darwin) + racc (~> 1.4) + phantomjs (2.1.1.0) + poltergeist (1.18.1) + capybara (>= 2.1, < 4) + cliver (~> 0.3.1) + websocket-driver (>= 0.2.0) + powerbar (1.0.18) + hashie (>= 1.1.0) + pry (0.14.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-byebug (3.10.1) + byebug (~> 11.0) + pry (>= 0.13, < 0.15) + public_suffix (5.0.0) + puma (6.0.0) + nio4r (~> 2.0) + racc (1.6.0) + rack (2.2.4) + rack-protection (2.2.3) + rack + rack-test (2.0.2) + rack (>= 1.3) + rake (13.0.6) + regexp_parser (2.6.1) + relish (0.7.1) + archive-tar-minitar (>= 0.5.2) + json (>= 1.4.6) + rest-client (>= 1.7.2) + rest-client (2.1.0) + http-accept (>= 1.7.0, < 2.0) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 4.0) + netrc (~> 0.8) + rexml (3.2.5) + rspec (3.12.0) + rspec-core (~> 3.12.0) + rspec-expectations (~> 3.12.0) + rspec-mocks (~> 3.12.0) + rspec-core (3.12.0) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-support (3.12.0) + ruby2_keywords (0.0.5) + rubyzip (2.3.2) + selenium-webdriver (4.6.1) + childprocess (>= 0.5, < 5.0) + rexml (~> 3.2, >= 3.2.5) + rubyzip (>= 1.2.2, < 3.0) + websocket (~> 1.0) + simplecov (0.21.2) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.12.3) + simplecov_json_formatter (0.1.4) + sinatra (2.2.3) + mustermann (~> 2.0) + rack (~> 2.2) + rack-protection (= 2.2.3) + tilt (~> 2.0) + sinatra-flash (0.3.0) + sinatra (>= 1.0.0) + sqlite3 (1.5.4-x86_64-darwin) + sys-uname (1.2.2) + ffi (~> 1.1) + temple (0.9.1) + thin (1.8.1) + daemons (~> 1.0, >= 1.0.9) + eventmachine (~> 1.0, >= 1.0.4) + rack (>= 1, < 3) + thread_safe (0.3.6) + tilt (2.0.11) + tzinfo (1.2.10) + thread_safe (~> 0.1) + unf (0.1.4) + unf_ext + unf_ext (0.0.8.2) + websocket (1.2.9) + websocket-driver (0.7.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) + +PLATFORMS + x86_64-darwin-19 + +DEPENDENCIES + anticipate + awesome_print + capybara + chromedriver-helper + cucumber + database_cleaner + launchy + phantomjs + poltergeist + pry + pry-byebug + puma + rack-test + rake + relish + rest-assured! + rspec + selenium-webdriver + simplecov + sqlite3 + +BUNDLED WITH + 2.3.11 From 6ddae6351ca26220c0e529effd95736cb7273b36 Mon Sep 17 00:00:00 2001 From: shanekelly-bbc Date: Mon, 5 Dec 2022 11:48:21 +0000 Subject: [PATCH 11/11] MSPA-2678 updating version --- Gemfile.lock | 2 +- lib/rest-assured/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a6a7c5e..d766751 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - rest-assured (4.0.0) + rest-assured (4.0.1) activerecord (~> 5.0, >= 4.0) activeresource (~> 5.0, >= 4.0) childprocess (~> 0.3) diff --git a/lib/rest-assured/version.rb b/lib/rest-assured/version.rb index fed142f..e73a514 100644 --- a/lib/rest-assured/version.rb +++ b/lib/rest-assured/version.rb @@ -1,3 +1,3 @@ module RestAssured - VERSION = '4.0.0' + VERSION = '4.0.1' end