Sha256: e680035a48ea4dc7b57df095ba12910ce450a80ca5001a343bbc9d13bdec0eb8

Contents?: true

Size: 1.41 KB

Versions: 3

Compression:

Stored size: 1.41 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 "should log the ticket details" do
        logger = double("logger")
        expect(logger).to receive(:info).with("Zendesk ticket created: #{ticket_options.inspect}")

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

      it "can simulate failures, triggered by a specific description or comment" do
        logger = double("logger")
        client = DummyClient.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(:created_user_options) { { email: "a@b.com" } }

      it "should log the user details" do
        logger = double("logger")
        expect(logger).to receive(:info).with("Zendesk user created: #{created_user_options.inspect}")

        client = DummyClient.new(logger: logger)
        client.users.create!(created_user_options)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gds_zendesk-1.0.5 spec/gds_zendesk/dummy_client_spec.rb
gds_zendesk-1.0.4 spec/gds_zendesk/dummy_client_spec.rb
gds_zendesk-1.0.3 spec/gds_zendesk/dummy_client_spec.rb