<commit_before>require 'spec_helper'

describe :localized_routes do

  @@r = nil # Global routes in order to speed up testing
  
  before(:all) do

    if !@@r
      if !rails3?
        ActionController::Routing::Routes.clear!
        ActionController::Routing::Routes.draw do |map|
          map.not_about 'not_about', :controller => 'not_about'
          map.resources :not_users
          map.resource  :not_contact

          map.localized(I18n.available_locales, :verbose => false) do
            map.about 'about', :controller => 'about', :action => :show

            map.resources :users, :member => {:level => :get}, :collection => {:groups => :get}
            map.resource  :contact

            map.resources :authors do |m|
              m.resources :books
            end

            map.resources :universes do |m|
              m.resources :galaxies do |mm|
                mm.resources :planets do |mmm|
                  mmm.resources :countries
                end
              end
            end
          end
        end
      
        @@r = ActionController::Routing::Routes
      
        class UrlTester
          include ActionController::UrlWriter
        end

      else

        @@r = ActionDispatch::Routing::RouteSet.new
        @@r.draw do
          match 'not_about' => "not_about#show", :as => :not_about
          resources :not_users
          resource  :not_contact

          localized(I18n.available_locales, :verbose => false) do
            match 'about' => "about#show", :as => :about

            resources :users do
              member do
                get :level
              end
              get :groups, :on => :collection
            end
            resource  :contact

            resources :authors do
              resources :books
            end
            
            resources :universes do
              resources :galaxies do
                resources :planets do
                  scope do
                    resources :countries
                  end
                end
              end
            end

          end
        end
           
        class UrlTester; end
        UrlTester.send :include, @@r.url_helpers

      end
    end

  end

  let(:nested_routes) { @@r.named_routes.instance_eval { routes } }
  let(:routes) { UrlTester.new }

  def url_for(opts)
    @@r.generate_extras(opts).first
  end

  context "do not break existing behavior" do

    it "of named_routes" do
      routes.send(:not_about_path).should == "/not_about"
    end

    it "of a singular resource" do
      routes.send(:not_contact_path).should == "/not_contact"
    end

    it "of resources" do
      routes.send(:not_users_path).should == "/not_users"
    end

  end

  context "for default routes" do

    before do
      I18n.locale = :de # Not localized
    end

    it "named_route uses default values" do
      routes.send(:about_path).should == "/about"
    end<commit_msg>Fix warning running specs on ruby 1.9.2<commit_after>require 'spec_helper'

describe :localized_routes do

  $r = nil # Global routes in order to speed up testing
  
  before(:all) do

    if !$r
      if !rails3?
        ActionController::Routing::Routes.clear!
        ActionController::Routing::Routes.draw do |map|
          map.not_about 'not_about', :controller => 'not_about'
          map.resources :not_users
          map.resource  :not_contact

          map.localized(I18n.available_locales, :verbose => false) do
            map.about 'about', :controller => 'about', :action => :show

            map.resources :users, :member => {:level => :get}, :collection => {:groups => :get}
            map.resource  :contact

            map.resources :authors do |m|
              m.resources :books
            end

            map.resources :universes do |m|
              m.resources :galaxies do |mm|
                mm.resources :planets do |mmm|
                  mmm.resources :countries
                end
              end
            end
          end
        end
      
        $r = ActionController::Routing::Routes
      
        class UrlTester
          include ActionController::UrlWriter
        end

      else

        $r = ActionDispatch::Routing::RouteSet.new
        $r.draw do
          match 'not_about' => "not_about#show", :as => :not_about
          resources :not_users
          resource  :not_contact

          localized(I18n.available_locales, :verbose => false) do
            match 'about' => "about#show", :as => :about

            resources :users do
              member do
                get :level
              end
              get :groups, :on => :collection
            end
            resource  :contact

            resources :authors do
              resources :books
            end
            
            resources :universes do
              resources :galaxies do
                resources :planets do
                  scope do
                    resources :countries
                  end
                end
              end
            end

          end
        end
           
        class UrlTester; end
        UrlTester.send :include, $r.url_helpers

      end
    end

  end

  let(:nested_routes) { $r.named_routes.instance_eval { routes } }
  let(:routes) { UrlTester.new }

  def url_for(opts)
    $r.generate_extras(opts).first
  end

  context "do not break existing behavior" do

    it "of named_routes" do
      routes.send(:not_about_path).should == "/not_about"
    end

    it "of a singular resource" do
      routes.send(:not_contact_path).should == "/not_contact"
    end

    it "of resources" do
      routes.send(:not_users_path).should == "/not_users"
    end

  end

  context "for default routes" do

    before do
      I18n.locale = :de # Not localized
    end

    it "named_route uses default values" do
      routes.send(:about_path).should == "/about"
    end
{'fraction_non_alphanumeric': 0.08915254237288135, 'fraction_numerical': 0.00288135593220339, 'mean_word_length': 1.58702323542306, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1857618', 'n_tokens_mistral': 1681, 'n_tokens_neox': 1614, 'n_words': 443}