Sha256: d3dd0220bebdca5b580390dacbfc2b9fce01c3e519052b9f6ac7a10e4ad8bbb4

Contents?: true

Size: 1.24 KB

Versions: 5

Compression:

Stored size: 1.24 KB

Contents

require 'spec_helper'

describe Rundeck::Request do
  it { is_expected.to respond_to(:get) }
  it { is_expected.to respond_to(:post) }
  it { is_expected.to respond_to(:put) }
  it { is_expected.to respond_to(:delete) }

  describe '.default_options' do
    subject { Rundeck::Request.default_options }
    it { is_expected.to be_a Hash }
    its([:format]) { is_expected.to eq(:xml) }
    its([:default_params]) { is_expected.to be_nil }
  end

  describe '#set_request_defaults' do
    context 'when endpoint' do
      context 'is not set' do
        it do
          expect do
            Rundeck::Request.new.set_request_defaults(nil, 'secret')
          end.to raise_error(Rundeck::Error::MissingCredentials,
                             'Please set an endpoint to API')
        end
      end

      context 'is set' do
        before do
          @rundeck_request = Rundeck::Request.new
          @rundeck_request
            .set_request_defaults('http://api.example.org', 'secret')
        end
        subject { @rundeck_request }

        it do
          expect(Rundeck::Request.base_uri)
            .to eq("http://api.example.org/api/#{Rundeck.api_version}")
        end
        its(:api_token) { is_expected.to eq('secret') }
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rundeck-1.2.1 spec/rundeck/request_spec.rb
rundeck-1.2.0 spec/rundeck/request_spec.rb
rundeck-1.1.0 spec/rundeck/request_spec.rb
rundeck-1.0.2 spec/rundeck/request_spec.rb
rundeck-1.0.1 spec/rundeck/request_spec.rb