Sha256: ca16604633b18c5b3f516e91be16f035b8468921b721208540071f43643440c1

Contents?: true

Size: 1.69 KB

Versions: 21

Compression:

Stored size: 1.69 KB

Contents

require 'spec_helper'
require 'routemaster/resources/rest_resource'

module Routemaster
  module Resources
    RSpec.describe RestResource do
      let(:client) { double('Client') }
      let(:params) { {} }

      describe "singular resource" do
        let(:url) { '/resources/1' }

        subject { described_class.new('/resources/{id}', client: client) }

        describe '#show' do
          it 'gets to the given url' do
            expect(client).to receive(:get).with(url, options: { enable_caching: true })
            subject.show(1)
          end
        end

        describe '#update' do
          it 'updates the given resource' do
            expect(client).to receive(:patch).with(url, body: params)
            subject.update(1, params)
          end
        end

        describe '#destroy' do
          it 'destroys the given resource' do
            expect(client).to receive(:delete).with(url)
            subject.destroy(1)
          end
        end
      end

      describe "collection resource" do
        let(:url) { '/resources' }

        subject { described_class.new('/resources{?page,per_page}', client: client) }

        describe '#create' do
          it 'posts to the given url' do
            expect(client).to receive(:post).with(url, body: params)
            subject.create(params)
          end
        end

        describe '#index' do
          it 'gets to the given url' do
            expect(client).to receive(:get).with(
              url, params: {}, options: {
                enable_caching: false, response_class: Routemaster::Responses::HateoasEnumerableResponse
              }
            )
            subject.index
          end
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
routemaster-drain-3.7.1 spec/routemaster/resources/rest_resource_spec.rb
routemaster-drain-3.7.0 spec/routemaster/resources/rest_resource_spec.rb
routemaster-drain-3.6.8 spec/routemaster/resources/rest_resource_spec.rb
routemaster-drain-3.6.7 spec/routemaster/resources/rest_resource_spec.rb
routemaster-drain-3.6.6 spec/routemaster/resources/rest_resource_spec.rb
routemaster-drain-3.6.5 spec/routemaster/resources/rest_resource_spec.rb
routemaster-drain-3.6.4 spec/routemaster/resources/rest_resource_spec.rb
routemaster-drain-3.6.3 spec/routemaster/resources/rest_resource_spec.rb
routemaster-drain-3.6.2 spec/routemaster/resources/rest_resource_spec.rb
routemaster-drain-3.6.1 spec/routemaster/resources/rest_resource_spec.rb
routemaster-drain-3.6.0 spec/routemaster/resources/rest_resource_spec.rb
routemaster-drain-3.5.1 spec/routemaster/resources/rest_resource_spec.rb
routemaster-drain-3.5.0 spec/routemaster/resources/rest_resource_spec.rb
routemaster-drain-3.4.0 spec/routemaster/resources/rest_resource_spec.rb
routemaster-drain-3.3.0 spec/routemaster/resources/rest_resource_spec.rb
routemaster-drain-3.2.0 spec/routemaster/resources/rest_resource_spec.rb
routemaster-drain-3.1.0 spec/routemaster/resources/rest_resource_spec.rb
routemaster-drain-3.0.3 spec/routemaster/resources/rest_resource_spec.rb
routemaster-drain-3.0.2 spec/routemaster/resources/rest_resource_spec.rb
routemaster-drain-3.0.1 spec/routemaster/resources/rest_resource_spec.rb