Class: CommandTest::Tests::RunsCommand
- Inherits:
-
Object
- Object
- CommandTest::Tests::RunsCommand
- Defined in:
- lib/command_test/tests.rb
Instance Method Summary collapse
-
#initialize(expected, &proc) ⇒ RunsCommand
constructor
A new instance of RunsCommand.
- #matches? ⇒ Boolean
- #negative_failure_message ⇒ Object
- #positive_failure_message ⇒ Object
Constructor Details
#initialize(expected, &proc) ⇒ RunsCommand
Returns a new instance of RunsCommand.
4 5 6 7 |
# File 'lib/command_test/tests.rb', line 4 def initialize(expected, &proc) @expected = expected @proc = proc end |
Instance Method Details
#matches? ⇒ Boolean
9 10 11 12 13 14 |
# File 'lib/command_test/tests.rb', line 9 def matches? @actual = CommandTest.record(&@proc) @actual.any? do |actual| CommandTest.match?(@expected, actual) end end |
#negative_failure_message ⇒ Object
23 24 25 26 27 28 |
# File 'lib/command_test/tests.rb', line 23 def expected_string = display_commands([@expected]) actual_string = display_commands(@actual) "This command should not have been run, but was:\n#{expected_string}\n" << "These were the commands run:\n#{actual_string}\n" end |
#positive_failure_message ⇒ Object
16 17 18 19 20 21 |
# File 'lib/command_test/tests.rb', line 16 def expected_string = display_commands([@expected]) actual_string = display_commands(@actual) "This command should have been run, but was not:\n#{expected_string}\n" << "These were the commands run:\n#{actual_string}\n" end |