Sha256: 50ec0bf8c8becd28d4c53b6f77639abf3fd9fc5f4c06357c8290d8c86df6774d

Contents?: true

Size: 918 Bytes

Versions: 5

Compression:

Stored size: 918 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

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

    it 'should add route' do
      routes.add_route(%w[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(%w[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

5 entries across 5 versions & 1 rubygems

Version Path
rails_best_practices-1.20.0 spec/rails_best_practices/core/routes_spec.rb
rails_best_practices-1.19.5 spec/rails_best_practices/core/routes_spec.rb
rails_best_practices-1.19.4 spec/rails_best_practices/core/routes_spec.rb
rails_best_practices-1.19.3 spec/rails_best_practices/core/routes_spec.rb
rails_best_practices-1.19.2 spec/rails_best_practices/core/routes_spec.rb