English 中文(简体)
rspec testing views with internationalization?
原标题:

I want to make sure I have the right meta desc/keyword and title text in my view so I want to create rspec views tests for that. Now the real challange here is how to make it work across multiple languages.

The way I ve done it is:

it "should have the right page title" do
  title = "some nice title here"
  response.should have_tag("title", title)
end

So because the "requirement" is hard coded in that example, I am having a hard time figuring out how to do the same thing for all the other languages in my config/locale/.

I m not sure if this is the best way to do it or should I just fetch the text from the locale/lang.yml like so :

it "should have the right page title" do
  title = t( site.title )
  response.should have_tag("title", title)
end

Thanks

最佳回答

This seems perfectly acceptable. I see no reason to fetch directly from the localization files.

It should give you a good indication that you are indeed using the localized calls throughout your application. You could probably even run your tests under the different locales and that would help you ensure you have all the keys filled out for each one.

It doesn t strike me as any different than testing using fixtures, it still requires that your .yml file be correct, and won t check to make sure you ve created them correctly, but it does help you check that you ve properly used them in your code.

问题回答

暂无回答




相关问题
Selenium not working with Firefox 3.x on linux

I am using selenium-server , selenium rc for UI testing in my application . My dev box is Windows with FireFox 3.5 and every thing is running fine and cool. But when i try to run selenium tests on my ...

Best browser for testing under Safari Mobile on Linux?

I have an iPhone web app I m producing on a Linux machine. What s the best browser I can use to most closely mimic the feature-limited version of Safari present on the iPhone? (It s a "slimmed down" ...

Code Coverage Tools & Visual Studio 2008 Pro

Just wondering what people are using for code coverage tools when using MS Visual Studio 2008 Pro. We are using the built-in MS test project and unit testing tool (the one that come pre-installed ...

Is there any error checking web app cralwers out there?

Wondering if there was some sort of crawler we could use to test and re-test everything when changes are made to the web app so we know some new change didn t error out any existing pages. Or maybe a ...

热门标签