Sha256: abdc87b4b89e5c679c1602a2c5b8dc60b585e3c4ef45a13941ddf07da356b17b
Contents?: true
Size: 1.88 KB
Versions: 10
Compression:
Stored size: 1.88 KB
Contents
require 'spec_helper' describe Hieracles::Puppetdb::Client do describe '.new' do context 'when no option is passed' do let(:client) { Hieracles::Puppetdb::Client.new Hash.new } it { expect(client.class.instance_variable_get(:@default_options)[:base_uri]).to eq 'http://localhost:8080/v3' } end end describe '.setup_if_ssl' do let(:basepath) { 'spec/files' } let(:options) { { 'usessl' => true, 'key' => File.join(basepath, 'ssl', 'key.pem'), 'cert' => File.join(basepath, 'ssl', 'cert.crt'), 'ca_file' => File.join(basepath, 'ssl', 'ca.crt') } } let(:client) { Hieracles::Puppetdb::Client.new options } it { expect(client.class.instance_variable_get(:@default_options)[:options]).to eq options } end describe '.request' do context 'with a GET request' do let(:client) { Hieracles::Puppetdb::Client.new Hash.new } let(:request) { client.request('endpoint')} let(:response) { Hieracles::Puppetdb::Response.new(Hash.new, 0, Array.new) } before { resp = double allow(resp). to receive(:code). and_return(200) allow(resp). to receive(:parsed_response). and_return('') allow(client). to receive(:get_request). with('endpoint', nil, {}). and_return(resp) } it { expect(request.data).to eq Hash.new } it { expect(request.notifications.count).to eq 1 } end end describe '.get_request' do let(:client) { Hieracles::Puppetdb::Client.new Hash.new } context 'without query' do let(:request) { client.request('endpoint')} before { allow(client.class). to receive(:get). and_return('ha') } let(:get_request) { client.get_request('endpoint', nil, Hash.new) } it { expect(get_request).to eq 'ha' } end end end
Version data entries
10 entries across 10 versions & 1 rubygems