Sha256: e3ddd77052b3ae6f4113c819bc9cb61040c29570070e9b598cc20be567a72d88

Contents?: true

Size: 903 Bytes

Versions: 7

Compression:

Stored size: 903 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

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

    it 'adds 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 'adds 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 'adds controller name with namespace' do
        route = Route.new(['admin'], 'test/posts', 'new')
        expect(route.to_s).to eq('Admin::Test::PostsController#new')
      end

      it 'adds 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

7 entries across 7 versions & 1 rubygems

Version Path
rails_best_practices-1.23.2 spec/rails_best_practices/core/routes_spec.rb
rails_best_practices-1.23.1 spec/rails_best_practices/core/routes_spec.rb
rails_best_practices-1.23.0 spec/rails_best_practices/core/routes_spec.rb
rails_best_practices-1.22.1 spec/rails_best_practices/core/routes_spec.rb
rails_best_practices-1.22.0 spec/rails_best_practices/core/routes_spec.rb
rails_best_practices-1.21.0 spec/rails_best_practices/core/routes_spec.rb
rails_best_practices-1.20.1 spec/rails_best_practices/core/routes_spec.rb