Skip to content

Commit

Permalink
Merge pull request #2321 from agrobbin/system-example-group-extra-fai…
Browse files Browse the repository at this point in the history
…lure-lines-array

Indent all extra failure lines correctly in system tests
  • Loading branch information
JonRowe committed May 19, 2020
1 parent 21622d8 commit 529f936
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rspec/rails/example/system_example_group.rb
Expand Up @@ -114,7 +114,8 @@ def driven_by(driver, **driver_options, &blk)
original_after_teardown.bind(self).call
ensure
myio = $stdout
RSpec.current_example.metadata[:extra_failure_lines] = myio.string
myio.rewind
RSpec.current_example.metadata[:extra_failure_lines] = myio.readlines
$stdout = orig_stdout
end
end
Expand Down
22 changes: 22 additions & 0 deletions spec/rspec/rails/example/system_example_group_spec.rb
Expand Up @@ -58,6 +58,28 @@ module RSpec::Rails
expect(example).to have_received(:driven_by).once
end
end

describe '#after' do
it 'sets the :extra_failure_lines metadata to an array of STDOUT lines' do
group = RSpec::Core::ExampleGroup.describe do
include SystemExampleGroup

before do
driven_by(:selenium)
end

def take_screenshot
puts 'line 1'
puts 'line 2'
end
end
example = group.it('fails') { fail }

group.run

expect(example.metadata[:extra_failure_lines]).to eq(["line 1\n", "line 2\n"])
end
end
end
end
end

0 comments on commit 529f936

Please sign in to comment.