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.0 support #1427

Merged
merged 14 commits into from Apr 10, 2021
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Expand Up @@ -27,6 +27,7 @@ jobs:
fail-fast: false
matrix:
ruby:
- 3.0.1
- 2.7.2
- 2.6.6
appraisal:
Expand All @@ -36,6 +37,9 @@ jobs:
adapter:
- sqlite3
- postgresql
exclude:
- { ruby: 3.0.1, appraisal: rails_5_1 }
- { ruby: 3.0.1, appraisal: rails_5_2 }
env:
DATABASE_ADAPTER: ${{ matrix.adapter }}
BUNDLE_GEMFILE: gemfiles/${{ matrix.appraisal }}.gemfile
Expand All @@ -49,7 +53,7 @@ jobs:
- uses: actions/cache@v2
with:
path: vendor/bundle
key: v1-rubygems-local-${{ runner.os }}-${{ matrix.ruby }}-${{ hashFiles(format('gemfiles/{0}.gemfile.lock', matrix.rails_appraisal)) }}
key: v1-rubygems-local-${{ runner.os }}-${{ matrix.ruby }}-${{ hashFiles(format('gemfiles/{0}.gemfile.lock', matrix.appraisal)) }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops 😅 nice!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 😄

- name: Install dependencies
run: bundle install --jobs=3 --retry=3
- name: Run Unit Tests
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
@@ -1 +1 @@
2.7.2
3.0.1
2 changes: 1 addition & 1 deletion .tool-versions
@@ -1 +1 @@
ruby 2.7.2
ruby 3.0.1
2 changes: 1 addition & 1 deletion Appraisals
Expand Up @@ -77,7 +77,7 @@ appraise 'rails_6_0' do
gem 'jbuilder', '~> 2.7'
gem 'bcrypt', '~> 3.1.7'
gem 'capybara', '>= 2.15'
gem 'listen', '~> 3.2.0'
gem 'listen', '~> 3.3.0'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'selenium-webdriver'
gem 'webdrivers'
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_5_1.gemfile.lock
Expand Up @@ -62,7 +62,7 @@ GEM
crass (1.0.6)
diff-lcs (1.4.4)
erubi (1.10.0)
ffi (1.14.2)
ffi (1.15.0)
fssm (0.2.10)
globalid (0.4.2)
activesupport (>= 4.2.0)
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_5_2.gemfile.lock
Expand Up @@ -73,7 +73,7 @@ GEM
crass (1.0.6)
diff-lcs (1.4.4)
erubi (1.10.0)
ffi (1.14.2)
ffi (1.15.0)
fssm (0.2.10)
globalid (0.4.2)
activesupport (>= 4.2.0)
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_6_0.gemfile
Expand Up @@ -30,7 +30,7 @@ gem "turbolinks", "~> 5"
gem "jbuilder", "~> 2.7"
gem "bcrypt", "~> 3.1.7"
gem "capybara", ">= 2.15"
gem "listen", "~> 3.2.0"
gem "listen", "~> 3.3.0"
gem "spring-watcher-listen", "~> 2.0.0"
gem "selenium-webdriver"
gem "webdrivers"
Expand Down
6 changes: 3 additions & 3 deletions gemfiles/rails_6_0.gemfile.lock
Expand Up @@ -82,15 +82,15 @@ GEM
crass (1.0.6)
diff-lcs (1.4.4)
erubi (1.10.0)
ffi (1.14.2)
ffi (1.15.0)
fssm (0.2.10)
globalid (0.4.2)
activesupport (>= 4.2.0)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
jbuilder (2.11.2)
activesupport (>= 5.0.0)
listen (3.2.1)
listen (3.3.4)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.9.0)
Expand Down Expand Up @@ -268,7 +268,7 @@ DEPENDENCIES
capybara (>= 2.15)
fssm
jbuilder (~> 2.7)
listen (~> 3.2.0)
listen (~> 3.3.0)
pg (>= 0.18, < 2.0)
pry
pry-byebug
Expand Down
1 change: 1 addition & 0 deletions spec/support/acceptance/helpers/step_helpers.rb
Expand Up @@ -82,6 +82,7 @@ def create_rails_application
bundle.remove_gem 'uglifier'
bundle.remove_gem 'debugger'
bundle.remove_gem 'byebug'
bundle.remove_gem 'webdrivers'
bundle.remove_gem 'web-console'
end

Expand Down
2 changes: 1 addition & 1 deletion spec/support/unit/active_record/create_table.rb
Expand Up @@ -109,7 +109,7 @@ def add_column_to_table(table, column_name, column_specification)
)
end

table.column(column_name, column_type, column_options)
table.column(column_name, column_type, **column_options)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/support/unit/helpers/model_builder.rb
Expand Up @@ -44,7 +44,7 @@ def create_table(table_name, options = {}, &block)

begin
connection.execute("DROP TABLE IF EXISTS #{table_name}")
connection.create_table(table_name, options, &block)
connection.create_table(table_name, **options, &block)
created_tables << table_name
connection
rescue StandardError => e
Expand Down
Expand Up @@ -21,7 +21,7 @@

def build_object(**options, &block)
build_object_with_generic_attribute(
options.merge(column_type: :integer, value: 1),
**options.merge(column_type: :integer, value: 1),
&block
)
end
Expand All @@ -45,7 +45,7 @@ def validation_matcher_scenario_args

def build_object(**options, &block)
build_object_with_generic_attribute(
options.merge(
**options.merge(
column_type: :integer,
column_options: { limit: 2 },
value: 1,
Expand All @@ -71,7 +71,7 @@ def expect_to_match_on_values(builder, values, &block)

def build_object(**options, &block)
build_object_with_generic_attribute(
options.merge(column_type: :float, value: 1.0),
**options.merge(column_type: :float, value: 1.0),
&block
)
end
Expand Down Expand Up @@ -99,7 +99,7 @@ def validation_matcher_scenario_args

def build_object(**options, &block)
build_object_with_generic_attribute(
options.merge(column_type: :decimal, value: BigDecimal('1.0')),
**options.merge(column_type: :decimal, value: BigDecimal('1.0')),
&block
)
end
Expand Down Expand Up @@ -130,7 +130,7 @@ def validation_matcher_scenario_args

define_method :build_object do |options = {}, &block|
build_object_with_generic_attribute(
options.merge(column_type: :date, value: today),
**options.merge(column_type: :date, value: today),
&block
)
end
Expand Down Expand Up @@ -158,7 +158,7 @@ def validation_matcher_scenario_args

define_method :build_object do |options = {}, &block|
build_object_with_generic_attribute(
options.merge(column_type: :datetime, value: now),
**options.merge(column_type: :datetime, value: now),
&block
)
end
Expand Down Expand Up @@ -186,7 +186,7 @@ def validation_matcher_scenario_args

define_method :build_object do |options = {}, &block|
build_object_with_generic_attribute(
options.merge(column_type: :time, value: default_time),
**options.merge(column_type: :time, value: default_time),
&block
)
end
Expand All @@ -207,7 +207,7 @@ def validation_matcher_scenario_args

def build_object(**options, &block)
build_object_with_generic_attribute(
options.merge(column_type: :string),
**options.merge(column_type: :string),
&block
)
end
Expand Down Expand Up @@ -798,7 +798,7 @@ def configure_validation_matcher(matcher)

define_method :build_object do |options = {}, &block|
build_object_with_generic_attribute(
options.merge(column_type: :timestamp, value: now),
**options.merge(column_type: :timestamp, value: now),
&block
)
end
Expand Down Expand Up @@ -842,7 +842,7 @@ def validation_matcher_scenario_args

def build_object(**options, &block)
super(
options.merge(column_options: { null: true }, value: true),
**options.merge(column_options: { null: true }, value: true),
&block
)
end
Expand All @@ -863,13 +863,13 @@ def build_object(**options, &block)
end

def build_object(**options, &block)
super(options.merge(column_options: { null: false }), &block)
super(**options.merge(column_options: { null: false }), &block)
end
end

def build_object(**options, &block)
build_object_with_generic_attribute(
options.merge(column_type: :boolean),
**options.merge(column_type: :boolean),
&block
)
end
Expand All @@ -896,15 +896,15 @@ def validation_matcher_scenario_args
include_context 'against a boolean attribute for true and false'

def build_object(**options, &block)
build_object_with_generic_attribute(options.merge(value: true), &block)
build_object_with_generic_attribute(**options.merge(value: true), &block)
end
end

context 'against a boolean attribute (designated by false)' do
include_context 'against a boolean attribute for true and false'

def build_object(**options, &block)
build_object_with_generic_attribute(options.merge(value: false), &block)
build_object_with_generic_attribute(**options.merge(value: false), &block)
end
end

Expand Down Expand Up @@ -1010,7 +1010,7 @@ def define_model_validating_inclusion(
column_options: column_options,
}.compact

define_simple_model(model_options) do |model|
define_simple_model(**model_options) do |model|
if validation_options
model.validates_inclusion_of(attribute_name, validation_options)
end
Expand Down
Expand Up @@ -714,7 +714,7 @@ def create_child_model_belonging_to_parent(
define_model(:parent, parent_options)

define_model :child, parent_id: :integer do
belongs_to :parent, options
belongs_to :parent, **options

if block
class_eval(&block)
Expand Down Expand Up @@ -743,7 +743,7 @@ def belonging_to_with_inverse(association, inverse_association)

def belonging_to_non_existent_class(model_name, assoc_name, options = {})
define_model model_name, "#{assoc_name}_id" => :integer do
belongs_to assoc_name, options
belongs_to assoc_name, **options
end.new
end
end
Expand Down Expand Up @@ -1156,14 +1156,14 @@ def having_many_children(options = {})
order = options.delete(:order)
define_association_with_order(model, :has_many, :children, order, options)
else
model.has_many :children, options
model.has_many :children, **options
end
end.new
end

def having_many_non_existent_class(model_name, assoc_name, options = {})
define_model model_name do
has_many assoc_name, options
has_many assoc_name, **options
end.new
end
end
Expand Down Expand Up @@ -1494,14 +1494,14 @@ def having_one_detail(options = {})
order = options.delete(:order)
define_association_with_order(model, :has_one, :detail, order, options)
else
model.has_one :detail, options
model.has_one :detail, **options
end
end.new
end

def having_one_non_existent(model_name, assoc_name, options = {})
define_model model_name do
has_one assoc_name, options
has_one assoc_name, **options
end.new
end
end
Expand Down Expand Up @@ -2124,25 +2124,17 @@ def having_and_belonging_to_many_relatives(_options = {})

def having_and_belonging_to_many_non_existent_class(model_name, assoc_name, options = {})
define_model model_name do
has_and_belongs_to_many assoc_name, options
has_and_belongs_to_many assoc_name, **options
end.new
end
end

def define_association_with_conditions(model, macro, name, conditions, _other_options = {})
args = []
options = {}
args << proc { where(conditions) }
args << options
model.__send__(macro, name, *args)
model.__send__(macro, name, proc { where(conditions) }, **{})
end

def define_association_with_order(model, macro, name, order, _other_options = {})
args = []
options = {}
args << proc { order(order) }
args << options
model.__send__(macro, name, *args)
model.__send__(macro, name, proc { order(order) }, **{})
end

def dependent_options
Expand Down
Expand Up @@ -112,7 +112,7 @@ def model(options = {})

def with_table(column_name, column_type, options)
create_table 'employees' do |table|
table.__send__(column_type, column_name, options)
table.__send__(column_type, column_name, **options)
end
define_model_class('Employee').new
end
Expand Down