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

Commit 81b3d13

Browse files
committed
Fix build for JRuby 9.2.x.x
1 parent 08ef2ee commit 81b3d13

File tree

2 files changed

+36
-12
lines changed

2 files changed

+36
-12
lines changed

spec/integration/suite_hooks_errors_spec.rb

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
let(:failure_exit_code) { rand(97) + 2 } # 2..99
99
let(:error_exit_code) { failure_exit_code + 2 } # 4..101
1010

11-
if RSpec::Support::Ruby.jruby_9000?
11+
if RSpec::Support::Ruby.jruby_9000? && RSpec::Support::Ruby.jruby_version > '9.2.0.0'
12+
let(:spec_line_suffix) { ":in `block in <main>'" }
13+
elsif RSpec::Support::Ruby.jruby_9000?
1214
let(:spec_line_suffix) { ":in `block in (root)'" }
1315
elsif RSpec::Support::Ruby.jruby?
1416
let(:spec_line_suffix) { ":in `(root)'" }
@@ -97,6 +99,19 @@ def run_spec_expecting_non_zero(before_or_after)
9799
end
98100
"
99101

102+
cause =
103+
if RSpec::Support::Ruby.jruby_9000? && RSpec::Support::Ruby.jruby_version > '9.2.0.0'
104+
unindent(<<-EOS)
105+
# ------------------
106+
# --- Caused by: ---
107+
# RuntimeError:
108+
# before 1
109+
# ./the_spec.rb:3:in `block in <main>'
110+
EOS
111+
else
112+
""
113+
end
114+
100115
run_command "the_spec.rb"
101116
expect(last_cmd_exit_status).to eq(error_exit_code)
102117
output = normalize_durations(last_cmd_stdout)
@@ -116,14 +131,14 @@ def run_spec_expecting_non_zero(before_or_after)
116131
RuntimeError:
117132
after 2
118133
# ./the_spec.rb:6#{spec_line_suffix}
119-
134+
#{ cause }
120135
An error occurred in an `after(:suite)` hook.
121136
Failure/Error: c.after(:suite) { raise 'after 1' }
122137
123138
RuntimeError:
124139
after 1
125140
# ./the_spec.rb:5#{spec_line_suffix}
126-
141+
#{ cause }
127142
128143
Finished in n.nnnn seconds (files took n.nnnn seconds to load)
129144
0 examples, 0 failures, 3 errors occurred outside of examples

spec/rspec/core/notifications_spec.rb

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ def normalize_backtraces(failure)
6666
end
6767

6868
def normalize_one_backtrace(exception)
69+
if RSpec::Support::Ruby.jruby_9000? && RSpec::Support::Ruby.jruby_version >= '9.2.0.0'
70+
pending "On JRuby 9.2.x.x these specs are broken due to no backtrace."
71+
end
6972
line = exception.backtrace.find { |l| l.include?(__FILE__) }
7073
exception.set_backtrace([ line.sub(/:in .*$/, '') ])
7174
end
@@ -117,16 +120,22 @@ def normalize_one_backtrace(exception)
117120
end
118121

119122
context "due to using `:aggregate_failures` metadata" do
120-
let(:exception) do
121-
ex = nil
122-
RSpec.describe do
123-
ex = it "", :aggregate_failures do
124-
expect(1).to fail_with_description("foo")
125-
expect(1).to fail_with_description("bar")
126-
end
127-
end.run
123+
if RSpec::Support::Ruby.jruby_9000? && RSpec::Support::Ruby.jruby_version >= '9.2.0.0'
124+
let(:exception) do
125+
pending "On JRuby 9.2.x.x these specs are broken due to no backtrace."
126+
end
127+
else
128+
let(:exception) do
129+
ex = nil
130+
RSpec.describe do
131+
ex = it "", :aggregate_failures do
132+
expect(1).to fail_with_description("foo")
133+
expect(1).to fail_with_description("bar")
134+
end
135+
end.run
128136

129-
capture_and_normalize_aggregation_error { raise ex.execution_result.exception }
137+
capture_and_normalize_aggregation_error { raise ex.execution_result.exception }
138+
end
130139
end
131140

132141
it 'uses an alternate format for the exception summary to avoid confusing references to the aggregation block or stack trace' do

0 commit comments

Comments
 (0)