module HammerCLIForeman::Testing::APIExpectations

Public Instance Methods

api_expects(resource=nil, action=nil, note=nil, &block) click to toggle source
# File lib/hammer_cli_foreman/testing/api_expectations.rb, line 41
def api_expects(resource=nil, action=nil, note=nil, &block)
  ex = ApipieBindings::API.any_instance.expects(:call_action)
  ex.extend(ExpectationExtensions)
  ex.with(BlockMatcher.new(resource, action, &block))
  ex.set_note(note)
  ex
end
api_expects_no_call() click to toggle source
# File lib/hammer_cli_foreman/testing/api_expectations.rb, line 49
def api_expects_no_call
  ApipieBindings::API.any_instance.expects(:call_action).never
end
index_response(items, options={}) click to toggle source
# File lib/hammer_cli_foreman/testing/api_expectations.rb, line 53
def index_response(items, options={})
  cnt = items.length
  {
    "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