Class: HammerCLIForeman::Testing::APIExpectations::APIExpectationsDecorator
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- HammerCLIForeman::Testing::APIExpectations::APIExpectationsDecorator
- Defined in:
- lib/hammer_cli_foreman/testing/api_expectations.rb
Instance Method Summary collapse
- #expects_call(resource = nil, action = nil, note = nil, &block) ⇒ Object
- #expects_no_call ⇒ Object
- #expects_search(resource = nil, search_options = {}, note = nil) ⇒ Object
-
#initialize(api_instance = ApipieBindings::API.any_instance) ⇒ APIExpectationsDecorator
constructor
A new instance of APIExpectationsDecorator.
Constructor Details
#initialize(api_instance = ApipieBindings::API.any_instance) ⇒ APIExpectationsDecorator
Returns a new instance of APIExpectationsDecorator.
109 110 111 112 |
# File 'lib/hammer_cli_foreman/testing/api_expectations.rb', line 109 def initialize(api_instance = ApipieBindings::API.any_instance) @api_instance = api_instance super end |
Instance Method Details
#expects_call(resource = nil, action = nil, note = nil, &block) ⇒ Object
114 115 116 117 118 119 120 |
# File 'lib/hammer_cli_foreman/testing/api_expectations.rb', line 114 def expects_call(resource=nil, action=nil, note=nil, &block) ex = @api_instance.expects(:call_action) ex.extend(ExpectationExtensions) ex.with_action(resource, action).with_params(&block) ex.set_note(note) ex end |
#expects_no_call ⇒ Object
122 123 124 |
# File 'lib/hammer_cli_foreman/testing/api_expectations.rb', line 122 def expects_no_call @api_instance.expects(:call_action).never end |
#expects_search(resource = nil, search_options = {}, note = nil) ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/hammer_cli_foreman/testing/api_expectations.rb', line 126 def expects_search(resource=nil, ={}, note=nil) note ||= "Find #{resource}" if .is_a?(Hash) search_query = .map{|k, v| "#{k} = \"#{v}\"" }.join(" or ") else search_query = end expects_call(resource, :index, note).with_params(:search => search_query) end |