mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
Add Ruby 3.0 support (#1427)
* Fix warning: Using the last argument as keyword parameters is deprecated * Add ruby 3.0 support * Update listen to support ruby 3.0 * Prevent CI testing Ruby 3.0 with Rails 5.x * Fix action/cache key * Update nokogiri * Use Ruby 3.0.1 for development * Remove webdrivers gem
This commit is contained in:
parent
21bc474674
commit
8dea981df0
14 changed files with 42 additions and 45 deletions
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
|
@ -27,6 +27,7 @@ jobs:
|
|||
fail-fast: false
|
||||
matrix:
|
||||
ruby:
|
||||
- 3.0.1
|
||||
- 2.7.2
|
||||
- 2.6.6
|
||||
appraisal:
|
||||
|
@ -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
|
||||
|
@ -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)) }}
|
||||
- name: Install dependencies
|
||||
run: bundle install --jobs=3 --retry=3
|
||||
- name: Run Unit Tests
|
||||
|
|
|
@ -1 +1 @@
|
|||
2.7.2
|
||||
3.0.1
|
||||
|
|
|
@ -1 +1 @@
|
|||
ruby 2.7.2
|
||||
ruby 3.0.1
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -82,7 +82,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)
|
||||
|
@ -90,7 +90,7 @@ GEM
|
|||
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)
|
||||
|
@ -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
|
||||
|
|
|
@ -82,6 +82,7 @@ module AcceptanceTests
|
|||
bundle.remove_gem 'uglifier'
|
||||
bundle.remove_gem 'debugger'
|
||||
bundle.remove_gem 'byebug'
|
||||
bundle.remove_gem 'webdrivers'
|
||||
bundle.remove_gem 'web-console'
|
||||
end
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ module UnitTests
|
|||
)
|
||||
end
|
||||
|
||||
table.column(column_name, column_type, column_options)
|
||||
table.column(column_name, column_type, **column_options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -44,7 +44,7 @@ module UnitTests
|
|||
|
||||
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
|
||||
|
|
|
@ -21,7 +21,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|||
|
||||
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
|
||||
|
@ -45,7 +45,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|||
|
||||
def build_object(**options, &block)
|
||||
build_object_with_generic_attribute(
|
||||
options.merge(
|
||||
**options.merge(
|
||||
column_type: :integer,
|
||||
column_options: { limit: 2 },
|
||||
value: 1,
|
||||
|
@ -71,7 +71,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|||
|
||||
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
|
||||
|
@ -99,7 +99,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|||
|
||||
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
|
||||
|
@ -130,7 +130,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|||
|
||||
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
|
||||
|
@ -158,7 +158,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|||
|
||||
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
|
||||
|
@ -186,7 +186,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|||
|
||||
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
|
||||
|
@ -207,7 +207,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|||
|
||||
def build_object(**options, &block)
|
||||
build_object_with_generic_attribute(
|
||||
options.merge(column_type: :string),
|
||||
**options.merge(column_type: :string),
|
||||
&block
|
||||
)
|
||||
end
|
||||
|
@ -798,7 +798,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|||
|
||||
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
|
||||
|
@ -842,7 +842,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|||
|
||||
def build_object(**options, &block)
|
||||
super(
|
||||
options.merge(column_options: { null: true }, value: true),
|
||||
**options.merge(column_options: { null: true }, value: true),
|
||||
&block
|
||||
)
|
||||
end
|
||||
|
@ -863,13 +863,13 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|||
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
|
||||
|
@ -896,7 +896,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|||
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
|
||||
|
||||
|
@ -904,7 +904,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|||
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
|
||||
|
||||
|
@ -1010,7 +1010,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|||
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
|
||||
|
|
|
@ -714,7 +714,7 @@ describe Shoulda::Matchers::ActiveRecord::AssociationMatcher, type: :model do
|
|||
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)
|
||||
|
@ -743,7 +743,7 @@ describe Shoulda::Matchers::ActiveRecord::AssociationMatcher, type: :model do
|
|||
|
||||
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
|
||||
|
@ -1156,14 +1156,14 @@ Expected Parent to have a has_many association called children through conceptio
|
|||
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
|
||||
|
@ -1494,14 +1494,14 @@ Expected Parent to have a has_many association called children through conceptio
|
|||
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
|
||||
|
@ -2124,25 +2124,17 @@ Expected Person to have a has_and_belongs_to_many association called relatives (
|
|||
|
||||
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
|
||||
|
|
|
@ -112,7 +112,7 @@ describe Shoulda::Matchers::ActiveRecord::HaveDbColumnMatcher, type: :model do
|
|||
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue