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