From e38ee98ed70fcfa61b90bbf5fd6478b918669039 Mon Sep 17 00:00:00 2001 From: Eric Proulx Date: Sat, 28 Dec 2024 18:59:48 +0100 Subject: [PATCH 1/3] Add ruby 3.4 to CI Fix specs --- .github/workflows/danger.yml | 2 +- .github/workflows/edge.yml | 2 +- .github/workflows/test.yml | 4 ++-- spec/grape/api_spec.rb | 5 +++-- spec/grape/endpoint_spec.rb | 13 ++++++++----- spec/grape/middleware/exception_spec.rb | 3 ++- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index 5e99cbf53b..12372470c4 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -12,7 +12,7 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7 + ruby-version: 3.4 bundler-cache: true - name: Run Danger run: | diff --git a/.github/workflows/edge.yml b/.github/workflows/edge.yml index c9d26044dc..c73a44ad34 100644 --- a/.github/workflows/edge.yml +++ b/.github/workflows/edge.yml @@ -6,7 +6,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: ['2.7', '3.0', '3.1', '3.2', '3.3', ruby-head, truffleruby-head, jruby-head] + ruby: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4', ruby-head, truffleruby-head, jruby-head] gemfile: [rails_edge, rack_edge] exclude: - ruby: '2.7' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a7710f2aa8..14a6638185 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.3 + ruby-version: 3.4 bundler-cache: true rubygems: latest @@ -23,7 +23,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: ['2.7', '3.0', '3.1', '3.2', '3.3'] + ruby: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4'] gemfile: [Gemfile, gemfiles/rack_2_0.gemfile, gemfiles/rack_3_0.gemfile, gemfiles/rack_3_1.gemfile, gemfiles/rails_6_1.gemfile, gemfiles/rails_7_0.gemfile, gemfiles/rails_7_1.gemfile, gemfiles/rails_7_2.gemfile, gemfiles/rails_8_0.gemfile] specs: ['spec --exclude-pattern=spec/integration/**/*_spec.rb'] include: diff --git a/spec/grape/api_spec.rb b/spec/grape/api_spec.rb index bd63987807..20193ccb35 100644 --- a/spec/grape/api_spec.rb +++ b/spec/grape/api_spec.rb @@ -2970,9 +2970,10 @@ def self.call(object, _env) subject.put :yaml do params[:tag] end - put '/yaml', 'a123', 'CONTENT_TYPE' => 'application/xml' + body = 'a123' + put '/yaml', body, 'CONTENT_TYPE' => 'application/xml' expect(last_response).to be_successful - expect(last_response.body).to eql '{"type"=>"symbol", "__content__"=>"a123"}' + expect(last_response.body).to eq(Grape::Xml.parse(body)['tag'].to_s) end end end diff --git a/spec/grape/endpoint_spec.rb b/spec/grape/endpoint_spec.rb index f51e582138..0674731fec 100644 --- a/spec/grape/endpoint_spec.rb +++ b/spec/grape/endpoint_spec.rb @@ -391,14 +391,16 @@ def app expect(last_response.body).to eq('Bobby T.') end else + let(:body) { 'Bobby T.' } + it 'converts XML bodies to params' do - post '/request_body', 'Bobby T.', 'CONTENT_TYPE' => 'application/xml' - expect(last_response.body).to eq('{"__content__"=>"Bobby T."}') + post '/request_body', body, 'CONTENT_TYPE' => 'application/xml' + expect(last_response.body).to eq(Grape::Xml.parse(body)['user'].to_s) end it 'converts XML bodies to params' do - put '/request_body', 'Bobby T.', 'CONTENT_TYPE' => 'application/xml' - expect(last_response.body).to eq('{"__content__"=>"Bobby T."}') + put '/request_body', body, 'CONTENT_TYPE' => 'application/xml' + expect(last_response.body).to eq(Grape::Xml.parse(body)['user'].to_s) end end @@ -685,7 +687,8 @@ def app if Gem::Version.new(RUBY_VERSION).release <= Gem::Version.new('3.2') %r{undefined local variable or method `undefined_helper' for # in '/hey' endpoint} else - /undefined local variable or method `undefined_helper' for/ + opening_quote = Gem::Version.new(RUBY_VERSION).release >= Gem::Version.new('3.4') ? "'" : '`' + /undefined local variable or method #{opening_quote}undefined_helper' for/ end end diff --git a/spec/grape/middleware/exception_spec.rb b/spec/grape/middleware/exception_spec.rb index b3fe181448..b209b726f1 100644 --- a/spec/grape/middleware/exception_spec.rb +++ b/spec/grape/middleware/exception_spec.rb @@ -220,7 +220,8 @@ def call(_env) it 'is possible to specify a custom formatter' do get '/' - expect(last_response.body).to eq('{:custom_formatter=>"rain!"}') + response = Rack::Utils.escape_html({ custom_formatter: 'rain!' }.inspect) + expect(last_response.body).to eq(response) end end From a0abdaa427c41fa90bcaccfb729c2da854746890 Mon Sep 17 00:00:00 2001 From: Eric Proulx Date: Sat, 28 Dec 2024 19:01:39 +0100 Subject: [PATCH 2/3] CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ec8b6d643..13b1b09133 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ * [#2513](https://github.com/ruby-grape/grape/pull/2513): Optimize Grape::Path - [@ericproulx](https://github.com/ericproulx). * [#2514](https://github.com/ruby-grape/grape/pull/2514): Add rails 8.0 to CI - [@ericproulx](https://github.com/ericproulx). * [#2516](https://github.com/ruby-grape/grape/pull/2516): Dynamic registration for parsers, formatters, versioners - [@ericproulx](https://github.com/ericproulx). +* [#2518](https://github.com/ruby-grape/grape/pull/2518): Add ruby 3.4 to CI - [@ericproulx](https://github.com/ericproulx). * Your contribution here. #### Fixes From ca7f6c1b6e8bef1690e41a50c81f7148676e25df Mon Sep 17 00:00:00 2001 From: Eric Proulx Date: Sat, 28 Dec 2024 19:07:10 +0100 Subject: [PATCH 3/3] Add mutex_m for rails 6.1 and 7.0 gemfiles --- gemfiles/rails_6_1.gemfile | 1 + gemfiles/rails_7_0.gemfile | 1 + 2 files changed, 2 insertions(+) diff --git a/gemfiles/rails_6_1.gemfile b/gemfiles/rails_6_1.gemfile index f6ae644776..edb73448cb 100644 --- a/gemfiles/rails_6_1.gemfile +++ b/gemfiles/rails_6_1.gemfile @@ -2,5 +2,6 @@ eval_gemfile '../Gemfile' +gem 'mutex_m' gem 'rails', '~> 6.1' gem 'tzinfo-data', require: false diff --git a/gemfiles/rails_7_0.gemfile b/gemfiles/rails_7_0.gemfile index e9c87639dd..b458a7d6fa 100644 --- a/gemfiles/rails_7_0.gemfile +++ b/gemfiles/rails_7_0.gemfile @@ -2,5 +2,6 @@ eval_gemfile '../Gemfile' +gem 'mutex_m' gem 'rails', '~> 7.0.0' gem 'tzinfo-data', require: false