简体   繁体   English

如何从黄瓜步骤访问语言字符串?

[英]How can I access language strings from a cucumber step?

I'm trying to do this: 我正在尝试这样做:

Then /^I should see a message saying I have no narratives$/ do
  page.should have_content t(:no_narratives_on_recent_activity_page)
end

but t() is not available. 但是t()不可用。 The idea is that if I enter the expected text manually, then alter the i18n string later it'll break the step, so I want to test using the i18n string in the first place. 想法是,如果我手动输入所需的文本,然后稍后更改i18n字符串,则会中断该步骤,因此我想首先使用i18n字符串进行测试。

How can I access the t() helper (or something equivalent) in the cucumber step? 我如何在黄瓜步骤中访问t()助手(或类似的东西)?

I18n should be loaded, so you can simply send methods directly (rather than using helpers) 应该加载I18n ,因此您可以直接直接发送方法(而不是使用帮助器)

Then /^I should see a message saying I have no narratives$/ do
  page.should have_content I18n.t(:no_narratives_on_recent_activity_page)
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM