Skip to content

Commit

Permalink
BigDecimal required; test fixes for ruby 3 (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanH authored Mar 2, 2021
1 parent 8df1675 commit 9ae56ba
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
1 change: 1 addition & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ end

appraise 'mongoid-5.0' do
gem 'mongoid', '~> 5.0.0'
gem 'bigdecimal', '~> 1.3.5'
end

appraise 'mongoid-6.0' do
Expand Down
1 change: 1 addition & 0 deletions gemfiles/mongoid_5.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
source "https://rubygems.org"

gem "mongoid", "~> 5.0.0"
gem "bigdecimal", "~> 1.3.5"

gemspec path: "../"
30 changes: 24 additions & 6 deletions spec/ext/active_record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,25 +218,43 @@ class SubUser < User {
# spec 1
out = @ap.awesome(User.methods.grep(/first/))

if ActiveRecord::VERSION::STRING >= '3.2'
expect(out).to match(/\sfirst\(\*arg.*?\)\s+User/)
if RUBY_VERSION >= '3.0.0'
expect(out).to match(/\sfirst\(\*\*,\s&&\)/)
elsif RUBY_VERSION >= '2.7.0'
if ActiveRecord::VERSION::STRING >= '3.2'
expect(out).to match(/\sfirst\(\*\*,\s&&\)\s+User/)
else
expect(out).to match(/\sfirst\(\*\*,\s&&\)\s+User \(ActiveRecord::Base\)/)
end
else
expect(out).to match(/\sfirst\(\*arg.*?\)\s+User \(ActiveRecord::Base\)/)
if ActiveRecord::VERSION::STRING >= '3.2'
expect(out).to match(/\sfirst\(\*arg.*?\)\s+User/)
else
expect(out).to match(/\sfirst\(\*arg.*?\)\s+User \(ActiveRecord::Base\)/)
end
end

# spec 2
out = @ap.awesome(User.methods.grep(/primary_key/))
expect(out).to match(/\sprimary_key\(.*?\)\s+User/)
if RUBY_VERSION >= '3.0.0'
expect(out).to match(/\sprimary_key\(.*?\)/)
else
expect(out).to match(/\sprimary_key\(.*?\)\s+User/)
end

# spec 3
out = @ap.awesome(User.methods.grep(/validate/))

if ActiveRecord::VERSION::MAJOR < 3
expect(out).to match(/\svalidate\(\*arg.*?\)\s+User \(ActiveRecord::Base\)/)
else
expect(out).to match(/\svalidate\(\*arg.*?\)\s+User/)
if RUBY_VERSION >= '3.0.0'
expect(out).to match(/\svalidate\(\*arg.*?\)/)
else
expect(out).to match(/\svalidate\(\*arg.*?\)\s+User/)
end
end

end
end
end

0 comments on commit 9ae56ba

Please sign in to comment.