module HammerCLIForeman::Testing::APIExpectations
Public Class Methods
api_calls()
click to toggle source
# File lib/hammer_cli_foreman/testing/api_expectations.rb, line 5 def self.api_calls @api_calls ||= [] end
Public Instance Methods
api_calls()
click to toggle source
# File lib/hammer_cli_foreman/testing/api_expectations.rb, line 168 def api_calls HammerCLIForeman::Testing::APIExpectations.api_calls end
api_connection(options={}, version = '1.15')
click to toggle source
# File lib/hammer_cli_foreman/testing/api_expectations.rb, line 158 def api_connection(options={}, 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(options)) end
api_expects(resource=nil, action=nil, note=nil, &block)
click to toggle source
# File lib/hammer_cli_foreman/testing/api_expectations.rb, line 172 def api_expects(resource=nil, action=nil, note=nil, &block) api_calls << [resource, action] APIExpectationsDecorator.new.expects_call(resource, action, note, &block) end
api_expects_no_call()
click to toggle source
# File lib/hammer_cli_foreman/testing/api_expectations.rb, line 177 def api_expects_no_call APIExpectationsDecorator.new.expects_no_call end
api_expects_search(resource=nil, search_options={}, note=nil)
click to toggle source
# File lib/hammer_cli_foreman/testing/api_expectations.rb, line 181 def api_expects_search(resource=nil, search_options={}, note=nil) APIExpectationsDecorator.new.expects_search(resource, search_options, note) end
index_response(items, options={})
click to toggle source
# File lib/hammer_cli_foreman/testing/api_expectations.rb, line 185 def index_response(items, options={}) cnt = if items.is_a?(Hash) items.keys.count else items.length end { "total" => options.fetch(:total, cnt), "subtotal" => options.fetch(:subtotal, cnt), "page" => options.fetch(:page, 1), "per_page" => options.fetch(:per_page, cnt), "search" => "", "sort" => { "by" => nil, "order" => nil }, "results" => items } end