Module: HammerCLIForeman::Testing::APIExpectations

Defined in:
lib/hammer_cli_foreman/testing/api_expectations.rb

Defined Under Namespace

Modules: ExpectationExtensions Classes: BlockMatcher

Instance Method Summary collapse

Instance Method Details

#api_expects(resource = nil, action = nil, note = nil, &block) ⇒ Object



41
42
43
44
45
46
47
# 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_callObject



49
50
51
# File 'lib/hammer_cli_foreman/testing/api_expectations.rb', line 49

def api_expects_no_call
  ApipieBindings::API.any_instance.expects(:call).never
end

#index_response(items) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/hammer_cli_foreman/testing/api_expectations.rb', line 53

def index_response(items)
  cnt = items.length
  {
    "total" => cnt,
    "subtotal" => cnt,
    "page" => 1,
    "per_page" => cnt,
    "search" => "",
    "sort" => {
      "by" => nil,
      "order" => nil
    },
    "results" => items
  }
end