Closed c-lliope closed 10 years ago
I had to delete two specs that just weren't compatible with JRuby:
context "when is called from a block" do
it "prints the indication of a block" do
expect(test_output).to receive(:puts).twice.
with(/from block/)
Caller.new.call_method_inside_block(null)
end
end
context "when is called from many levels blocks" do
it "prints the indication of blocks and its levels" do
expect(test_output).to receive(:puts).exactly(4).times.
with(/from block \(2 levels\)/)
Caller.new.call_method_inside_nested_block(null)
end
end
They were failing because JRuby (and RBX) don't give a clear indication of blocks in their stacktrace.
As an example, the following code:
def foo
2.times { raise 'ohno' }
end
foo
when run in the three different environments, give these stack traces:
MRI:
RuntimeError: ohno
from (irb):2:in `block in foo'
from (irb):2:in `times'
from (irb):2:in `foo'
from (irb):4
JRuby:
RuntimeError: ohno
from (irb):2:in `foo'
from org/jruby/RubyFixnum.java:280:in `times'
from (irb):2:in `foo'
from (irb):4:in `evaluate'
...
RBX:
RuntimeError: ohno
from (irb):2:in `foo'
from kernel/common/integer.rb:83:in `times'
from (irb):2:in `foo'
from (irb):4
...
They all give similar information, but the specs are looking for a specific indication that the call is coming from inside a block.
I don't think it's really necessary for Pebble to collect detailed information on the blocks, so I decided to scrap those specs. Pebbles will collect slightly less information on JRuby/RBX, but still capture the method name that the pebble was called from, etc.
Let me know if you think those specs were necessary.
Looks like @sferik has included JRuby support in his 1.8 compatibility PR. Thanks for getting the ball rolling!
See the comments on https://github.com/avdi/naught/pull/27