Module: HammerCLIForeman::Testing::APIExpectations::ExpectationExtensions
- Defined in:
- lib/hammer_cli_foreman/testing/api_expectations.rb
Instance Method Summary collapse
- #api_call_matcher ⇒ Object
- #method_signature ⇒ Object
- #params_signature(hash) ⇒ Object
- #set_note(note) ⇒ Object
- #with_action(resource, action) ⇒ Object
- #with_params(expected_params = {}, &block) ⇒ Object
Instance Method Details
#api_call_matcher ⇒ Object
82 83 84 |
# File 'lib/hammer_cli_foreman/testing/api_expectations.rb', line 82 def api_call_matcher @api_call_matcher ||= APICallMatcher.new end |
#method_signature ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/hammer_cli_foreman/testing/api_expectations.rb', line 52 def method_signature signature = "#{@note}\n #{super}" if @api_call_matcher && !@api_call_matcher.expected_params.empty? signature += "\n expected params to include: " + params_signature(@api_call_matcher.expected_params) end signature end |
#params_signature(hash) ⇒ Object
60 61 62 |
# File 'lib/hammer_cli_foreman/testing/api_expectations.rb', line 60 def params_signature(hash) JSON.pretty_generate(hash).split("\n").join("\n ") end |
#set_note(note) ⇒ Object
64 65 66 |
# File 'lib/hammer_cli_foreman/testing/api_expectations.rb', line 64 def set_note(note) @note = note end |
#with_action(resource, action) ⇒ Object
75 76 77 78 79 80 |
# File 'lib/hammer_cli_foreman/testing/api_expectations.rb', line 75 def with_action(resource, action) api_call_matcher.expected_resource = resource api_call_matcher.expected_action = action self.with(api_call_matcher) self end |
#with_params(expected_params = {}, &block) ⇒ Object
68 69 70 71 72 73 |
# File 'lib/hammer_cli_foreman/testing/api_expectations.rb', line 68 def with_params(expected_params = {}, &block) api_call_matcher.expected_params = expected_params api_call_matcher.block = block if block_given? self.with(api_call_matcher) self end |