Test failure on JRuby 1.6.0 #44

kaiwren opened this Issue Mar 22, 2011 · 3 comments


None yet
3 participants

kaiwren commented Mar 22, 2011

Running rake for rspec-mocks against Jruby-1.6.0 on OSX against ef127a5 has nil_expectation_warning_spec.rb fail with the trace given at the end of this ticket.

The failure seems to be occurring because jruby returns a failure trace with
Called from #{FILE}:#{LINE+3}:in (class Mocks)' instead of what CRuby returns which is Called from #{__FILE__}:#{__LINE__+3}(:inblock (2 levels) in module:Mocks

These strings are generated by caller[4] so this might actually be a JRuby issue (which I will check and confirm).

1) an expectation set on nil issues a warning with file and line number information
Failure/Error: nil.should_receive(:foo)
Kernel received :warn with unexpected arguments
expected: (/An expectation of :foo was set on nil. Called from /Users/sidu/Work/Rspec/rspec-mocks/spec/rspec/mocks/nil_expectation_warning_spec.rb:21(:in block \(2 levels\) in <module:Mocks>')?. Use allow_message_expectations_on_nil to disable warnings./) got: ("An expectation of :foo was set on nil. Called from /Users/sidu/Work/Rspec/rspec-mocks/spec/rspec/mocks/nil_expectation_warning_spec.rb:21:in(class Mocks)'. Use allow_message_expectations_on_nil to disable warnings.")
# ./spec/rspec/mocks/nil_expectation_warning_spec.rb:21:in (class Mocks)' # org/jruby/RubyKernel.java:2007:ininstance_eval'
# org/jruby/RubyArray.java:2306:in collect' # org/jruby/RubyArray.java:2306:incollect'

headius commented Mar 22, 2011

This is going too far. The format of caller lines is going to differ across Ruby impls and potentially even across Ruby versions. If RSpec is looking for that exact format of line, I believe it is asking too much.

Where's the code that wants caller lines formatted this way?


kaiwren commented Mar 22, 2011

Submitted pull-request. See #45.


kaiwren commented Mar 23, 2011

Not so dependent on a particular ruby implementation. Closed by 8e2c1a2 Closed by 8e2c1a2

justinko closed this Mar 23, 2011

@myronmarston myronmarston pushed a commit to myronmarston/rspec-mocks that referenced this issue Oct 21, 2012

@kaiwren @justinko kaiwren + justinko Not so dependent on a particular ruby implementation. Closes #44 Closes 8e2c1a2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment