Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indent all extra failure lines correctly in system tests #2321

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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