Sha256: 87791e141c3ab30feffcd60299610b80eb0f79fdec3633bcc7001b0b1fe055bc
Contents?: true
Size: 1.23 KB
Versions: 2
Compression:
Stored size: 1.23 KB
Contents
# frozen_string_literal: true shared_examples 'a request handler' do subject(:handler) { described_class.new(controller, model) } let(:controller) { controller_class.new } let(:params) { ActionController::Parameters.new(parameters) } let(:model) { Azeroth::Model.new(:document) } 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) .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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
azeroth-0.2.0 | spec/support/shared_examples/request_handler.rb |
azeroth-0.1.0 | spec/support/shared_examples/request_handler.rb |