Sha256: bf16e4c6e5343a70d9c227ddc7cf9798657205fa9d693189131b9b36e11ba96c

Contents?: true

Size: 1.52 KB

Versions: 58

Compression:

Stored size: 1.52 KB

Contents

require 'spec_helper'
require 'pact_broker/api/decorators/webhooks_decorator'

module PactBroker
  module Api
    module Decorators
      describe WebhooksDecorator do

        let(:webhook) do
          instance_double(Domain::Webhook, uuid: 'some-uuid', description: 'description', request_description: 'request description')
        end
        let(:base_url) { 'http://example.org' }
        let(:resource_url) { 'http://example.org/webhooks' }

        let(:decorator_context) do
          DecoratorContext.new(base_url, resource_url, resource_title: 'Title')
        end

        let(:webhooks) { [webhook] }

        describe "to_json" do

          let(:json) { WebhooksDecorator.new(webhooks).to_json(user_options: decorator_context) }

          subject { JSON.parse(json, symbolize_names: true) }

          it "includes a link to itself with a title" do
            expect(subject[:_links][:self][:href]).to eq resource_url
            expect(subject[:_links][:self][:title]).to eq 'Title'
          end

          it "includes a list of links to the webhooks" do
            expect(subject[:_links][:'pb:webhooks']).to be_instance_of(Array)
            expect(subject[:_links][:'pb:webhooks'].first).to eq title: 'description', name: 'request description', href: 'http://example.org/webhooks/some-uuid'
          end

          it "includes curies" do
            expect(subject[:_links][:curies]).to eq [{:name=>"pb", :href=>"http://example.org/doc/webhooks-{rel}", templated: true}]
          end

        end

      end
    end
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
pact_broker-2.31.0 spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb
pact_broker-2.30.0 spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb
pact_broker-2.29.0 spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb
pact_broker-2.27.6 spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb
pact_broker-2.27.5 spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb
pact_broker-2.27.4 spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb
pact_broker-2.27.3 spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb
pact_broker-2.27.2 spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb
pact_broker-2.27.0 spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb
pact_broker-2.26.1 spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb
pact_broker-2.26.0 spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb
pact_broker-2.25.0 spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb
pact_broker-2.24.0 spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb
pact_broker-2.23.4 spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb
pact_broker-2.23.3 spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb
pact_broker-2.23.2 spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb
pact_broker-2.23.1 spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb
pact_broker-2.23.0 spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb
pact_broker-2.22.0 spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb
pact_broker-2.21.0 spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb