Class: CommandTest::Tests::RunsCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/command_test/tests.rb

Instance Method Summary collapse

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

Returns:

  • (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_messageObject



23
24
25
26
27
28
# File 'lib/command_test/tests.rb', line 23

def negative_failure_message
  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_messageObject



16
17
18
19
20
21
# File 'lib/command_test/tests.rb', line 16

def positive_failure_message
  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