2017-10-06 7 views
1

RSpec、Capybara、SeleniumでRuby on Railsアプリケーションをテストしています。Capybaraはevent.preventDefaultを気にしません

hrefのアンカーをクリックしたいのですが、event.preventDefaultのためにどこにも通ってはいけません。それにもかかわらず、リンクは現在のページの上に残るのではなくリンクされたページにテストを導く。

私の最初の印象は、Javascriptが動作していないということです。。他のテストに加えて、私はFirefoxがいくつかのことをしているのを見ることができますが、私はこの特定のテストのために同じことを言うことができます。私が行方不明のものはありますか?

ダミーのアプリケーションevent.preventDefaultのページをテストすると、意図したとおりに動作します。

現在のテストでは、次のとおりです。

describe "In field group editor, user", type: :feature do 

    let(:user) { User.first } 

    before(:context) do 
     @structure = create(:structure) 
    end 

    it "should be able to create a checkbox" do 
     sign_in user 

     # should be login page 
     save_and_open_page # and it is 

     path_to_structure = edit_structure_path(structure_id: @structure.slug) 
     visit path_to_structure 

     find "#add-new-setting" 

     # should be structure page 
     save_and_open_page # and it is 

     click_on "add-new-setting" # this should fire an ajax call and preventDefault link behaviour 

     # should be still structure page 
     save_and_open_page # instead capybara it's gone to the new setting page 

     # ... 
    end 
end 

答えて

0

私はちょうど最初の説明でjs: trueを追加するのを忘れ。

私は誰か他の人が同様の問題を解決するために時間を失う可能性があり、その解決策を実現することが簡単ではなかったので、質問を削除しません!

関連する問題