Sha256: 4e7594c68bb410635ff796c7524938fb0f44ee8fff1bbe6b9e29b4ebdf5031e9
Contents?: true
Size: 1.59 KB
Versions: 1
Compression:
Stored size: 1.59 KB
Contents
# frozen_string_literal: true require 'spec_helper' describe Azeroth::RoutesBuilder do subject(:routes_builder) do described_class.new( model: model, builder: builder, options: options ) end let(:controller) { controller_class.new } let(:params) { ActionController::Parameters.new(parameters) } let(:model) { Azeroth::Model.new(:document, options) } let(:builder) { Sinclair.new(controller_class) } let(:parameters) { { action: :index, format: :json } } let(:options) { Azeroth::Options.new(options_hash) } let(:options_hash) { {} } let(:expected_json) do Document::Decorator.new(Document.all).as_json end let(:controller_class) do Class.new(ActionController::Base) do include Azeroth::Resourceable def documents Document.all end end end before do create_list(:document, 10) allow(controller).to receive(:params) .and_return(params) allow(controller).to receive(:render) .with(json: expected_json, status: :ok) .and_return(expected_json) end describe '#append' do before { routes_builder.append } it 'adds index route' do expect do builder.build end.to add_method(:index).to(controller) end describe 'when calling index' do before { builder.build } it 'returns the index object' do expect(controller.index).to eq(expected_json) end it 'renders the json' do controller.index expect(controller).to have_received(:render) .with(json: expected_json, status: :ok) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
azeroth-1.0.0 | spec/lib/azeroth/routes_builder_spec.rb |