Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ruby 3.1 and 3.2 to the CI matrix and fix CI failure in Ruby 3 #916

Merged
merged 14 commits into from
Aug 21, 2024
Merged
25 changes: 9 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ on:
- push
- pull_request

permissions:
contents: read

jobs:
rspec:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
ruby:
- '3.3'
- '3.2'
- '3.1'
- '3.0'
- '2.7'
- '2.6'
Expand All @@ -26,29 +32,16 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}

- name: Setup Ruby cache
uses: actions/cache@v2
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-${{ matrix.ruby }}-

- name: Bundle
run: |
gem install bundler
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
bundler-cache: true

- name: RSpec & publish code coverage
uses: paambaati/codeclimate-action@v2.7.5
uses: paambaati/codeclimate-action@v8
env:
CC_TEST_REPORTER_ID: b7ba588af2a540fa96c267b3655a2afe31ea29976dc25905a668dd28d5e88915
with:
Expand Down
16 changes: 14 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ gemspec

platforms :ruby do
if RUBY_VERSION >= "2.5.0"
gem 'sqlite3'
gem 'sqlite3', '~> 1.4'
else
gem 'sqlite3', '~> 1.3.6'
end
Expand All @@ -22,8 +22,20 @@ else
gem "rails", "~> 5.0"
end

if RUBY_VERSION >= "2.5.0"
if RUBY_VERSION >= "2.7.0"
gem "mongoid", github: "mongodb/mongoid"
elsif RUBY_VERSION >= "2.6.0"
gem "mongoid", "~> 8.1"
else
gem "mongoid", "~> 7.2"
end

if RUBY_VERSION >= "3.1.0"
gem "net-imap"
gem "net-pop"
gem "net-smtp"
end

if RUBY_VERSION < "2.5.0"
gem "loofah", "< 2.21.0" # Workaround for `uninitialized constant Nokogiri::HTML4`
end
2 changes: 1 addition & 1 deletion spec/draper/decoratable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ module Draper
scoped = [Product.new]
allow(Product).to receive(:all).and_return(scoped)

expect(Product.decorator_class).to receive(:decorate_collection).with(scoped, with: nil).and_return(:decorated_collection)
expect(Product.decorator_class).to receive(:decorate_collection).with(scoped, {with: nil}).and_return(:decorated_collection)
expect(Product.decorate).to be :decorated_collection
end

Expand Down
4 changes: 2 additions & 2 deletions spec/draper/decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ module Draper
it "creates a CollectionDecorator using itself for each item" do
object = [Model.new]

expect(CollectionDecorator).to receive(:new).with(object, with: Decorator)
expect(CollectionDecorator).to receive(:new).with(object, {with: Decorator})
Decorator.decorate_collection(object)
end

Expand All @@ -134,7 +134,7 @@ module Draper
it "creates a custom collection decorator using itself for each item" do
object = [Model.new]

expect(ProductsDecorator).to receive(:new).with(object, with: ProductDecorator)
expect(ProductsDecorator).to receive(:new).with(object, {with: ProductDecorator})
ProductDecorator.decorate_collection(object)
end

Expand Down
16 changes: 8 additions & 8 deletions spec/draper/factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,17 @@ module Draper
worker = ->(*){}
allow(Factory::Worker).to receive_messages new: worker

expect(worker).to receive(:call).with(baz: "qux", context: {foo: "bar"})
expect(worker).to receive(:call).with({baz: "qux", context: {foo: "bar"}})
factory.decorate(double, {baz: "qux"})
end

it "is overridden by explicitly-specified context" do
factory = Factory.new(context: {foo: "bar"})
factory = Factory.new({context: {foo: "bar"}})
worker = ->(*){}
allow(Factory::Worker).to receive_messages new: worker

expect(worker).to receive(:call).with(context: {baz: "qux"})
factory.decorate(double, context: {baz: "qux"})
expect(worker).to receive(:call).with({context: {baz: "qux"}})
factory.decorate(double, {context: {baz: "qux"}})
end
end
end
Expand All @@ -109,7 +109,7 @@ module Draper
allow(worker).to receive_messages decorator: decorator
context = {foo: "bar"}

expect(decorator).to receive(:call).with(anything(), context: context)
expect(decorator).to receive(:call).with(anything(), {context: context})
worker.call(context: ->{ context })
end

Expand Down Expand Up @@ -140,7 +140,7 @@ module Draper
allow(worker).to receive_messages decorator: decorator
context = {foo: "bar"}

expect(decorator).to receive(:call).with(anything(), context: context)
expect(decorator).to receive(:call).with(anything(), {context: context})
worker.call(context: context)
end
end
Expand All @@ -150,7 +150,7 @@ module Draper
decorator = ->(*){}
allow(worker).to receive_messages decorator: decorator

expect(decorator).to receive(:call).with(anything(), foo: "bar")
expect(decorator).to receive(:call).with(anything(), {foo: "bar"})
worker.call(foo: "bar", context_args: [])
end
end
Expand Down Expand Up @@ -228,7 +228,7 @@ module Draper
allow(object).to receive(:decorate){ nil }
worker = Factory::Worker.new(nil, object)

expect(decorator_class).to receive(:decorate_collection).with(object, foo: "bar", with: nil).and_return(:decorated)
expect(decorator_class).to receive(:decorate_collection).with(object, {foo: "bar", with: nil}).and_return(:decorated)
expect(worker.decorator.call(object, foo: "bar")).to be :decorated
end
end
Expand Down