Skip to content

Commit 9ae56ba

Browse files
authored
BigDecimal required; test fixes for ruby 3 (#408)
1 parent 8df1675 commit 9ae56ba

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

Appraisals

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ end
2929

3030
appraise 'mongoid-5.0' do
3131
gem 'mongoid', '~> 5.0.0'
32+
gem 'bigdecimal', '~> 1.3.5'
3233
end
3334

3435
appraise 'mongoid-6.0' do

gemfiles/mongoid_5.0.gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
source "https://rubygems.org"
44

55
gem "mongoid", "~> 5.0.0"
6+
gem "bigdecimal", "~> 1.3.5"
67

78
gemspec path: "../"

spec/ext/active_record_spec.rb

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,25 +218,43 @@ class SubUser < User {
218218
# spec 1
219219
out = @ap.awesome(User.methods.grep(/first/))
220220

221-
if ActiveRecord::VERSION::STRING >= '3.2'
222-
expect(out).to match(/\sfirst\(\*arg.*?\)\s+User/)
221+
if RUBY_VERSION >= '3.0.0'
222+
expect(out).to match(/\sfirst\(\*\*,\s&&\)/)
223+
elsif RUBY_VERSION >= '2.7.0'
224+
if ActiveRecord::VERSION::STRING >= '3.2'
225+
expect(out).to match(/\sfirst\(\*\*,\s&&\)\s+User/)
226+
else
227+
expect(out).to match(/\sfirst\(\*\*,\s&&\)\s+User \(ActiveRecord::Base\)/)
228+
end
223229
else
224-
expect(out).to match(/\sfirst\(\*arg.*?\)\s+User \(ActiveRecord::Base\)/)
230+
if ActiveRecord::VERSION::STRING >= '3.2'
231+
expect(out).to match(/\sfirst\(\*arg.*?\)\s+User/)
232+
else
233+
expect(out).to match(/\sfirst\(\*arg.*?\)\s+User \(ActiveRecord::Base\)/)
234+
end
225235
end
226236

227237
# spec 2
228238
out = @ap.awesome(User.methods.grep(/primary_key/))
229-
expect(out).to match(/\sprimary_key\(.*?\)\s+User/)
239+
if RUBY_VERSION >= '3.0.0'
240+
expect(out).to match(/\sprimary_key\(.*?\)/)
241+
else
242+
expect(out).to match(/\sprimary_key\(.*?\)\s+User/)
243+
end
230244

231245
# spec 3
232246
out = @ap.awesome(User.methods.grep(/validate/))
233-
234247
if ActiveRecord::VERSION::MAJOR < 3
235248
expect(out).to match(/\svalidate\(\*arg.*?\)\s+User \(ActiveRecord::Base\)/)
236249
else
237-
expect(out).to match(/\svalidate\(\*arg.*?\)\s+User/)
250+
if RUBY_VERSION >= '3.0.0'
251+
expect(out).to match(/\svalidate\(\*arg.*?\)/)
252+
else
253+
expect(out).to match(/\svalidate\(\*arg.*?\)\s+User/)
254+
end
238255
end
239256

240257
end
241258
end
242259
end
260+

0 commit comments

Comments
 (0)