2012-03-05 12 views
2

私のCapybarasテストは、指定されたロケールではなくデフォルトロケールでのみ動作します。Cany pass:ロケールからCapybaraのメソッド訪問

describe "How it works" do 
    it "should have the content 'how it works'" do 
    visit how_it_works_url(:locale => :en) 
    page.should have_content('How it works')  
    end 
    it "should have the content 'wie es geht'" do 
    visit how_it_works_url(:locale => :de) 
    page.should have_content('Wie es geht')  
    end 
end 

default_localeが 'en'の場合、最初のテストが成功し、 'de'の場合は2番目のテストが合格になります。

ルートは翻訳されません(私はgem 'rails-translate-routes'も使用しません)。

答えて

2

多分これは役立ちます:

パスはRSpecのためcapybara

を使用しているときに、たとえばspec/support/locale.rbでは、このスニペットを置くことができます正常に動作しません:

# workaround, to set default locale for ALL spec 
class ActionView::TestCase::TestController 
    def default_url_options(options={}) 
    { :locale => I18n.default_locale } 
    end 
end 

class ActionDispatch::Routing::RouteSet 
    def default_url_options(options={}) 
    { :locale => I18n.default_locale } 
    end 
end 

ルックhere詳細については。

関連する問題