diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index c3962d1..3e2919a 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -8,6 +8,6 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: "3.1.2" + ruby-version: 3.3.3 bundler-cache: true - run: bundle exec rubocop diff --git a/.rubocop.yml b/.rubocop.yml index 440c672..ed78494 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -16,6 +16,7 @@ Layout/LineLength: require: - rubocop-capybara - rubocop-rails + - rubocop-rspec_rails - rubocop-rake - rubocop-rspec diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a2a2ca7..8d244e1 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-03-19 16:06:55 UTC using RuboCop version 1.62.1. +# on 2024-08-31 12:33:26 UTC using RuboCop version 1.62.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -14,6 +14,7 @@ Lint/EmptyBlock: # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AutoCorrect. RSpec/EmptyExampleGroup: Exclude: - 'spec/helpers/welcome_helper_spec.rb' @@ -21,12 +22,21 @@ RSpec/EmptyExampleGroup: # Offense count: 4 # Configuration parameters: CountAsOne. RSpec/ExampleLength: - Max: 13 + Max: 22 # Offense count: 5 -# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. -# Include: **/*_spec*rb*, **/spec/**/* -RSpec/FilePath: +RSpec/MultipleExpectations: + Max: 2 + +# Offense count: 2 +RSpec/RepeatedExample: + Exclude: + - 'spec/api/headers_spec.rb' + +# Offense count: 5 +# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata. +# Include: **/*_spec.rb +RSpec/SpecFilePathFormat: Exclude: - 'spec/api/headers_spec.rb' - 'spec/api/ping_spec.rb' @@ -34,15 +44,11 @@ RSpec/FilePath: - 'spec/api/protected_spec.rb' - 'spec/api/raise_spec.rb' -# Offense count: 4 -RSpec/MultipleExpectations: - Max: 2 - # Offense count: 4 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: ResponseMethods. # ResponseMethods: response, last_response -RSpec/Rails/HaveHttpStatus: +RSpecRails/HaveHttpStatus: Exclude: - 'spec/api/post_spec.rb' - 'spec/api/protected_spec.rb' @@ -50,23 +56,7 @@ RSpec/Rails/HaveHttpStatus: # Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Inferences. -RSpec/Rails/InferredSpecType: +RSpecRails/InferredSpecType: Exclude: - 'spec/features/homepage_spec.rb' - 'spec/features/swagger_spec.rb' - -# Offense count: 2 -RSpec/RepeatedExample: - Exclude: - - 'spec/api/headers_spec.rb' - -# Offense count: 5 -# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata. -# Include: **/*_spec.rb -RSpec/SpecFilePathFormat: - Exclude: - - 'spec/api/headers_spec.rb' - - 'spec/api/ping_spec.rb' - - 'spec/api/post_spec.rb' - - 'spec/api/protected_spec.rb' - - 'spec/api/raise_spec.rb' diff --git a/Gemfile b/Gemfile index 71679fe..f200066 100644 --- a/Gemfile +++ b/Gemfile @@ -11,7 +11,7 @@ gem 'sprockets-rails' gem 'pg', '~> 1.1' # Use the Puma web server [/~https://github.com/puma/puma] -gem 'puma', '~> 5.6' +gem 'puma' # Use JavaScript with ESM import maps [/~https://github.com/rails/importmap-rails] gem 'importmap-rails' @@ -46,7 +46,7 @@ gem 'bootsnap', require: false # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] # gem "image_processing", "~> 1.2" -gem 'grape', '~> 1.7' +gem 'grape', '~> 2.1' gem 'grape-swagger' group :development, :test do @@ -77,6 +77,6 @@ group :test do gem 'rubocop-rails' gem 'rubocop-rake' gem 'rubocop-rspec' + gem 'rubocop-rspec_rails' gem 'selenium-webdriver' - gem 'webdrivers' end diff --git a/Gemfile.lock b/Gemfile.lock index 53bd72b..32524ff 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -66,73 +66,78 @@ GEM i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) - appraisal (2.4.1) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + appraisal (2.5.0) bundler rake thor (>= 0.14.0) ast (2.4.2) + base64 (0.2.0) + bigdecimal (3.1.8) bindex (0.8.1) - bootsnap (1.12.0) + bootsnap (1.18.4) msgpack (~> 1.2) - builder (3.2.4) - capybara (3.37.1) + builder (3.3.0) + capybara (3.40.0) addressable matrix mini_mime (>= 0.1.3) - nokogiri (~> 1.8) + nokogiri (~> 1.11) rack (>= 1.6.0) rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) - childprocess (4.1.0) - concurrent-ruby (1.3.1) + concurrent-ruby (1.3.4) crass (1.0.6) date (3.3.4) - debug (1.5.0) - irb (>= 1.3.6) - reline (>= 0.2.7) - diff-lcs (1.5.0) - dry-core (1.0.0) + debug (1.9.2) + irb (~> 1.10) + reline (>= 0.3.8) + diff-lcs (1.5.1) + dry-core (1.0.1) concurrent-ruby (~> 1.0) zeitwerk (~> 2.6) - dry-inflector (1.0.0) + dry-inflector (1.1.0) dry-logic (1.5.0) concurrent-ruby (~> 1.0) dry-core (~> 1.0, < 2) zeitwerk (~> 2.6) - dry-types (1.7.1) + dry-types (1.7.2) + bigdecimal (~> 3.0) concurrent-ruby (~> 1.0) dry-core (~> 1.0) dry-inflector (~> 1.0) dry-logic (~> 1.4) zeitwerk (~> 2.6) - erubi (1.12.0) + erubi (1.13.0) globalid (1.2.1) activesupport (>= 6.1) - grape (1.7.0) - activesupport - builder + grape (2.1.3) + activesupport (>= 6) dry-types (>= 1.1) - mustermann-grape (~> 1.0.0) - rack (>= 1.3.0) - rack-accept - grape-swagger (1.6.0) - grape (~> 1.3) + mustermann-grape (~> 1.1.0) + rack (>= 2) + zeitwerk + grape-swagger (2.1.0) + grape (>= 1.7, < 3.0) + rack-test (~> 2) i18n (1.14.5) concurrent-ruby (~> 1.0) - importmap-rails (1.1.1) + importmap-rails (2.0.1) actionpack (>= 6.0.0) + activesupport (>= 6.0.0) railties (>= 6.0.0) - io-console (0.5.11) - irb (1.4.1) - reline (>= 0.3.0) - jbuilder (2.11.5) + io-console (0.7.2) + irb (1.14.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + jbuilder (2.12.0) actionview (>= 5.0.0) activesupport (>= 5.0.0) - json (2.7.1) + json (2.7.2) language_server-protocol (3.17.0.3) + logger (1.6.0) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -143,42 +148,48 @@ GEM net-smtp marcel (1.0.4) matrix (0.4.2) - method_source (1.0.0) + method_source (1.1.0) mini_mime (1.1.5) - minitest (5.23.1) - msgpack (1.5.2) - mustermann (3.0.0) + minitest (5.25.1) + msgpack (1.7.2) + mustermann (3.0.2) ruby2_keywords (~> 0.0.1) - mustermann-grape (1.0.2) + mustermann-grape (1.1.0) mustermann (>= 1.0.0) - net-imap (0.4.10) + net-imap (0.4.15) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.2) timeout - net-smtp (0.4.0.1) + net-smtp (0.5.0) net-protocol - nio4r (2.7.0) - nokogiri (1.16.5-arm64-darwin) + nio4r (2.7.3) + nokogiri (1.16.7-aarch64-linux) + racc (~> 1.4) + nokogiri (1.16.7-arm-linux) + racc (~> 1.4) + nokogiri (1.16.7-arm64-darwin) + racc (~> 1.4) + nokogiri (1.16.7-x86-linux) racc (~> 1.4) - nokogiri (1.16.5-x86_64-darwin) + nokogiri (1.16.7-x86_64-darwin) racc (~> 1.4) - nokogiri (1.16.5-x86_64-linux) + nokogiri (1.16.7-x86_64-linux) racc (~> 1.4) - parallel (1.24.0) - parser (3.3.0.5) + parallel (1.26.3) + parser (3.3.4.2) ast (~> 2.4.1) racc - pg (1.3.5) - public_suffix (4.0.7) - puma (5.6.8) + pg (1.5.7) + psych (5.1.2) + stringio + public_suffix (6.0.1) + puma (6.4.2) nio4r (~> 2.0) - racc (1.8.0) + racc (1.8.1) rack (2.2.9) - rack-accept (0.4.5) - rack (>= 0.4) rack-test (2.1.0) rack (>= 1.3) rails (7.0.8.4) @@ -210,32 +221,35 @@ GEM thor (~> 1.0) zeitwerk (~> 2.5) rainbow (3.1.1) - rake (13.1.0) - regexp_parser (2.5.0) - reline (0.3.1) + rake (13.2.1) + rdoc (6.7.0) + psych (>= 4.0.0) + regexp_parser (2.9.2) + reline (0.5.9) io-console (~> 0.5) - rexml (3.2.5) - rspec (3.11.0) - rspec-core (~> 3.11.0) - rspec-expectations (~> 3.11.0) - rspec-mocks (~> 3.11.0) - rspec-core (3.11.0) - rspec-support (~> 3.11.0) - rspec-expectations (3.11.0) + rexml (3.3.6) + strscan + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.0) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-mocks (3.11.1) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-rails (5.1.2) - actionpack (>= 5.2) - activesupport (>= 5.2) - railties (>= 5.2) - rspec-core (~> 3.10) - rspec-expectations (~> 3.10) - rspec-mocks (~> 3.10) - rspec-support (~> 3.10) - rspec-support (3.11.0) + rspec-support (~> 3.13.0) + rspec-rails (6.1.4) + actionpack (>= 6.1) + activesupport (>= 6.1) + railties (>= 6.1) + rspec-core (~> 3.13) + rspec-expectations (~> 3.13) + rspec-mocks (~> 3.13) + rspec-support (~> 3.13) + rspec-support (3.13.1) rubocop (1.62.1) json (~> 2.3) language_server-protocol (>= 3.17.0) @@ -247,70 +261,70 @@ GEM rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.31.2) - parser (>= 3.3.0.4) - rubocop-capybara (2.20.0) - rubocop (~> 1.41) - rubocop-factory_bot (2.25.1) + rubocop-ast (1.32.1) + parser (>= 3.3.1.0) + rubocop-capybara (2.21.0) rubocop (~> 1.41) - rubocop-rails (2.24.0) + rubocop-rails (2.26.0) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 1.33.0, < 2.0) + rubocop (>= 1.52.0, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (2.27.1) - rubocop (~> 1.40) - rubocop-capybara (~> 2.17) - rubocop-factory_bot (~> 2.22) + rubocop-rspec (3.0.4) + rubocop (~> 1.61) + rubocop-rspec_rails (2.30.0) + rubocop (~> 1.61) + rubocop-rspec (~> 3, >= 3.0.1) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) rubyzip (2.3.2) - selenium-webdriver (4.2.1) - childprocess (>= 0.5, < 5.0) + selenium-webdriver (4.24.0) + base64 (~> 0.2) + logger (~> 1.4) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) - sprockets (4.0.3) + sprockets (4.2.1) concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (3.4.2) - actionpack (>= 5.2) - activesupport (>= 5.2) + rack (>= 2.2.4, < 4) + sprockets-rails (3.5.2) + actionpack (>= 6.1) + activesupport (>= 6.1) sprockets (>= 3.0.0) - stimulus-rails (1.0.4) + stimulus-rails (1.3.4) railties (>= 6.0.0) - thor (1.3.1) + stringio (3.1.1) + strscan (3.1.0) + thor (1.3.2) timeout (0.4.1) - turbo-rails (1.1.1) + turbo-rails (2.0.6) actionpack (>= 6.0.0) activejob (>= 6.0.0) railties (>= 6.0.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.5.0) - web-console (4.2.0) + web-console (4.2.1) actionview (>= 6.0.0) activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - webdrivers (5.0.0) - nokogiri (~> 1.6) - rubyzip (>= 1.3.0) - selenium-webdriver (~> 4.0) - websocket (1.2.9) + websocket (1.2.11) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.13) + zeitwerk (2.6.17) PLATFORMS - arm64-darwin-21 - x86_64-darwin-19 - x86_64-darwin-20 + aarch64-linux + arm-linux + arm64-darwin + x86-linux + x86_64-darwin x86_64-linux DEPENDENCIES @@ -318,12 +332,12 @@ DEPENDENCIES bootsnap capybara debug - grape (~> 1.7) + grape (~> 2.1) grape-swagger importmap-rails jbuilder pg (~> 1.1) - puma (~> 5.6) + puma rails (~> 7.0.8) rspec rspec-rails @@ -332,13 +346,13 @@ DEPENDENCIES rubocop-rails rubocop-rake rubocop-rspec + rubocop-rspec_rails selenium-webdriver sprockets-rails stimulus-rails turbo-rails tzinfo-data web-console - webdrivers BUNDLED WITH - 2.3.26 + 2.5.2 diff --git a/gemfiles/rails_6.gemfile b/gemfiles/rails_6.gemfile index 4bf9ccf..596af58 100644 --- a/gemfiles/rails_6.gemfile +++ b/gemfiles/rails_6.gemfile @@ -3,12 +3,12 @@ source 'https://rubygems.org' gem 'bootsnap', require: false -gem 'grape', '~> 1.7' +gem 'grape', '~> 2.1' gem 'grape-swagger' gem 'importmap-rails' gem 'jbuilder' gem 'pg', '~> 1.1' -gem 'puma', '~> 5.6' +gem 'puma' gem 'rails', '~> 6.0' gem 'sprockets-rails' gem 'stimulus-rails' @@ -33,6 +33,6 @@ group :test do gem 'rubocop-rails' gem 'rubocop-rake' gem 'rubocop-rspec' + gem 'rubocop-rspec_rails' gem 'selenium-webdriver' - gem 'webdrivers' end diff --git a/gemfiles/rails_6_1.gemfile b/gemfiles/rails_6_1.gemfile index 412d942..0ee3efa 100644 --- a/gemfiles/rails_6_1.gemfile +++ b/gemfiles/rails_6_1.gemfile @@ -3,12 +3,12 @@ source 'https://rubygems.org' gem 'bootsnap', require: false -gem 'grape', '~> 1.7' +gem 'grape', '~> 2.1' gem 'grape-swagger' gem 'importmap-rails' gem 'jbuilder' gem 'pg', '~> 1.1' -gem 'puma', '~> 5.6' +gem 'puma' gem 'rails', '~> 6.1' gem 'sprockets-rails' gem 'stimulus-rails' @@ -33,6 +33,6 @@ group :test do gem 'rubocop-rails' gem 'rubocop-rake' gem 'rubocop-rspec' + gem 'rubocop-rspec_rails' gem 'selenium-webdriver' - gem 'webdrivers' end diff --git a/gemfiles/rails_7.gemfile b/gemfiles/rails_7.gemfile index 2e980a5..a15c028 100644 --- a/gemfiles/rails_7.gemfile +++ b/gemfiles/rails_7.gemfile @@ -3,12 +3,12 @@ source 'https://rubygems.org' gem 'bootsnap', require: false -gem 'grape', '~> 1.7' +gem 'grape', '~> 2.1' gem 'grape-swagger' gem 'importmap-rails' gem 'jbuilder' gem 'pg', '~> 1.1' -gem 'puma', '~> 6.4.2' +gem 'puma' gem 'rails', '~> 7.0' gem 'sprockets-rails' gem 'stimulus-rails' @@ -33,6 +33,6 @@ group :test do gem 'rubocop-rails' gem 'rubocop-rake' gem 'rubocop-rspec' + gem 'rubocop-rspec_rails' gem 'selenium-webdriver' - gem 'webdrivers' end diff --git a/gemfiles/rails_edge.gemfile b/gemfiles/rails_edge.gemfile index 49440a0..6ae245c 100644 --- a/gemfiles/rails_edge.gemfile +++ b/gemfiles/rails_edge.gemfile @@ -3,12 +3,12 @@ source 'https://rubygems.org' gem 'bootsnap', require: false -gem 'grape', '~> 1.7' +gem 'grape', '~> 2.1' gem 'grape-swagger' gem 'importmap-rails' gem 'jbuilder' gem 'pg', '~> 1.1' -gem 'puma', '~> 6.4.2' +gem 'puma' gem 'rails', git: '/~https://github.com/rails/rails.git' gem 'sprockets-rails' gem 'stimulus-rails' @@ -33,6 +33,6 @@ group :test do gem 'rubocop-rails' gem 'rubocop-rake' gem 'rubocop-rspec' + gem 'rubocop-rspec_rails' gem 'selenium-webdriver' - gem 'webdrivers' end diff --git a/spec/api/headers_spec.rb b/spec/api/headers_spec.rb index ff860a7..5705a61 100644 --- a/spec/api/headers_spec.rb +++ b/spec/api/headers_spec.rb @@ -3,11 +3,19 @@ describe Acme::Headers do it 'returns all headers' do get '/api/headers' - expect(JSON.parse(response.body)).to include( - 'Accept' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', - 'Cookie' => '', - 'Host' => 'www.example.com' - ) + if Gem::Version.new(Rack.release) >= Gem::Version.new('3') + expect(JSON.parse(response.body)).to include( + 'accept' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', + 'cookie' => '', + 'host' => 'www.example.com' + ) + else + expect(JSON.parse(response.body)).to include( + 'Accept' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', + 'Cookie' => '', + 'Host' => 'www.example.com' + ) + end end it 'returns a Host header' do @@ -20,18 +28,29 @@ expect(JSON.parse(response.body)).to eq('Host' => 'www.example.com') end - it 'headers via arg' do + it "headers via arg (rack #{Rack.release})" do get '/api/headers', headers: { 'HTTP_RETICULATED_SPLINE' => 42, 'Something' => 1, 'SOMETHING_ELSE' => 1 } - expect(JSON.parse(response.body)).to include( - 'Accept' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', - 'Cookie' => '', - 'Host' => 'www.example.com', - 'Reticulated-Spline' => 42, - 'Something' => 1 - ) + + if Gem::Version.new(Rack.release) >= Gem::Version.new('3') + expect(JSON.parse(response.body)).to include( + 'accept' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', + 'cookie' => '', + 'host' => 'www.example.com', + 'reticulated-spline' => 42, + 'something' => 1 + ) + else + expect(JSON.parse(response.body)).to include( + 'Accept' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', + 'Cookie' => '', + 'Host' => 'www.example.com', + 'reticulated-spline' => 42, + 'something' => 1 + ) + end end end