Sha256: d72a1d82f9f95ad7f167d83a7b5bacf7c9d3666a6dcf60e250c169b2b53fa867
Contents?: true
Size: 1.31 KB
Versions: 7
Compression:
Stored size: 1.31 KB
Contents
# frozen_string_literal: true shared_examples 'a request handler' do |status: :ok| subject(:handler) { described_class.new(controller, model) } let(:controller) { controller_class.new } let(:params) { ActionController::Parameters.new(parameters) } let(:model) { Azeroth::Model.new(:document, options) } let(:options) { Azeroth::Options.new } let(:extra_params) { {} } let(:decorator) { Document::Decorator.new(expected_resource) } let(:expected_json) { decorator.as_json } let(:documents_count) { 0 } let(:controller_class) { RequestHandlerController } let(:format) { 'json' } let(:parameters) do { format: format }.merge(extra_params) end before do documents_count.times { create(:document) } allow(controller).to receive(:params) .and_return(params) allow(controller).to receive(:render) .with(json: expected_json, status: status) .and_return(expected_json) end it 'returns all documents json' do expect(handler.process).to eq(expected_json) end it 'renders the json' do handler.process expect(controller).to have_received(:render) end context 'with format html' do let(:format) { 'html' } it do handler.process expect(controller).not_to have_received(:render) end end end
Version data entries
7 entries across 7 versions & 1 rubygems