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

Add support for have_output* with no arguments #600

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

peagha
Copy link

@peagha peagha commented Mar 13, 2019

Summary

Allow have_output* matchers to work with no arguments

Details

When using the have_output* matchers they will fail to match if no argument is provided:

expect(last_command_stopped).not_to have_output_in_stdout

The documentation has examples like that:

# RSpec.describe do
# it { expect(last_command_started).to have_output_on_stderr }
# end

# RSpec.describe do
# it { expect(last_command_started).to have_output }
# end

How Has This Been Tested?

RSpec examples were added to cover the changes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring (cleanup of codebase without changing any existing functionality)
  • Update documentation

Checklist:

  • I've added tests for my code
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

TODO:

  • Fix failure message

@peagha
Copy link
Author

peagha commented Mar 13, 2019

I've noticed the failure message is not working properly; I'll fix that and push again

@mvz
Copy link
Contributor

mvz commented Mar 13, 2019

Hi @peagha, you seem to have removed the 'motivation and context' section from the pull request template. Can you tell me a little bit more about where you encountered problems with the current behavior?

Also, which version of Aruba are you using?

@peagha
Copy link
Author

peagha commented Mar 15, 2019

@mvz thanks for your answer!

The main motivation is that I had a scenario where the command was failing (exit status != 0) and I wanted to have feedback on that. Older versions of Aruba used to print the whole output when using assert_passing_with, like that:

Exit status was 1 but expected it to be 0. Output:
      /Users/peagha/Code/me/forca/bin/forca:5:in `<main>': unhandled exception

In the latest version, when using expect(last_command_stopped).to be_successfully_executed, all I get is:

(...)
expected "forca" to be successfully executed (RSpec::Expectations::ExpectationNotMetError)
(...)

The output is useful to understand why the command wasn't successfully executed, therefore I added to my app:

expect(last_command_stopped).not_to have_output_on_stderr

What would print the STDERR whenever something is wrong. But that doesn't work because have_output_on_stderr expects an argument. That motivated me to change the matcher to work without arguments 😄

I'm using the lates version of Aruba (0.14.8)

@peagha peagha force-pushed the add-empty-support-have-output-stderr-matcher branch from 8d02d98 to a4f3ee6 Compare March 15, 2019 03:09
@peagha
Copy link
Author

peagha commented Mar 15, 2019

I've updated the failure messages code and they should be working now

@peagha peagha force-pushed the add-empty-support-have-output-stderr-matcher branch from a4f3ee6 to 6cd38c7 Compare March 15, 2019 03:33
Copy link
Contributor

@luke-hill luke-hill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given you're changing the output of the rspec failure messages (And matchers by extension), we need at the very least 2 rspec message tests (Ideally more)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants