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

Use a stub for $stdin during testing #2033

Merged

Conversation

mattbrictson
Copy link
Member

Summary

This allows the tests to run even in a situation where stdin isn't available, for example when the test is run with < /dev/null as is the case for some packaging scripts.

Fixes #2032

Short checklist

  • Did you run bundle exec rubocop -a to fix linter issues?
  • If relevant, did you create a test?
  • Did you confirm that the RSpec tests pass?
  • If you are fixing a bug or introducing a new feature, did you add a CHANGELOG entry? (this is not a user-facing fix)

This allows the tests to run even in a situation where stdin isn't
available, for example when the test is run with `< /dev/null` as is the
case for some packaging scripts.

Fixes #2032
@capistrano-bot
Copy link

1 Warning
⚠️ Please update CHANGELOG.md with a description of your changes. If this PR is not a user-facing change (e.g. just refactoring), you can disregard this.

Here's an example of a CHANGELOG.md entry (place it immediately under the * Your contribution here! line):

* [#2033](https://github.com/capistrano/capistrano/pull/2033): Use a stub for $stdin during testing - [@mattbrictson](https://github.com/mattbrictson)

Generated by 🚫 Danger

@mattbrictson
Copy link
Member Author

This fix is incomplete. There are still 2 failing tests when I run the tests with < /dev/null:

  1) Capistrano::DSL asking for a variable variable is provided sets the input as the variable
     Failure/Error: expect(dsl.fetch(:scm)).to eq "git"

       expected: "git"
            got: :svn

       (compared using ==)

       Diff:
       @@ -1,2 +1,2 @@
       -"git"
       +:svn
     # ./spec/integration/dsl_spec.rb:370:in `block (4 levels) in <top (required)>'

  2) Capistrano::DSL asking for a variable variable is not provided sets the variable as the default
     Failure/Error: $stdin.expects(:gets).returns("")

     Mocha::ExpectationError:
       not all expectations were satisfied
       unsatisfied expectations:
       - expected exactly once, not yet invoked: #<IO:0x108a28e20>.gets(any_parameters)
       satisfied expectations:
       - allowed any number of times, invoked once: #<IO:0x108a28d80>.print(any_parameters)
     # ./spec/integration/dsl_spec.rb:376:in `block (4 levels) in <top (required)>'

@mattbrictson
Copy link
Member Author

All fixed now

@mattbrictson mattbrictson merged commit 5c21b70 into master Sep 4, 2019
@mattbrictson mattbrictson deleted the chores/allow-question-test-to-run-without-stdin branch September 4, 2019 15:39
@mattbrictson mattbrictson added the 🏠 Housekeeping Non-user facing cleanup and maintenance label Sep 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏠 Housekeeping Non-user facing cleanup and maintenance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some tests fail if stdin is redirected
3 participants