Skip to content

Instantly share code, notes, and snippets.

@chadh
Created December 21, 2018 17:53
Show Gist options
  • Select an option

  • Save chadh/78f645ca5784f544c84bca2e613d7c38 to your computer and use it in GitHub Desktop.

Select an option

Save chadh/78f645ca5784f544c84bca2e613d7c38 to your computer and use it in GitHub Desktop.
function test
require 'spec_helper'
require 'json'
describe 'dcm::get' do
let(:uri) { 'https://baz.bar.org/api/v2/x/y?host=foo.bar.org' }
let(:response_string) { '{"count":1,"next":null,"previous":null,"results":[{"id":2061,"dataset":"foo","port":3314}]}' }
let(:response) { JSON.parse(response_string) }
let(:result) { 'foo' }
before do
Puppet::Parser::Functions.newfunction(:'dcm::cached_request', :type => :rvalue) {
|args| dcm::cached_request.call(args[0], args[1], args[2])
}
dcm::cached_request.stubs(:call).returns(nil)
end
it do
dcm::cached_request.stubs(:call).with({},uri).returns(response)
is_expected.to run.with_params(
{},
'datastores/instances',
{'host' => 'foo.bar.org'},
'v2').and_return(result)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment