Sha256: 965c9e5f0b0c3e90a90a22f6bbc7bab06f3d782ddcf5d71f975bdaa0204ac176

Contents?: true

Size: 1.39 KB

Versions: 9

Compression:

Stored size: 1.39 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(:options) { { email: "a@b.com" } }

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

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
gds_zendesk-3.2.0 spec/gds_zendesk/dummy_client_spec.rb
gds_zendesk-3.1.0 spec/gds_zendesk/dummy_client_spec.rb
gds_zendesk-3.0.0 spec/gds_zendesk/dummy_client_spec.rb
gds_zendesk-2.4.0 spec/gds_zendesk/dummy_client_spec.rb
gds_zendesk-2.3.1 spec/gds_zendesk/dummy_client_spec.rb
gds_zendesk-2.3.0 spec/gds_zendesk/dummy_client_spec.rb
gds_zendesk-2.2.0 spec/gds_zendesk/dummy_client_spec.rb
gds_zendesk-2.1.0 spec/gds_zendesk/dummy_client_spec.rb
gds_zendesk-2.0.0 spec/gds_zendesk/dummy_client_spec.rb