2016-09-01 5 views
0

私はに呼び出される関数の下パブリック/グローバル関数は、すべての機能検査で利用可能である必要があります)などのすべての機能検査、欲しい:テストのほとんどは最初のログインを必要とするのでminitest-rails-capybaraで使用するグローバル関数はどこに追加できますか?

を。

def feature_login(username, password) 
    scenario 'user sign in with valid data' do 
    within 'form' do 
     fill_in 'username', with: username 
     fill_in 'password', with: password 
     click_button 'continue' 
    end 
    end 
end 

私はtest_helper.rbに上記のコードを入れてみましたが、私は得た:

NoMethodError: undefined method `scenario' 

構文が異なっているように思え(通常の機能テストでは好きではありません)。私のログイン機能検査で

require "test_helper" 

    feature "Login" do 
    before do 
     visit root_path 
    end 

    scenario 'user sign in with valid data' do 
     feature_login('admin', 'my_pass') # so I can simply call like this.  
     page.current_path.must_equal '/en/home' 
    end 
    end 

私はfeature_login( '管理者'、 'MY_PASS') のように、パブリック関数を呼びたいです。

どのようにすればいいですか?

助けてください!

答えて

0

解決済み:

ああ、私はそれを理解しました。

シナリオブロックを削除するだけです。

私のテストでは/ test_helper.rb。

def feature_login(username, password) 
     within 'form' do 
     fill_in 'username', with: username 
     fill_in 'password', with: password 
     click_button 'continue' 
     end 
    end 
関連する問題