Sha256: e49cfe406e4c1054658b5c9cfef9bcc4ccb397bd468e0563370c0a62791b7068

Contents?: true

Size: 893 Bytes

Versions: 1

Compression:

Stored size: 893 Bytes

Contents

require 'spec_helper'

module RailsBestPractices::Core
  describe Routes do
    let(:routes) { Routes.new }

    it 'should add route' do
      routes.add_route(['admin', 'test'], 'posts', 'new')
      expect(routes.map(&:to_s)).to eq(['Admin::Test::PostsController#new'])
    end

    context 'route' do
      it 'should add namesapces, controller name and action name' do
        route = Route.new(['admin', 'test'], 'posts', 'new')
        expect(route.to_s).to eq('Admin::Test::PostsController#new')
      end

      it 'should add controller name with namespace' do
        route = Route.new(['admin'], 'test/posts', 'new')
        expect(route.to_s).to eq('Admin::Test::PostsController#new')
      end

      it 'should add routes without controller' do
        route = Route.new(['posts'], nil, 'new')
        expect(route.to_s).to eq('PostsController#new')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_best_practices-1.19.1 spec/rails_best_practices/core/routes_spec.rb