Skip to content

Commit 6e296e6

Browse files
authored
Merge pull request #2321 from agrobbin/system-example-group-extra-failure-lines-array
Indent all extra failure lines correctly in system tests
2 parents 0896526 + b7741f2 commit 6e296e6

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Diff for: lib/rspec/rails/example/system_example_group.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ def driven_by(driver, **driver_options, &blk)
114114
original_after_teardown.bind(self).call
115115
ensure
116116
myio = $stdout
117-
RSpec.current_example.metadata[:extra_failure_lines] = myio.string
117+
myio.rewind
118+
RSpec.current_example.metadata[:extra_failure_lines] = myio.readlines
118119
$stdout = orig_stdout
119120
end
120121
end

Diff for: spec/rspec/rails/example/system_example_group_spec.rb

+22
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,28 @@ module RSpec::Rails
5858
expect(example).to have_received(:driven_by).once
5959
end
6060
end
61+
62+
describe '#after' do
63+
it 'sets the :extra_failure_lines metadata to an array of STDOUT lines' do
64+
group = RSpec::Core::ExampleGroup.describe do
65+
include SystemExampleGroup
66+
67+
before do
68+
driven_by(:selenium)
69+
end
70+
71+
def take_screenshot
72+
puts 'line 1'
73+
puts 'line 2'
74+
end
75+
end
76+
example = group.it('fails') { fail }
77+
78+
group.run
79+
80+
expect(example.metadata[:extra_failure_lines]).to eq(["line 1\n", "line 2\n"])
81+
end
82+
end
6183
end
6284
end
6385
end

0 commit comments

Comments
 (0)