Permalink
Browse files

Works in JRuby 1.8 and 1.9 and MRI 1.8.7 and 1.9.2

  • Loading branch information...
1 parent 76457c2 commit e62e1a5f0360ea4219e759f432061446a244a7f3 Darrick Wiebe committed Sep 21, 2011
Showing with 9 additions and 6 deletions.
  1. +1 −0 .gitignore
  2. +1 −1 lib/nested_exceptions.rb
  3. +7 −5 spec/nested_exceptions_spec.rb
View
@@ -2,3 +2,4 @@
.bundle
Gemfile.lock
pkg/*
+bin
View
@@ -10,7 +10,7 @@ def initialize(message = nil, cause = nil)
super(message)
end
- if RUBY_ENGINE == 'jruby'
+ if Object.const_defined? :RUBY_ENGINE and RUBY_ENGINE == 'jruby'
def backtrace
return @processed_backtrace if defined? @processed_backtrace and @processed_backtrace
@processed_backtrace = process_backtrace(super)
@@ -33,17 +33,19 @@ def double_bug
describe NestedExceptions do
let(:ex) { ErrorSpec::Example.new }
- let(:in_rescue) do
- if RUBY_ENGINE == 'jruby'
- in_rescue = ''
+ def in_rescue
+ if Object.const_defined? :RUBY_ENGINE and RUBY_ENGINE == 'jruby'
+ ''
+ elsif RUBY_VERSION =~ /^1\.[0-8]\./
+ ''
else
in_rescue = 'rescue in '
end
end
it 'should create a stack trace correctly' do
stack = raise rescue $!.backtrace
- stack.first.should =~ /#{__FILE__}:#{__LINE__ - 1}:in `(\(root\)|block \(2 levels\) in <top \(required\)>)'/
+ stack.first.should =~ /#{__FILE__}:#{__LINE__ - 1}/
end
describe 'normal StandardError' do
@@ -87,7 +89,7 @@ def double_bug
"#{__FILE__}:13:in `nested_bug'",
"#{__FILE__}:17:in `problem'",
"#{__FILE__}:23:in `nested_problem'",
- "#{__FILE__}:27:in `double_bug'",
+ "#{__FILE__}:27:in `double_bug'"
] + @stack
end
end

0 comments on commit e62e1a5

Please sign in to comment.