Sha256: 680ffaa414d10d791f0003833a4d5f94256807eb1381d9429f45a885e1242d4a

Contents?: true

Size: 1.28 KB

Versions: 18

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Azeroth::ResourceBuilder do
  subject(:resource_builder) { described_class.new(model, builder) }

  let(:model)   { Azeroth::Model.new(:document, options) }
  let(:options) { Azeroth::Options.new }
  let(:builder) { Sinclair.new(klass) }
  let(:klass)   { Class.new(ResourceBuilderController) }

  before do
    resource_builder.append
    create_list(:document, 10)
  end

  describe '#append' do
    it 'adds the listing method' do
      expect { builder.build }
        .to change { klass.new.respond_to?(:documents) }
        .to(true)
    end

    it 'adds the fetching method' do
      expect { builder.build }
        .to change { klass.new.respond_to?(:document) }
        .to(true)
    end

    describe 'after the build' do
      let(:controller) { klass.new(document_id: document.id) }
      let(:document)   { create(:document) }

      before { builder.build }

      context 'when requesting the list of documents' do
        it 'returns the list of documents' do
          expect(controller.documents).to eq(Document.all)
        end
      end

      context 'when requesting one document' do
        it 'returns the requested document' do
          expect(controller.document).to eq(document)
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
azeroth-0.10.1 spec/lib/azeroth/resource_builder_spec.rb
azeroth-0.10.0 spec/lib/azeroth/resource_builder_spec.rb
azeroth-0.9.0 spec/lib/azeroth/resource_builder_spec.rb
azeroth-0.8.2 spec/lib/azeroth/resource_builder_spec.rb
azeroth-0.8.1 spec/lib/azeroth/resource_builder_spec.rb
azeroth-0.8.0 spec/lib/azeroth/resource_builder_spec.rb
azeroth-0.7.4 spec/lib/azeroth/resource_builder_spec.rb
azeroth-0.7.3 spec/lib/azeroth/resource_builder_spec.rb
azeroth-0.7.2 spec/lib/azeroth/resource_builder_spec.rb
azeroth-0.7.1 spec/lib/azeroth/resource_builder_spec.rb
azeroth-0.7.0 spec/lib/azeroth/resource_builder_spec.rb
azeroth-0.6.5 spec/lib/azeroth/resource_builder_spec.rb
azeroth-0.6.4 spec/lib/azeroth/resource_builder_spec.rb
azeroth-0.6.3 spec/lib/azeroth/resource_builder_spec.rb
azeroth-0.6.2 spec/lib/azeroth/resource_builder_spec.rb
azeroth-0.6.1 spec/lib/azeroth/resource_builder_spec.rb
azeroth-0.6.0 spec/lib/azeroth/resource_builder_spec.rb
azeroth-0.5.0 spec/lib/azeroth/resource_builder_spec.rb