Sha256: 385e6a5ba616d94cd5768a762d6f814e1d1ba880b52ff5b32d56b0fe9034cab8

Contents?: true

Size: 1.39 KB

Versions: 5

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

module RailsBestPractices
  module Reviews
    describe NotUseDefaultRouteReview do
      let(:runner) { Core::Runner.new(reviews: NotUseDefaultRouteReview.new) }

      it 'should not use default route' do
        content = <<-EOF
        RailsBestpracticesCom::Application.routes.draw do |map|
          resources :posts

          match ':controller(/:action(/:id(.:format)))'
        end
        EOF
        runner.review('config/routes.rb', content)
        expect(runner.errors.size).to eq(1)
        expect(runner.errors[0].to_s).to eq('config/routes.rb:4 - not use default route')
      end

      it 'should no not use default route' do
        content = <<-EOF
        RailsBestpracticesCom::Application.routes.draw do |map|
          resources :posts
        end
        EOF
        runner.review('config/routes.rb', content)
        expect(runner.errors.size).to eq(0)
      end

      it 'should not check ignored files' do
        runner = Core::Runner.new(reviews: NotUseDefaultRouteReview.new(ignored_files: /config\/routes\.rb/))
        content = <<-EOF
        RailsBestpracticesCom::Application.routes.draw do |map|
          resources :posts

          match ':controller(/:action(/:id(.:format)))'
        end
        EOF
        runner.review('config/routes.rb', content)
        expect(runner.errors.size).to eq(0)
      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/reviews/not_use_default_route_review_spec.rb
rails_best_practices-1.19.5 spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb
rails_best_practices-1.19.4 spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb
rails_best_practices-1.19.3 spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb
rails_best_practices-1.19.2 spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb