开发者

Rails, Cucumber and localized messages

开发者 https://www.devze.com 2023-01-16 22:41 出处:网络
开发者_开发知识库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
开发者_开发知识库

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)


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

0

精彩评论

暂无评论...
验证码 换一张
取 消