Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 2724883

Browse files
committed
Merge pull request #322 from rspec/refactor_jruby_fix
Refactor the workaround for JRuby 1.7.4
2 parents a27fc90 + a457df0 commit 2724883

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/rspec/mocks/syntax.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,19 @@ def self.expect_enabled?(syntax_host = ::RSpec::Mocks::ExampleMethods)
155155
# @api private
156156
# Determines where the methods like `should_receive`, and `stub` are added.
157157
def self.default_should_syntax_host
158+
# JRuby 1.7.4 introduces a regression whereby `defined?(::BasicObject) => nil`
159+
# yet `BasicObject` still exists and patching onto ::Object breaks things
160+
# e.g. SimpleDelegator expectations won't work
161+
#
162+
# See: https://github.com/jruby/jruby/issues/814
163+
if defined?(JRUBY_VERSION) && JRUBY_VERSION == '1.7.4' && RUBY_VERSION.to_f > 1.8
164+
return ::BasicObject
165+
end
166+
158167
# On 1.8.7, Object.ancestors.last == Kernel but
159168
# things blow up if we include `RSpec::Mocks::Methods`
160169
# into Kernel...not sure why.
161-
return Object unless defined?(::BasicObject) || (RUBY_PLATFORM == 'java' && RUBY_VERSION.to_f > 1.8)
170+
return Object unless defined?(::BasicObject)
162171

163172
# MacRuby has BasicObject but it's not the root class.
164173
return Object unless Object.ancestors.last == ::BasicObject

0 commit comments

Comments
 (0)