Class: RSpec::ShellCommand::Matchers::ExitWith

Inherits:
Base
  • Object
show all
Includes:
Matchers::Composable
Defined in:
lib/rspec/shell_command/matchers/exit_with.rb

Overview

Provide implementation of exit_with matcher

Check whether given command exit with expected status

Author:

Instance Method Summary collapse

Methods inherited from Base

#actual_status, #actual_status_message, #make_expected_and_got_message, #matches?

Constructor Details

#initialize(status) ⇒ ExitWith

Returns a new instance of ExitWith.



13
14
15
# File 'lib/rspec/shell_command/matchers/exit_with.rb', line 13

def initialize(status)
  @status = status
end

Instance Method Details

#descriptionObject



36
37
38
# File 'lib/rspec/shell_command/matchers/exit_with.rb', line 36

def description
  "exit with #{description_of(@status)}"
end

#failure_messageObject



22
23
24
25
26
27
# File 'lib/rspec/shell_command/matchers/exit_with.rb', line 22

def failure_message
  make_expected_and_got_message(
    "exited with status #{@status}",
    actual_status_message
  )
end

#failure_message_when_negatedObject



29
30
31
32
33
34
# File 'lib/rspec/shell_command/matchers/exit_with.rb', line 29

def failure_message_when_negated
  make_expected_and_got_message(
    "not exited with status #{@status}",
    actual_status_message
  )
end

#perform_match(actual) ⇒ Object



17
18
19
20
# File 'lib/rspec/shell_command/matchers/exit_with.rb', line 17

def perform_match(actual)
  actual_status = actual.status
  values_match?(@status, actual_status.exitstatus)
end