Sha256: ca1b4e5b9e2ce3b5a4135818ba9a5ce394dec15f1081f6e12bac2913748123f6

Contents?: true

Size: 1.96 KB

Versions: 7

Compression:

Stored size: 1.96 KB

Contents

require "spec_helper"

describe Bugsnag::Api::Client::Events do
  before do
    @client = auth_token_client
    @project_id = test_bugsnag_project_id
    @error_id = test_bugsnag_error_id
    @event_id = test_bugsnag_event_id
    Bugsnag::Api.reset!
  end

  describe ".event", :vcr do
    it "returns the specified event" do
      event = @client.event @project_id, @event_id
      expect(event.id).to_not be_nil
      expect(event.context).to_not be_nil

      assert_requested :get, bugsnag_url("/projects/#{@project_id}/events/#{@event_id}")
    end
  end

  describe ".delete_event", :vcr do
    it "deletes the specified event" do
      stub_request(:delete, bugsnag_url("/projects/#{@project_id}/events/#{@event_id}")).to_return(:status => [204, "No Content"])

      response = @client.delete_event @project_id, @event_id
      expect(response).to be true

      assert_requested :delete, bugsnag_url("/projects/#{@project_id}/events/#{@event_id}")
    end
  end

  describe ".error_events", :vcr do
    it "lists all error events" do
      events = @client.error_events @project_id, @error_id
      expect(events).to be_a_kind_of(Array)
      expect(events.first.id).to_not be_nil
      expect(events.first.context).to_not be_nil
      
      assert_requested :get, bugsnag_url("/projects/#{@project_id}/errors/#{@error_id}/events")
    end
  end

  describe ".latest_event", :vcr do
    it "returns the last event on an error" do
      event = @client.latest_event @error_id
      expect(event.id).to_not be_nil
      expect(event.context).to_not be_nil

      assert_requested :get, bugsnag_url("/errors/#{@error_id}/latest_event")
    end
  end

  describe ".events", :vcr do
    it "returns the a list of project errors" do
      events = @client.events @project_id
      expect(events).to be_a_kind_of(Array)
      expect(events.first.id).to_not be_nil
      expect(events.first.context).to_not be_nil

      assert_requested :get, bugsnag_url("/projects/#{@project_id}/events")
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bugsnag-api-3.0.0 spec/bugsnag/api/client/events_spec.rb
bugsnag-api-2.1.1 spec/bugsnag/api/client/events_spec.rb
bugsnag-api-2.1.0 spec/bugsnag/api/client/events_spec.rb
bugsnag-api-2.0.3 spec/bugsnag/api/client/events_spec.rb
bugsnag-api-2.0.2 spec/bugsnag/api/client/events_spec.rb
bugsnag-api-2.0.1 spec/bugsnag/api/client/events_spec.rb
bugsnag-api-2.0.0 spec/bugsnag/api/client/events_spec.rb