Class: HammerCLI::Testing::CommandAssertions::CommandExpectation

Inherits:
Object
  • Object
show all
Includes:
MiniTest::Assertions
Defined in:
lib/hammer_cli/testing/command_assertions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expected_out = "", expected_err = "", expected_exit_code = 0) ⇒ CommandExpectation

Returns a new instance of CommandExpectation.



9
10
11
12
13
# File 'lib/hammer_cli/testing/command_assertions.rb', line 9

def initialize(expected_out="", expected_err="", expected_exit_code=0)
  @expected_out = expected_out
  @expected_err = expected_err
  @expected_exit_code = expected_exit_code
end

Instance Attribute Details

#expected_errObject

Returns the value of attribute expected_err.



7
8
9
# File 'lib/hammer_cli/testing/command_assertions.rb', line 7

def expected_err
  @expected_err
end

#expected_exit_codeObject

Returns the value of attribute expected_exit_code.



7
8
9
# File 'lib/hammer_cli/testing/command_assertions.rb', line 7

def expected_exit_code
  @expected_exit_code
end

#expected_outObject

Returns the value of attribute expected_out.



7
8
9
# File 'lib/hammer_cli/testing/command_assertions.rb', line 7

def expected_out
  @expected_out
end

Instance Method Details

#assert_match(actual_result) ⇒ Object



15
16
17
18
19
# File 'lib/hammer_cli/testing/command_assertions.rb', line 15

def assert_match(actual_result)
  assert_equal_or_match @expected_err, actual_result.err
  assert_equal_or_match @expected_out, actual_result.out
  assert_exit_code_equal @expected_exit_code, actual_result.exit_code
end