Sha256: 6a211eaeef0524642be78d3fc92b3473a90741a3e7c2396ad5720b5f6e17face

Contents?: true

Size: 1.42 KB

Versions: 3

Compression:

Stored size: 1.42 KB

Contents

require "gds_zendesk/dummy_client"

module GDSZendesk
  describe DummyClient do
    context "when a ticket has been raised" do
      let(:ticket_options) { { opt1: "val1" } }

      it "logs the ticket details" do
        logger = instance_double("Logger")
        expect(logger).to receive(:info).with("Zendesk ticket created: #{ticket_options.inspect}")

        client = described_class.new(logger: logger)
        client.ticket.create!(ticket_options)
      end

      it "can simulate failures, triggered by a specific description or comment" do
        logger = instance_double("Logger")
        client = described_class.new(logger: logger)
        expect(logger).to receive(:info).with(/Simulating Zendesk ticket creation failure/).twice

        expect {
          client.ticket.create!(description: "break_zendesk")
        }.to raise_error(ZendeskAPI::Error::RecordInvalid)

        expect {
          client.ticket.create!(comment: { value: "break_zendesk" })
        }.to raise_error(ZendeskAPI::Error::RecordInvalid)
      end
    end

    context "when a user has been created" do
      let(:options) { { email: "a@b.com" } }

      it "logs the user details" do
        logger = instance_double("Logger")
        expect(logger).to receive(:info).with("Zendesk user created or updated: #{options.inspect}")

        client = described_class.new(logger: logger)
        client.users.create_or_update_user(options)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gds_zendesk-3.6.0 spec/gds_zendesk/dummy_client_spec.rb
gds_zendesk-3.5.0 spec/gds_zendesk/dummy_client_spec.rb
gds_zendesk-3.4.0 spec/gds_zendesk/dummy_client_spec.rb