-
-
Notifications
You must be signed in to change notification settings - Fork 395
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
Is there a way to not "inspect" the expected output when it fails? #1188
Comments
Sorry for the delay, it took me a while to get to the response form through that log. Would you agree to make a slight change in your spec? - expect(output).not_to include "bad yarn binstub"
+ expect(output.include?("bad yarn binstub")).not_to be true If it's not possible due to strict styling rules, you may give |
👋 @schneems if turning off truncation (by setting |
Literally the shortest amount of time i've waiting on an OSS issue asking about a random thing. Thanks a ton! The problem with:
Is then I get no ouput. It would say something like "expected true to be false". I want all the output, but instead of
I would like the ability to tell rspec to give me the raw output rather than I'm already using some other pretty deeply hooked plugins for this project like https://github.com/Shopify/ci-queue which have tended to interact with other plugins in a not-always-predictable-way. If a custom formatter wasn't too hard I would probably adopt that approach.
Ahh, that's a good tip. I was setting it to Thanks for all your work here! |
Ah, sorry, I've misread your original problem.
For a spec: RSpec.describe do
it do
long = <<~LONG
not here
neither here
LONG
expect(long).to include 'rare'
end
end I'm getting this failure locally:
which includes an expectation, a formatted output and a diff. I've intentionally set a low limit for the output: RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.max_formatted_output_length = 20
end
end If you change - expect(long).to include 'rare'
+ expect(long * 100).to include 'rare' the diff gets longer as well. Do you have the diff part in your output? |
If nothing else works you may pass the expect(long).to(include('rare'), long)
# or
expect(output).not_to(include("bad yarn binstub"), output) |
While reading the code of I found this snippet that may help you Richard: def assert_execute(*command)
stdout, stderr, status = Open3.capture3(*command)
command_to_show = command.map { |c| c.gsub(Dir.pwd, '.') }.shelljoin
on_failure = -> {
# Show output directly since RSpec truncates long output
puts "\n\n#{'=' * 100}"
puts "Failed to execute:\n#{command_to_show}"
puts "\nstdout:\n```\n#{stdout}```\n\nstderr:\n```\n#{stderr}```\n\n\n"
"Failed to execute: #{command_to_show}"
}
expect(status.success?).to eq(true), on_failure
if ENV.key?('VERBOSE')
puts "\n```\n$ #{command_to_show}\n#{stdout}```\n\n"
end
unless stderr.empty?
$stderr.puts "stderr:\n```\n#{stderr}```"
end
end |
@schneems Have managed to solve the problem? Do you think there's anything we can help you with? |
I guess we'll close this for now. |
I'm using rspec to test build deploys which are very verbose. I want the full output when it fails because it's very valuable for debugging, but when an expectation fails it looks like it is "inspect"-ed so it shows up with newlines like this and is largely unreadable:
Is there a config for disabling calling inspect on the input?
The text was updated successfully, but these errors were encountered: