Skip to content

Commit f6f633c

Browse files
authored
update tests and ci for ruby 4 (#1197)
1 parent 674598f commit f6f633c

9 files changed

Lines changed: 63 additions & 22 deletions

File tree

.github/workflows/ci.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,19 @@ jobs:
2020
- gemfiles/rails61.gemfile
2121
include:
2222
- gemfile: gemfiles/rails81.gemfile
23-
ruby-version: 3.4.7
23+
ruby-version: 4.0.0
24+
- gemfile: gemfiles/rails81.gemfile
25+
ruby-version: 3.4.8
2426
- gemfile: gemfiles/rails81.gemfile
2527
ruby-version: 3.3.10
2628
- gemfile: gemfiles/rails72.gemfile
27-
ruby-version: 3.4.7
29+
ruby-version: 4.0.0
30+
- gemfile: gemfiles/rails72.gemfile
31+
ruby-version: 3.4.8
2832
- gemfile: gemfiles/rails72.gemfile
2933
ruby-version: 3.3.10
3034
- gemfile: gemfiles/rails71.gemfile
31-
ruby-version: 3.4.7
35+
ruby-version: 3.4.8
3236
- gemfile: gemfiles/rails71.gemfile
3337
ruby-version: 3.3.10
3438
- gemfile: gemfiles/rails70.gemfile

Gemfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This Gemfile is compatible with Ruby 2.5.0 or greater. To test with
22
# earlier Rubies, use the appropriate Gemfile from the ./gemfiles/ dir.
3-
ruby '3.4.7'
3+
ruby '4.0.0'
44

55
source 'https://rubygems.org'
66

@@ -74,6 +74,11 @@ if GEM_VERSION_RAILS < Gem::Version.new('6.0')
7474
else
7575
gem 'delayed_job', '~> 4.1', :require => false
7676
end
77+
78+
gem 'cgi' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.5.0')
79+
80+
gem 'benchmark' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('4.0.0')
81+
7782
gem 'generator_spec'
7883
gem 'redis', '<= 4.8.0'
7984
gem 'resque', '< 2.0.0'

gemfiles/rails70.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ is_jruby = defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && RUBY_ENGINE == '
66

77
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
88
gem 'jruby-openssl', :platform => :jruby
9-
gem 'rails', '~> 7.0.8'
9+
gem 'rails', '~> 7.0.10'
1010
gem 'sqlite3', '~> 1.4', :platform => [:ruby, :mswin, :mingw]
1111

1212
gem 'rspec-rails', '~> 6.0.3'

gemfiles/rails71.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ is_jruby = defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && RUBY_ENGINE == '
66

77
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
88
gem 'jruby-openssl', :platform => :jruby
9-
gem 'rails', '~> 7.1.0'
9+
gem 'rails', '~> 7.1.6'
1010
gem 'sqlite3', '~> 1.4', :platform => [:ruby, :mswin, :mingw]
1111

1212
gem 'rspec-rails', '~> 6.0.3'

gemfiles/rails72.gemfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ is_jruby = defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && RUBY_ENGINE == '
66

77
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
88
gem 'jruby-openssl', :platform => :jruby
9-
gem 'rails', '~> 7.2.0'
9+
gem 'rails', '~> 7.2.3'
1010
gem 'sqlite3', '~> 1.4', :platform => [:ruby, :mswin, :mingw]
1111

1212
gem 'rspec-rails', '~> 6.0.3'
@@ -27,6 +27,10 @@ gem 'sucker_punch', '~> 2.0'
2727
# We need last sinatra that uses rack 2.x and ruby 2.5.x
2828
gem 'sinatra', :git => 'https://github.com/sinatra/sinatra', :tag =>'v2.1.0'
2929

30+
gem 'cgi' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.5.0')
31+
32+
gem 'benchmark' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('4.0.0')
33+
3034
gem 'database_cleaner'
3135
gem 'delayed_job', '4.1.10', :require => false
3236
gem 'generator_spec'

gemfiles/rails81.gemfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ is_jruby = defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && RUBY_ENGINE == '
66

77
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
88
gem 'jruby-openssl', :platform => :jruby
9-
gem 'rails', '~> 8.1.0'
9+
gem 'rails', '~> 8.1.1'
1010
gem 'sqlite3', '~> 2.1', :platform => [:ruby, :mswin, :mingw]
1111

1212
gem 'rspec-rails', '~> 6.0.3'
@@ -27,6 +27,10 @@ gem 'sucker_punch', '~> 2.0'
2727
# We need last sinatra that uses rack 2.x and ruby 2.5.x
2828
gem 'sinatra', :git => 'https://github.com/sinatra/sinatra', :tag =>'v2.1.0'
2929

30+
gem 'cgi' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.5.0')
31+
32+
gem 'benchmark' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('4.0.0')
33+
3034
gem 'database_cleaner'
3135
gem 'delayed_job', '4.1.13', :require => false
3236
gem 'generator_spec'

spec/controllers/home_controller_spec.rb

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -446,17 +446,29 @@ def send_req(meth, path, args)
446446
else
447447
expect(frames[-2][:method]).to be_eql('tap')
448448
end
449-
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0')
449+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('4.0.0')
450+
expect(frames[-2][:locals]).to be_eql(locals[1])
451+
elsif Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0')
450452
expect(frames[-2][:locals]).to be_nil
451453
else
452454
expect(frames[-2][:locals]).to be_eql(locals[1])
453455
end
454456

455-
expect(frames[-3][:locals]).to be_eql(locals[2])
456-
expect(frames[-4][:locals]).to be_eql(locals[3])
457-
# Frames: -5 (and -6 in rails < 8.0) are not app frames, and have different
458-
# contents in different Ruby versions.
459-
if Gem::Version.new(Rails.version) >= Gem::Version.new('8.0.0')
457+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('4.0.0')
458+
expect(frames[-3][:locals]).to be_eql(locals[3])
459+
else
460+
expect(frames[-3][:locals]).to be_eql(locals[2])
461+
expect(frames[-4][:locals]).to be_eql(locals[3])
462+
end
463+
464+
# Skip non-app frames, which vary based on Ruby and Rails versions
465+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('4.0.0')
466+
if Gem::Version.new(Rails.version) >= Gem::Version.new('8.0.0')
467+
expect(frames[-5][:locals]).to be_eql(locals[4])
468+
else
469+
expect(frames[-4][:locals]).to be_eql(locals[4])
470+
end
471+
elsif Gem::Version.new(Rails.version) >= Gem::Version.new('8.0.0')
460472
expect(frames[-6][:locals]).to be_eql(locals[4])
461473
else
462474
expect(frames[-7][:locals]).to be_eql(locals[4])

spec/rollbar/middleware/sinatra_spec.rb

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,17 +293,29 @@ def app
293293
else
294294
expect(frames[-2][:method]).to be_eql('tap')
295295
end
296-
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0')
296+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('4.0.0')
297+
expect(frames[-2][:locals]).to be_eql(locals[1])
298+
elsif Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0')
297299
expect(frames[-2][:locals]).to be_nil
298300
else
299301
expect(frames[-2][:locals]).to be_eql(locals[1])
300302
end
301303

302-
expect(frames[-3][:locals]).to be_eql(locals[2])
303-
expect(frames[-4][:locals]).to be_eql(locals[3])
304-
# Frames: -5 (and -6 in rails < 8.0) are not app frames, and have different
305-
# contents in different Ruby versions.
306-
if Gem::Version.new(Rails.version) >= Gem::Version.new('8.0.0')
304+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('4.0.0')
305+
expect(frames[-3][:locals]).to be_eql(locals[3])
306+
else
307+
expect(frames[-3][:locals]).to be_eql(locals[2])
308+
expect(frames[-4][:locals]).to be_eql(locals[3])
309+
end
310+
311+
# Skip non-app frames, which vary based on Ruby and Rails versions
312+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('4.0.0')
313+
if Gem::Version.new(Rails.version) >= Gem::Version.new('8.0.0')
314+
expect(frames[-5][:locals]).to be_eql(locals[4])
315+
else
316+
expect(frames[-4][:locals]).to be_eql(locals[4])
317+
end
318+
elsif Gem::Version.new(Rails.version) >= Gem::Version.new('8.0.0')
307319
expect(frames[-6][:locals]).to be_eql(locals[4])
308320
else
309321
expect(frames[-7][:locals]).to be_eql(locals[4])

spec/spec_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
begin
22
require 'simplecov'
33

4-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
4+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
55
SimpleCov::Formatter::HTMLFormatter
6-
]
6+
)
77

88
SimpleCov.start do
99
add_filter '/spec/'

0 commit comments

Comments
 (0)