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

Inherits:
Object
  • Object
show all
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.



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

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.



5
6
7
# File 'lib/hammer_cli/testing/command_assertions.rb', line 5

def expected_err
  @expected_err
end

#expected_exit_codeObject

Returns the value of attribute expected_exit_code.



5
6
7
# File 'lib/hammer_cli/testing/command_assertions.rb', line 5

def expected_exit_code
  @expected_exit_code
end

#expected_outObject

Returns the value of attribute expected_out.



5
6
7
# File 'lib/hammer_cli/testing/command_assertions.rb', line 5

def expected_out
  @expected_out
end

Instance Method Details

#assert_match(test_ctx, actual_result) ⇒ Object



13
14
15
16
17
# File 'lib/hammer_cli/testing/command_assertions.rb', line 13

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