Module: HammerCLIForeman::Testing::APIExpectations
- Defined in:
- lib/hammer_cli_foreman/testing/api_expectations.rb
Defined Under Namespace
Modules: ExpectationExtensions Classes: APICallMatcher, APIExpectationsDecorator, FakeApiConnection, TestAuthenticator
Instance Method Summary collapse
- #api_connection(options = {}, version = '1.15') ⇒ Object
- #api_expects(resource = nil, action = nil, note = nil, &block) ⇒ Object
- #api_expects_no_call ⇒ Object
- #api_expects_search(resource = nil, search_options = {}, note = nil) ⇒ Object
- #index_response(items, options = {}) ⇒ Object
Instance Method Details
#api_connection(options = {}, version = '1.15') ⇒ Object
133 134 135 136 137 138 139 140 141 |
# File 'lib/hammer_cli_foreman/testing/api_expectations.rb', line 133 def api_connection(={}, version = '1.15') FakeApiConnection.new({ :uri => 'https://test.org', :apidoc_cache_dir => "test/data/#{version}", :apidoc_cache_name => 'foreman_api', :authenticator => TestAuthenticator.new('admin', 'changeme'), :dry_run => true }.merge()) end |
#api_expects(resource = nil, action = nil, note = nil, &block) ⇒ Object
143 144 145 |
# File 'lib/hammer_cli_foreman/testing/api_expectations.rb', line 143 def api_expects(resource=nil, action=nil, note=nil, &block) APIExpectationsDecorator.new.expects_call(resource, action, note, &block) end |
#api_expects_no_call ⇒ Object
147 148 149 |
# File 'lib/hammer_cli_foreman/testing/api_expectations.rb', line 147 def api_expects_no_call APIExpectationsDecorator.new.expects_no_call end |
#api_expects_search(resource = nil, search_options = {}, note = nil) ⇒ Object
151 152 153 |
# File 'lib/hammer_cli_foreman/testing/api_expectations.rb', line 151 def api_expects_search(resource=nil, ={}, note=nil) APIExpectationsDecorator.new.expects_search(resource, , note) end |
#index_response(items, options = {}) ⇒ Object
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/hammer_cli_foreman/testing/api_expectations.rb', line 155 def index_response(items, ={}) cnt = items.length { "total" => .fetch(:total, cnt), "subtotal" => .fetch(:subtotal, cnt), "page" => .fetch(:page, 1), "per_page" => .fetch(:per_page, cnt), "search" => "", "sort" => { "by" => nil, "order" => nil }, "results" => items } end |