2011-11-15 2 views
0

私はdeviseとlocalized_routesを使用する3.0.6のプロジェクトを取り戻しています。プロジェクトにはテストがありませんので、私はrspecと工場の女の子で非常に簡単なテストを書いています。rspecテストを実行しようとしたときに例外が発生しました。工場出荷時の状態です。

テストを実行するときに、私は(私は信じているテストに無関係である)、エラーを取得しています:

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 

マイ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 

(部分)my route.rb: Dialogcube :: Application.routes.draw do

何が起こっているのか、その時点でコンパイラエラーが発生しているのかわかりません。生成されたメソッドに基づいて、ロケールがen-caであり、ダッシュ文字が何らかの形でコードの一部をねじ込むように見えます。

私はどこを見なければならないのですか?

答えて

0

ロケールがen_caで、en-caではないと思われます。

+0

確かに、アプリケーションのソースコードや、アプリケーションが使用する宝石のソースコードに「en_ca」が具体的に使用されている場所は見つかりません。 –

+0

宝石 'localized_routes'への参照が見つかりませんが、現在のロケールがルートに挿入されていると仮定します。デフォルトのロケールは 'application.rb'またはイニシャライザの中で設定されます。それ以外の場合は 'en'になります。これはデフォルトのレールです。 – nathanvda

+0

- (en-us、en-ca、...)でロケールを宣言し、今は動作しますので、gem 'faker'を削除しました。私にとって、問題は、一般的な習慣である名前に ' - 'が含まれているロケールでは失敗する逸品です。さらに、アプリをテストするにはfakerが必要です。私は何ができるかを確認し、ここに詳しい情報を入れます。 –

関連する問題