Sha256: 3aa3f43c4b83e088ee69735abbb0b0490928f0e11a01f9974e69002f154dd0d2

Contents?: true

Size: 1.63 KB

Versions: 1

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'

describe Appsignal::AuthCheck do
  let(:auth_check) { Appsignal::AuthCheck.new('production') }

  describe "#perform_with_result" do
    it "should give success message" do
      auth_check.should_receive(:perform).and_return('200')
      auth_check.perform_with_result.should ==
        ['200', 'AppSignal has confirmed authorisation!']
    end

    it "should give 401 message" do
      auth_check.should_receive(:perform).and_return('401')
      auth_check.perform_with_result.should ==
        ['401', 'API key not valid with AppSignal...']
    end

    it "should give error message" do
      auth_check.should_receive(:perform).and_return('402')
      auth_check.perform_with_result.should ==
        ['402', 'Could not confirm authorisation: 402']
    end
  end

  context "transmitting" do
    before do
      @transmitter = mock
      Appsignal::Transmitter.should_receive(:new).
        with('http://localhost:3000/1', 'auth', 'def').
        and_return(@transmitter)
    end

    describe "#perform" do
      it "should not transmit any extra data" do
        @transmitter.should_receive(:transmit).with({}).and_return({})
        auth_check.perform
      end
    end

    describe "#uri" do
      before do
        @transmitter.should_receive(:transmit)
        auth_check.perform
      end

      it "should delegate to transmitter" do
        @transmitter.should_receive(:uri)
        auth_check.uri
      end

      it "should return uri" do
        @transmitter.should_receive(:uri).
          and_return('http://appsignal.com/1/auth')
        auth_check.uri.should == 'http://appsignal.com/1/auth'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
appsignal-0.6.0.beta.1 spec/appsignal/auth_check_spec.rb