Sha256: a903844219c8c9821736a6b64248d4e67fb365d8f04fa4413c34eb17ed06ddc8

Contents?: true

Size: 1.91 KB

Versions: 17

Compression:

Stored size: 1.91 KB

Contents

require 'spec_helper'

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

      describe "rails2" do
        it "should not use default route" do
          content = <<-EOF
          ActionController::Routing::Routes.draw do |map|
            map.resources :posts, member: { push: :post }

            map.connect ':controller/:action/:id'
            map.connect ':controller/:action/:id.:format'
          end
          EOF
          runner.review('config/routes.rb', content)
          runner.should have(2).errors
          runner.errors[0].to_s.should == "config/routes.rb:4 - not use default route"
          runner.errors[1].to_s.should == "config/routes.rb:5 - not use default route"
        end

        it "should no not use default route" do
          content = <<-EOF
          ActionController::Routing::Routes.draw do |map|
            map.resources :posts, member: { push: :post }
          end
          EOF
          runner.review('config/routes.rb', content)
          runner.should have(0).errors
        end
      end

      describe "rails3" do
        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)
          runner.should have(1).errors
          runner.errors[0].to_s.should == "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)
          runner.should have(0).errors
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
rails_best_practices-1.14.4 spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb
rails_best_practices-1.14.3 spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb
rails_best_practices-1.14.2 spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb
rails_best_practices-1.14.1 spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb
rails_best_practices-1.14.0 spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb
rails_best_practices-1.13.8 spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb
rails_best_practices-1.13.5 spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb
rails_best_practices-1.13.4 spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb
rails_best_practices-1.13.3 spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb
rails_best_practices-1.13.2 spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb
rails_best_practices-1.13.1 spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb
rails_best_practices-1.13.0 spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb
rails_best_practices-1.12.0 spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb
rails_best_practices-1.11.1 spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb
rails_best_practices-1.11.0 spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb
rails_best_practices-1.10.1 spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb
rails_best_practices-1.10.0 spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb