Sha256: a1955ff4d1cc8ac4a0f6215f3ecee936e0377e12ba60c39b45a9899cbafe8c65

Contents?: true

Size: 1.42 KB

Versions: 7

Compression:

Stored size: 1.42 KB

Contents

require_relative '../../spec_helper'
require_relative '../../../lib/passages/route_collection'

module Passages
  describe RouteCollection do
    let(:fake_route) { instance_double(Passages::Route) }

    before do
      allow_any_instance_of(described_class).to receive(:main_app_name) do
        'SomeGreatApp'
      end
      allow(fake_route).to receive(:internal?) { false }
    end

    subject { described_class.new([fake_route]) }

    it 'is behaves like an enumerable' do
      expect(subject.respond_to?(:each)).to eq(true)
    end

    describe '#initialize' do
      subject { described_class.new([fake_route]) }

      it 'sets the @routes variable' do
        expect(subject.instance_variable_get(:@routes)).to_not be_nil
      end

      context 'route is internal' do
        before do
          allow(fake_route).to receive(:internal?) { true }
        end

        it 'does not add it to @routes' do
          expect(subject.routes).to be_empty
        end

        context 'internal and external routes exist' do
          let(:another_fake_route) { instance_double(Passages::Route) }
          subject { described_class.new([fake_route, another_fake_route]) }

          before do
            allow(another_fake_route).to receive(:internal?) { false }
          end

          it 'only adds the external route' do
            expect(subject.routes).to eq([another_fake_route])
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
passages-3.0.0 spec/lib/passages/route_collection_spec.rb
passages-2.2.0 spec/lib/passages/route_collection_spec.rb
passages-2.1.0 spec/lib/passages/route_collection_spec.rb
passages-2.0.0 spec/lib/passages/route_collection_spec.rb
passages-1.5.2 spec/lib/passages/route_collection_spec.rb
passages-1.5.0 spec/lib/passages/route_collection_spec.rb
passages-1.4.1 spec/lib/passages/route_collection_spec.rb