Sha256: 737d3b23f53ef8a537741a8dd346e9dcb7a7f2ef29abde36973ff5a58da74e11
Contents?: true
Size: 1.92 KB
Versions: 4
Compression:
Stored size: 1.92 KB
Contents
require 'spec_helper' USERNAME = ENV['LINODE_USERNAME'] || 'test' PASSWORD = ENV['LINODE_PASSWORD'] || 'test' APIKEY = ENV['LINODE_APIKEY'] || 'test' describe LinodeAPI::Raw do let(:subject) do LinodeAPI::Raw.new(apikey: APIKEY) end it 'requires credentials' do VCR.use_cassette('no_creds') do expect { LinodeAPI::Raw.new }.to raise_error ArgumentError end end it 'fails if the username/password are invalid' do VCR.use_cassette('basic_auth_fail') do expect do LinodeAPI::Raw.new(username: 'bad', password: 'bad') end.to raise_error LinodeAPI::APIError end end it 'accepts valid username/password' do VCR.use_cassette('basic_auth') do api = LinodeAPI::Raw.new(username: USERNAME, password: PASSWORD) expect(api.test.echo).to be_an_instance_of OpenStruct end end it 'accepts a valid api key' do VCR.use_cassette('test_echo') do expect(subject.test.echo).to be_an_instance_of OpenStruct end end it 'has a to_s representation' do expect(subject.to_s).to eql 'LinodeAPI::Raw object' expect(subject.inspect).to eql 'LinodeAPI::Raw object' end it 'accurately responds to .respond_to?' do expect(subject.respond_to?(:linode)).to be_truthy expect(subject.respond_to?(:list)).to be_falsey end it 'returns arrays for list calls' do VCR.use_cassette('linode_list') do expect(subject.linode.list.class).to eql Array end end it 'fails if a required param is missing' do expect { subject.linode.create }.to raise_error ArgumentError end it 'converts boolean params to true/false' do VCR.use_cassette('kernel_list') do expect( subject.avail.kernels(isxen: 'word').all? { |x| x.isxen == 1 } ).to be_truthy end end it 'raises a validation error on invalid numeric params' do expect do subject.avail.linodeplans(planid: 'word') end.to raise_error ArgumentError end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
linodeapi-2.0.3 | spec/linodeapi/raw_spec.rb |
linodeapi-2.0.2 | spec/linodeapi/raw_spec.rb |
linodeapi-2.0.1 | spec/linodeapi/raw_spec.rb |
linodeapi-2.0.0 | spec/linodeapi/raw_spec.rb |