0
votes

I am taking back a project in rails 3.0.3 that make uses of devise and localized_routes. The project doesn't have any tests and so I've wrote a very simple test with rspec and factory girl.

when executing the test, I'm getting an error (which is unrelated to the test I believe):

rspec spec/helpers/application_helper_spec.rb

    /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:163:in `define_hash_access': compile error (SyntaxError)
    /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:161: syntax error, unexpected '-', expecting '\n' or ';'
    ... hash_for_new_user_session_en-ca_path(options = nil)        ...
                                  ^
    /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:163: syntax error, unexpected kEND, expecting $end
                  end                              ...
                     ^
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:151:in `define_named_route_methods'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:149:in `each'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:149:in `define_named_route_methods'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:100:in `[]='
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:300:in `add_route_without_i18n'
        from /Users/pl/src/dialogcube/vendor/plugins/localized_routes/lib/localized_routes.rb:21:in `add_route'
        from /Users/pl/src/dialogcube/vendor/plugins/localized_routes/lib/localized_routes.rb:12:in `each'
        from /Users/pl/src/dialogcube/vendor/plugins/localized_routes/lib/localized_routes.rb:12:in `add_route'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:262:in `match'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1112:in `match'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1297:in `match'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1094:in `match'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1015:in `member'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:525:in `scope'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1014:in `member'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1199:in `with_scope_level'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1013:in `member'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1094:in `match'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1297:in `match'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:383:in `map_method'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:312:in `get'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:206:in `devise_session'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:898:in `resource'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1208:in `resource_scope'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:525:in `scope'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1207:in `resource_scope'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1199:in `with_scope_level'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1206:in `resource_scope'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:897:in `resource'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:205:in `devise_session'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:157:in `send'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:157:in `devise_for'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:157:in `each'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:157:in `devise_for'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:237:in `with_devise_exclusive_scope'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:156:in `devise_for'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:197:in `devise_scope'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:661:in `constraints'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:525:in `scope'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:661:in `constraints'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:196:in `devise_scope'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:154:in `devise_for'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:136:in `each'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:136:in `devise_for'
        from /Users/pl/src/dialogcube/config/routes.rb:10
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:233:in `instance_exec'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:233:in `draw'
        from /Users/pl/src/dialogcube/config/routes.rb:1
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:227:in `load_dependency'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/railties-3.0.3/lib/rails/application.rb:127:in `reload_routes!'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/railties-3.0.3/lib/rails/application.rb:127:in `each'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/railties-3.0.3/lib/rails/application.rb:127:in `reload_routes!'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails.rb:17
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:34:in `call'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:34:in `execute_hook'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:43:in `run_load_hooks'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:42:in `each'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/railties-3.0.3/lib/rails/application/finisher.rb:40
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `instance_exec'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `run'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/railties-3.0.3/lib/rails/initializable.rb:50:in `run_initializers'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `each'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `run_initializers'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/railties-3.0.3/lib/rails/application.rb:134:in `initialize!'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/railties-3.0.3/lib/rails/application.rb:77:in `send'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing'
        from /Users/pl/src/dialogcube/config/environment.rb:5
        from /Users/pl/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:54:in `gem_original_require'
        from /Users/pl/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:54:in `require'
        from /Users/pl/src/dialogcube/spec/spec_helper.rb:3
        from /Users/pl/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:54:in `gem_original_require'
        from /Users/pl/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:54:in `require'
        from /Users/pl/src/dialogcube/spec/helpers/application_helper_spec.rb:1
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `load'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `load_spec_files'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `map'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `load_spec_files'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.7.1/lib/rspec/core/command_line.rb:18:in `run'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:80:in `run_in_process'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:69:in `run'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:10:in `autorun'
        from /Users/pl/.rvm/gems/ruby-1.8.7-p334/bin/rspec:19

application_helper_spec.rb:

require 'spec_helper'

describe ApplicationHelper do
  it 'should return a analytics tag' do
    s = Factory.build(:analytics_setting)
    result = analytics_tag
    result.should_not be_nil
  end
end

My spec_helper.rb:

# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'faker'
require 'factory_girl'
require 'rspec/autorun'

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

RSpec.configure do |config|
  # == Mock Framework
  #
  # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
  #
  # config.mock_with :mocha
  # config.mock_with :flexmock
  # config.mock_with :rr
  config.mock_with :rspec

  # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
  config.fixture_path = "#{::Rails.root}/spec/fixtures"

  # If you're not using ActiveRecord, or you'd prefer not to run each of your
  # examples within a transaction, remove the following line or assign false
  # instead of true.
  config.use_transactional_fixtures = true

  # If true, the base class of anonymous controllers will be inferred
  # automatically. This will be the default behavior in future versions of
  # rspec-rails.
  config.infer_base_class_for_anonymous_controllers = false
end

(part of) my route.rb: Dialogcube::Application.routes.draw do

  # Omniauth

  match '/auth/:provider/callback' => 'authentications#create', :i18n => false
  match '/auth/external/:provider' => 'authentications#show',   :i18n => false

  # Public

  devise_for :users,
             :path => 'auth',
             :controllers => {
               :registrations => 'registrations',
               :sessions      => 'sessions',
               :passwords     => 'passwords'
              }

  resources :users do
    put :follow_tag,  :on => :member
    put :unfollow_tag, :on => :member
    resources :entries
  end

I can't figure out what's going on or why is there a compiler error at that point. It seem, based on the generated method that the locale is en-ca and that the dash characters somehow screws up some part of the code.

Any leads on where I should look?

1

1 Answers

0
votes

I think it expects the locale to be en_ca and not en-ca.