Sha256: ca727c89313811a01e1141a40f108b162ab580d6c9854b9d30e9f53dd61b22b7

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

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

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

      subject { described_class.new(url, 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 '#show' do
        it 'gets to the given url' do
          expect(client).to receive(:get).with(url)
          subject.show(1)
        end
      end

      describe '#index' do
        it 'gets to the given url' do
          expect(client).to receive(:get).with(url)
          subject.index
        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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
routemaster-drain-2.3.0 spec/routemaster/resources/rest_resource_spec.rb
routemaster-drain-2.2.2 spec/routemaster/resources/rest_resource_spec.rb