From 42ce2c108022f09e6c8e2fa9a90ea3f74f2b97b4 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 21 Feb 2013 11:27:22 +0200 Subject: [PATCH] improve selectors to pass capybara 2.0 --- app/views/profiles/account.html.haml | 4 ++-- features/steps/profile/profile.rb | 22 ++++++++++++++-------- features/steps/shared/diff_note.rb | 6 +++--- spec/spec_helper.rb | 5 ++--- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/app/views/profiles/account.html.haml b/app/views/profiles/account.html.haml index 5b6c298df..b20d5c7a6 100644 --- a/app/views/profiles/account.html.haml +++ b/app/views/profiles/account.html.haml @@ -9,7 +9,7 @@ -%fieldset +%fieldset.update-token %legend Private token %span.cred.pull-right @@ -29,7 +29,7 @@ %span You don`t have one yet. Click generate to fix it. = f.submit 'Generate', class: "btn success btn-build-token" -%fieldset +%fieldset.update-password %legend Password = form_for @user, url: update_password_profile_path, method: :put do |f| .padded diff --git a/features/steps/profile/profile.rb b/features/steps/profile/profile.rb index b6833f2bd..e5a39abcc 100644 --- a/features/steps/profile/profile.rb +++ b/features/steps/profile/profile.rb @@ -23,15 +23,19 @@ class Profile < Spinach::FeatureSteps end Then 'I change my password' do - fill_in "user_password", :with => "222333" - fill_in "user_password_confirmation", :with => "222333" - click_button "Save" + within '.update-password' do + fill_in "user_password", :with => "222333" + fill_in "user_password_confirmation", :with => "222333" + click_button "Save" + end end When 'I unsuccessfully change my password' do - fill_in "user_password", with: "password" - fill_in "user_password_confirmation", with: "confirmation" - click_button "Save" + within '.update-password' do + fill_in "user_password", with: "password" + fill_in "user_password_confirmation", with: "confirmation" + click_button "Save" + end end Then "I should see a password error message" do @@ -43,8 +47,10 @@ class Profile < Spinach::FeatureSteps end Then 'I reset my token' do - @old_token = @user.private_token - click_button "Reset" + within '.update-token' do + @old_token = @user.private_token + click_button "Reset" + end end And 'I should see new token' do diff --git a/features/steps/shared/diff_note.rb b/features/steps/shared/diff_note.rb index 048623380..9dbbc5531 100644 --- a/features/steps/shared/diff_note.rb +++ b/features/steps/shared/diff_note.rb @@ -22,7 +22,7 @@ module SharedDiffNote Given 'I leave a diff comment like "Typo, please fix"' do find("#586fb7c4e1add2d4d24e27566ed7064680098646_29_14.line_holder .js-add-diff-note-button").trigger("click") - within(".file") do + within(".file form[rel$='586fb7c4e1add2d4d24e27566ed7064680098646_29_14']") do fill_in "note[note]", with: "Typo, please fix" #click_button("Add Comment") find(".js-comment-button").trigger("click") @@ -32,7 +32,7 @@ module SharedDiffNote Given 'I preview a diff comment text like "Should fix it :smile:"' do find("#586fb7c4e1add2d4d24e27566ed7064680098646_29_14.line_holder .js-add-diff-note-button").trigger("click") - within(".file") do + within(".file form[rel$='586fb7c4e1add2d4d24e27566ed7064680098646_29_14']") do fill_in "note[note]", with: "Should fix it :smile:" find(".js-note-preview-button").trigger("click") end @@ -40,7 +40,7 @@ module SharedDiffNote Given 'I preview another diff comment text like "DRY this up"' do find("#586fb7c4e1add2d4d24e27566ed7064680098646_57_41.line_holder .js-add-diff-note-button").trigger("click") - within(".file") do + within(".file form[rel$='586fb7c4e1add2d4d24e27566ed7064680098646_57_41']") do fill_in "note[note]", with: "DRY this up" find(".js-note-preview-button").trigger("click") end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c138d9a63..f6f70cfd9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -10,14 +10,13 @@ require 'capybara/rspec' require 'webmock/rspec' require 'email_spec' require 'sidekiq/testing/inline' +require 'capybara/poltergeist' +Capybara.javascript_driver = :poltergeist # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} -require 'capybara/poltergeist' -Capybara.javascript_driver = :poltergeist - WebMock.disable_net_connect!(allow_localhost: true) RSpec.configure do |config| -- 2.11.0