Class: RSpec::ShellCommand::Matchers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/shell_command/matchers/base.rb

Overview

Base class for a matcher class

NOTE: This is a internal class

Author:

Direct Known Subclasses

ExitWith, Output, Success

Instance Method Summary collapse

Instance Method Details

#actual_statusObject



20
21
22
# File 'lib/rspec/shell_command/matchers/base.rb', line 20

def actual_status
  @actual.status
end

#actual_status_messageObject



24
25
26
27
28
29
30
31
32
# File 'lib/rspec/shell_command/matchers/base.rb', line 24

def actual_status_message
  if actual_status.exited?
    "exited with status #{actual_status.exitstatus}"
  elsif actual_status.signaled?
    "terminated by signal #{actual_status.termsig}"
  else
    "been unknown status: #{@actual.inspect}"
  end
end

#make_expected_and_got_message(expected, got) ⇒ Object



34
35
36
37
38
# File 'lib/rspec/shell_command/matchers/base.rb', line 34

def make_expected_and_got_message(expected, got)
  "\n"\
  "expected: #{expected}\n"\
  "     got: #{got}"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
# File 'lib/rspec/shell_command/matchers/base.rb', line 11

def matches?(actual)
  unless actual.is_a?(RSpec::ShellCommand)
    raise TypeError,
          "expected RSpec::ShellCommand, but got #{actual.inspect}"
  end
  @actual = actual
  perform_match(actual.execute)
end