簡體   English   中英

如何從黃瓜步驟訪問語言字符串?

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

我正在嘗試這樣做:

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

但是t()不可用。 想法是,如果我手動輸入所需的文本,然后稍后更改i18n字符串,則會中斷該步驟,因此我想首先使用i18n字符串進行測試。

我如何在黃瓜步驟中訪問t()助手(或類似的東西)?

應該加載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