Rubinius skips calling `respond_to_missing?` in some circumstances #2845

myronmarston opened this Issue Dec 20, 2013 · 0 comments


None yet
1 participant
$ ruby -v
rubinius 2.2.1 (2.1.0 3ed43137 2013-11-17 JI) [x86_64-darwin12.5.0]

We're getting a build failure from rubinius for rspec-expectations for something that passes for all the other rubies we build against (MRI 1.8.7 - 2.1.0-preview2, JRuby in 1.8 and 1.9 mode and REE). I spent a while this morning trying to isolate it to a standalone script. I didn't quite get there but I've got an rspec-expectations branch that has easy repro steps to trigger the failure:

  • Clone rspec-expectations
  • bundle install
  • Checkout the rubinius-failure branch
  • Run bundle exec rspec spec/rspec/matchers/legacy_spec.rb -fp --seed 42356. You'll get the failure (with some logging output I added):
Run options: include {:focused=>true}

All examples were filtered out; ignoring {:focused=>true}
..#<RSpec::Expectations::LegacyMacherAdapter::RSpec2:0x1b8c0>.respond_to?(:does_not_match) = false


  1) Legacy matchers written using the RSpec 2.x `failure_message_for_should` and `failure_message_for_should_not` protocol behaves like a matcher written against a legacy protocol when matched negatively calls `does_not_match?` if it is defined on the matcher
     Failure/Error: expect(called).to be true

       expected true
            got #<FalseClass:10> => false
     Shared Example Group: "a matcher written against a legacy protocol" called from ./spec/rspec/matchers/legacy_spec.rb:45
     # ./lib/rspec/expectations/fail_with.rb:32:in `fail_with'
     # ./lib/rspec/expectations/handler.rb:38:in `handle_failure'
     # ./lib/rspec/expectations/handler.rb:49:in `handle_matcher'
     # ./lib/rspec/expectations/expectation_target.rb:29:in `to'
     # ./spec/rspec/matchers/legacy_spec.rb:33:in `__script__'
  • Run bundle exec rspec spec/rspec/matchers/legacy_spec.rb:25 -fp --seed 42356 (to isolate the run to just the failing spec). Notice that it passes:
Run options: include {:locations=>{"./spec/rspec/matchers/legacy_spec.rb"=>[25]}}
#<RSpec::Expectations::LegacyMacherAdapter::RSpec2:0x1b830>.respond_to?(:does_not_match) = true

Finished in 0.00767 seconds
1 example, 0 failures

Randomized with seed 42356

Notice that in this case respond_to_missing? is being called (logged here), but in the first place it's not. Rubinius appears to wrongly cache something that causes it to not check respond_to_missing? when it should.

Let me know if you need anything else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment