diff options
author | Peter Boling <peter.boling@gmail.com> | 2015-10-18 22:16:47 -0700 |
---|---|---|
committer | Peter Boling <peter.boling@gmail.com> | 2015-10-18 22:16:47 -0700 |
commit | a44dd9a2687055d0074f8e71f1c50e3096ee846b (patch) | |
tree | 257d5a08faae8e6e02555f086a7f5cfc6b2b4d15 | |
parent | 21780ddeabc7432331f0fe48722153aba15ba872 (diff) | |
download | hashie-a44dd9a2687055d0074f8e71f1c50e3096ee846b.tar.gz |
- Restrict pending the spec to only Ruby versions 2.2.0, 2.2.1, 2.2.2
- Better paradigm for pending specs due to bugs in interpreter
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | spec/hashie/mash_spec.rb | 4 | ||||
-rw-r--r-- | spec/support/ruby_version.rb | 61 |
3 files changed, 57 insertions, 9 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index f8b48ce..1d1ba16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * [#304](https://github.com/intridea/hashie/pull/304): Ensured compatibility of `Hash` extensions with singleton objects - [@regexident](https://github.com/regexident). * [#306](https://github.com/intridea/hashie/pull/306): Added `Hashie::Extensions::Dash::Coercion` - [@marshall-lee](https://github.com/marshall-lee). * [#310](https://github.com/intridea/hashie/pull/310): Fixed `Hashie::Extensions::SafeAssignment` bug with private methods - [@marshall-lee](https://github.com/marshall-lee). +* [#313](https://github.com/intridea/hashie/pull/313): Restrict pending spec to only Ruby versions 2.2.0-2.2.2 - [@pboling](https://github.com/pboling). ## 3.4.2 (6/2/2015) diff --git a/spec/hashie/mash_spec.rb b/spec/hashie/mash_spec.rb index c405f2a..213c47f 100644 --- a/spec/hashie/mash_spec.rb +++ b/spec/hashie/mash_spec.rb @@ -364,9 +364,7 @@ describe Hashie::Mash do it 'is able to access an unknown suffixed key as a method' do # See https://github.com/intridea/hashie/pull/285 for more information - if mri22? - pending 'Bug in MRI 2.2.x means this behavior is broken in those versions' - end + pending_for(engine: 'ruby', versions: %w(2.2.0 2.2.1 2.2.2)) %w(= ? ! _).each do |suffix| expect(subject.method(:"xyz#{suffix}")).to_not be_nil diff --git a/spec/support/ruby_version.rb b/spec/support/ruby_version.rb index e8c53c5..7642e77 100644 --- a/spec/support/ruby_version.rb +++ b/spec/support/ruby_version.rb @@ -1,10 +1,59 @@ -def mri22? - ruby_version.start_with?('ruby_2.2') +# How to pend specs that break due to bugs in Ruby interpreters or versions +# +# it("blah is blah") do +# pending_for(engine: 'jruby', version: '2.2.2') +# expect('blah').to eq 'blah' +# end +# +def pending_for(options = {}) # Not using named parameters because still supporting Ruby 1.9 + fail ArgumentError, 'pending_for requires at least an engine or versions to be specified' unless + options[:engine] || options[:versions] + current_engine, current_version = ruby_engine_and_version + versions_to_pend = Array(options[:versions]) # cast to array + engine_to_pend = options[:engine] + broken = 'This behavior is broken' + bug = 'due to a bug in the Ruby engine' + # If engine is nil, then any matching versions should be pended + if engine_to_pend.nil? + pending "#{broken} in Ruby versions #{versions_to_pend} #{bug}" if + versions_to_pend.include?(current_version) + elsif engine_to_pend == current_engine + if versions_to_pend.empty? + pending "#{broken} #{bug} #{INTERPRETER_MATRIX[engine_to_pend]}" + else + pending %[#{broken} in Ruby versions #{versions_to_pend} #{bug} (#{INTERPRETER_MATRIX[engine_to_pend]})] if + versions_to_pend.include?(current_version) + end + end end -def ruby_version - interpreter = Object.const_defined?(:RUBY_ENGINE) && RUBY_ENGINE - version = Object.const_defined?(:RUBY_VERSION) && RUBY_VERSION +# +# | RUBY_ENGINE | Implementation | +# |:-----------:|:-----------------:| +# | <undefined> | MRI < 1.9 | +# | 'ruby' | MRI >= 1.9 or REE | +# | 'jruby' | JRuby | +# | 'macruby' | MacRuby | +# | 'rbx' | Rubinius | +# | 'maglev' | MagLev | +# | 'ironruby' | IronRuby | +# | 'cardinal' | Cardinal | +# - "#{interpreter}_#{version}" +INTERPRETER_MATRIX = { + nil => 'MRI < 1.9', + 'ruby' => 'MRI >= 1.9 or REE', + 'jruby' => 'JRuby', + 'macruby' => 'MacRuby', + 'rbx' => 'Rubinius', + 'maglev' => 'MagLev', + 'ironruby' => 'IronRuby', + 'cardinal' => 'Cardinal' +} + +def ruby_engine_and_version + current_engine = Object.const_defined?(:RUBY_ENGINE) && RUBY_ENGINE + current_version = Object.const_defined?(:RUBY_VERSION) && RUBY_VERSION + + [current_engine, current_version] end |