env.rb =>
def setup_language_resources
I18n.load_path = ['features/configuration_resources/english.yml']
case ENV['Language']
when 'english'
I18n.locale = :en
when 'spanish'
I18n.locale = :es
when 'italian'
I18n.locale = :it
else
abort("Incorrect language set, cannot continue the test run: supported are 'english', 'italian' or 'spanish'")
end
end
setup_language_resources
steps =>
expect(@browser.text.include?(I18N.t('successful-adoption'))).to be true
我如何在步骤定义中引用我的I18n.t函数,我应该如何将它传递到“世界”以使其在那里可用?
yml =>
---
en:
successful-adoption: "Thank you for adopting a puppy!"
错误是:uninitialized constant I18N (NameError)
答案 0 :(得分:0)
只需在钩子@before方法中添加一个实例var。
Before do |scenario|
@locale = I18n
@log = setup_logger("#{scenario.name}")
@log.debug("Starting scenario: #{scenario.name}")
end