Support Ruby 2.4.0 (#389)

This commit is contained in:
Masahiro Saito 2017-01-06 21:45:16 +09:00 committed by Daniel Doubrovkine (dB.) @dblockdotorg
parent 199d816bc0
commit 87582b589f
5 changed files with 24 additions and 7 deletions

View File

@ -3,6 +3,7 @@ sudo: false
cache: bundler
rvm:
- 2.4.0
- 2.3.0
- 2.2.3
- 2.1.7

View File

@ -9,6 +9,7 @@ scheme are considered to be bugs.
## [Unreleased][unreleased]
* [#386](https://github.com/intridea/hashie/pull/386): Fix for #385: Make `deep_merge` always `deep_dup` nested hashes before merging them in so that there are no shared references between the two hashes being merged. - [@mltsy](https://github.com/mltsy).
* [#389](https://github.com/intridea/hashie/pull/389): Support Ruby 2.4.0 - [@camelmasa](https://github.com/camelmasa).
[3.4.7]: https://github.com/intridea/hashie/compare/v3.4.6...master

View File

@ -12,7 +12,12 @@ end
group :test do
# ActiveSupport required to test compatibility with ActiveSupport Core Extensions.
gem 'activesupport', '~> 4.x', require: false
require File.expand_path('../lib/hashie/extensions/ruby_version', __FILE__)
if Hashie::Extensions::RubyVersion.new(RUBY_VERSION) >= Hashie::Extensions::RubyVersion.new('2.4.0')
gem 'activesupport', '~> 5.x', require: false
else
gem 'activesupport', '~> 4.x', require: false
end
gem 'codeclimate-test-reporter', '~> 1.0', require: false
gem 'rspec-core', '~> 3.1.7'
gem 'danger-changelog', '~> 0.1.0', require: false

View File

@ -12,10 +12,14 @@ module Hashie
Symbol => :to_sym
}
ABSTRACT_CORE_TYPES = {
Integer => [Fixnum, Bignum],
Numeric => [Fixnum, Bignum, Float, Complex, Rational]
}
ABSTRACT_CORE_TYPES = if RubyVersion.new(RUBY_VERSION) >= RubyVersion.new('2.4.0')
{ Numeric => [Integer, Float, Complex, Rational] }
else
{
Integer => [Fixnum, Bignum],
Numeric => [Fixnum, Bignum, Float, Complex, Rational]
}
end
def self.included(base)
base.send :include, InstanceMethods

View File

@ -558,8 +558,14 @@ describe Hashie::Extensions::Coercion do
end
it 'raises a CoercionError when coercion is not possible' do
subject.coerce_value Fixnum, Symbol
expect { instance[:hi] = 1 }.to raise_error(Hashie::CoercionError, /Cannot coerce property :hi from Fixnum to Symbol/)
type = if Hashie::Extensions::RubyVersion.new(RUBY_VERSION) >= Hashie::Extensions::RubyVersion.new('2.4.0')
Integer
else
Fixnum
end
subject.coerce_value type, Symbol
expect { instance[:hi] = 1 }.to raise_error(Hashie::CoercionError, /Cannot coerce property :hi from #{type} to Symbol/)
end
it 'coerces Integer to String' do