Sha256: 337cd5ea6bad255a234b8589e69502e0b9ace1479d5fb7a0416b3687c9b3c082

Contents?: true

Size: 1.71 KB

Versions: 7

Compression:

Stored size: 1.71 KB

Contents

require_relative '../../spec_helper'
require_relative '../../../lib/passages/route'

module Passages
  describe Route do
    subject { described_class.new(anything) }

    describe '#name' do
      it 'calls name on the __getobj__' do
        expect(subject.__getobj__).to receive(:name)
        subject.name
      end
    end

    describe '#verb' do
      it 'calls verb on the __getobj__' do
        expect(subject.__getobj__).to receive(:verb)
        subject.verb
      end
    end

    describe '#controller' do
      it 'calls controller on the __getobj__' do
        expect(subject.__getobj__).to receive(:controller)
        subject.controller
      end
    end

    describe '#action' do
      it 'calls action on the __getobj__' do
        expect(subject.__getobj__).to receive(:action)
        subject.action
      end
    end

    describe '#path' do
      it 'calls path on the __getobj__' do
        expect(subject.__getobj__).to receive(:path)
        subject.path
      end
    end

    describe '.from_raw_route' do
      let(:raw_route) { anything }
      before do
        allow(described_class).to receive(:mount_route_class) { mount_class }
      end

      context 'mount class is present' do
        let(:mount_class) { anything }
        it 'instantiates and returns a new MountRoute' do
          expect(MountRoute).to receive(:new).with(raw_route, mount_class)
          described_class.from_raw_route(raw_route)
        end
      end

      context 'mount class is nil' do
        let(:mount_class) { nil }
        it 'instantiates and returns a new Route' do
          expect(described_class).to receive(:new).with(raw_route)
          described_class.from_raw_route(raw_route)
        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_spec.rb
passages-2.2.0 spec/lib/passages/route_spec.rb
passages-2.1.0 spec/lib/passages/route_spec.rb
passages-2.0.0 spec/lib/passages/route_spec.rb
passages-1.5.2 spec/lib/passages/route_spec.rb
passages-1.5.0 spec/lib/passages/route_spec.rb
passages-1.4.1 spec/lib/passages/route_spec.rb