Sha256: 028b0d3ff8fe3860d9016dc879dd740854d2364e12de9b8737ac010e37942939
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
# frozen_string_literal: true require 'spec_helper' describe Azeroth::RoutesBuilder do subject(:routes_builder) do described_class.new(model, builder, options) end let(:controller) { controller_class.new } let(:params) { ActionController::Parameters.new(parameters) } let(:model) { Azeroth::Model.new(:document) } 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
azeroth-0.4.0 | spec/lib/azeroth/routes_builder_spec.rb |
azeroth-0.3.0 | spec/lib/azeroth/routes_builder_spec.rb |