views:

35

answers:

1

I'm writing an application and I'm using localization everywhere I can. The problem is that I would like to test it using cucumber. I don't want to update the tests everytime the translation is changed. Is it possible to make cucumber understand something like that:

When I am logged in
Then I should see t(:login_ok)
+2  A: 

Not tested, but I believe something like this should work:

Then /I should see t\(:?([^\)]*)\)/ do |text|
  Then "I should see #{I18n.translate(text)}"
end

This should be in features/step_definitions/???_steps.rb

jigfox
Thanks, this more or less worked - just corrected it to look like:Then /^I press t"([^"]*)"$/ do |text| click_button(I18n.translate(text))endThen /^I should see t"([^"]*)"/ do |text| page.should have_content(I18n.translate(text)) end
j t
This is cool because you get to test your translation keys as well.
Andy Atkinson