2017-12-16 15 views
0

env.rb가 =>오이의 단계 정의에 I18n 기능을 추가하려면 어떻게해야합니까?

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 

단계> i는 단계 정의 안에 내 I18n.t 함수를 참조 할 수있는 방법

expect(@browser.text.include?(I18N.t('successful-adoption'))).to be true 

는 어떻게로 전달한다 =은 " 세계 "에서 사용할 수 있습니까?

YML =>

--- 
en: 
    successful-adoption: "Thank you for adopting a puppy!" 

오류는 다음과 같습니다

+0

[보석] (https://github.com/svenfuchs/i18n)을 추가하셨습니까? –

+0

그래, 난 그것을 해결할 것, 오이에 대한 후크 내부 @ locale = I18n 추가 할 수있는 로캘에 대한 단계 정의 액세스를 허용하는 다음 @ locale.t ('이름 - 여기') 호출 할 수 있습니다; – Jackofspace

답변

0

uninitialized constant I18N (NameError)는 단순히 @Before 방법 후크 내부 인스턴스 VAR를 추가합니다.

Before do |scenario| 
    @locale = I18n 
    @log = setup_logger("#{scenario.name}") 
    @log.debug("Starting scenario: #{scenario.name}") 
    end