Sha256: 4d70a396f9e8db4ace6e6048d8940f49a6af35d1f03a9b8d0d305846d499eaa3

Contents?: true

Size: 1001 Bytes

Versions: 9

Compression:

Stored size: 1001 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Azeroth::RequestHandler::Create do
  describe '#process' do
    it_behaves_like 'a request handler', status: :created do
      let(:extra_params) do
        {
          document: {
            name: 'My Document'
          }
        }
      end

      let(:expected_json) do
        { 'name' => 'My Document' }
      end

      it 'creates entry' do
        expect { handler.process }
          .to change(Document, :count)
          .by(1)
      end
    end
  end

  context 'when payload is invalid' do
    it_behaves_like 'a request handler',
                    status: :unprocessable_entity do
      let(:extra_params) do
        {
          document: {
            reference: 'my_reference'
          }
        }
      end

      let(:expected_json) do
        { 'name' => nil }
      end

      it 'does not create entry' do
        expect { handler.process }
          .not_to change(Document, :count)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
azeroth-0.6.5 spec/lib/azeroth/request_handler/create_spec.rb
azeroth-0.6.4 spec/lib/azeroth/request_handler/create_spec.rb
azeroth-0.6.3 spec/lib/azeroth/request_handler/create_spec.rb
azeroth-0.6.2 spec/lib/azeroth/request_handler/create_spec.rb
azeroth-0.6.1 spec/lib/azeroth/request_handler/create_spec.rb
azeroth-0.6.0 spec/lib/azeroth/request_handler/create_spec.rb
azeroth-0.5.0 spec/lib/azeroth/request_handler/create_spec.rb
azeroth-0.4.0 spec/lib/azeroth/request_handler/create_spec.rb
azeroth-0.3.0 spec/lib/azeroth/request_handler/create_spec.rb