Sha256: 952f7e17c03c7018d1425fd30db161d276e916385c8b92775652ff6f6695c7b6

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 KB

Contents

describe Appsignal::AuthCheck do
  let(:config) { project_fixture_config }
  let(:auth_check) { Appsignal::AuthCheck.new(config) }

  describe "#perform_with_result" do
    it "should give success message" do
      expect(auth_check).to receive(:perform).and_return("200")
      expect(auth_check.perform_with_result).to eq ["200", "AppSignal has confirmed authorization!"]
    end

    it "should give 401 message" do
      expect(auth_check).to receive(:perform).and_return("401")
      expect(auth_check.perform_with_result).to eq ["401", "API key not valid with AppSignal..."]
    end

    it "should give an error message" do
      expect(auth_check).to receive(:perform).and_return("402")
      expect(auth_check.perform_with_result).to eq ["402", "Could not confirm authorization: 402"]
    end
  end

  context "transmitting" do
    before do
      @transmitter = double
      expect(Appsignal::Transmitter).to receive(:new).with(
        "auth",
        kind_of(Appsignal::Config)
      ).and_return(@transmitter)
    end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
appsignal-2.1.2 spec/lib/appsignal/auth_check_spec.rb
appsignal-2.1.1 spec/lib/appsignal/auth_check_spec.rb
appsignal-2.1.1.beta.1 spec/lib/appsignal/auth_check_spec.rb
appsignal-2.1.0 spec/lib/appsignal/auth_check_spec.rb