Commit 42ce2c108022f09e6c8e2fa9a90ea3f74f2b97b4

Authored by Dmitriy Zaporozhets
1 parent 03f6a28e

improve selectors to pass capybara 2.0

app/views/profiles/account.html.haml
... ... @@ -9,7 +9,7 @@
9 9  
10 10  
11 11  
12   -%fieldset
  12 +%fieldset.update-token
13 13 %legend
14 14 Private token
15 15 %span.cred.pull-right
... ... @@ -29,7 +29,7 @@
29 29 %span You don`t have one yet. Click generate to fix it.
30 30 = f.submit 'Generate', class: "btn success btn-build-token"
31 31  
32   -%fieldset
  32 +%fieldset.update-password
33 33 %legend Password
34 34 = form_for @user, url: update_password_profile_path, method: :put do |f|
35 35 .padded
... ...
features/steps/profile/profile.rb
... ... @@ -23,15 +23,19 @@ class Profile < Spinach::FeatureSteps
23 23 end
24 24  
25 25 Then 'I change my password' do
26   - fill_in "user_password", :with => "222333"
27   - fill_in "user_password_confirmation", :with => "222333"
28   - click_button "Save"
  26 + within '.update-password' do
  27 + fill_in "user_password", :with => "222333"
  28 + fill_in "user_password_confirmation", :with => "222333"
  29 + click_button "Save"
  30 + end
29 31 end
30 32  
31 33 When 'I unsuccessfully change my password' do
32   - fill_in "user_password", with: "password"
33   - fill_in "user_password_confirmation", with: "confirmation"
34   - click_button "Save"
  34 + within '.update-password' do
  35 + fill_in "user_password", with: "password"
  36 + fill_in "user_password_confirmation", with: "confirmation"
  37 + click_button "Save"
  38 + end
35 39 end
36 40  
37 41 Then "I should see a password error message" do
... ... @@ -43,8 +47,10 @@ class Profile < Spinach::FeatureSteps
43 47 end
44 48  
45 49 Then 'I reset my token' do
46   - @old_token = @user.private_token
47   - click_button "Reset"
  50 + within '.update-token' do
  51 + @old_token = @user.private_token
  52 + click_button "Reset"
  53 + end
48 54 end
49 55  
50 56 And 'I should see new token' do
... ...
features/steps/shared/diff_note.rb
... ... @@ -22,7 +22,7 @@ module SharedDiffNote
22 22  
23 23 Given 'I leave a diff comment like "Typo, please fix"' do
24 24 find("#586fb7c4e1add2d4d24e27566ed7064680098646_29_14.line_holder .js-add-diff-note-button").trigger("click")
25   - within(".file") do
  25 + within(".file form[rel$='586fb7c4e1add2d4d24e27566ed7064680098646_29_14']") do
26 26 fill_in "note[note]", with: "Typo, please fix"
27 27 #click_button("Add Comment")
28 28 find(".js-comment-button").trigger("click")
... ... @@ -32,7 +32,7 @@ module SharedDiffNote
32 32  
33 33 Given 'I preview a diff comment text like "Should fix it :smile:"' do
34 34 find("#586fb7c4e1add2d4d24e27566ed7064680098646_29_14.line_holder .js-add-diff-note-button").trigger("click")
35   - within(".file") do
  35 + within(".file form[rel$='586fb7c4e1add2d4d24e27566ed7064680098646_29_14']") do
36 36 fill_in "note[note]", with: "Should fix it :smile:"
37 37 find(".js-note-preview-button").trigger("click")
38 38 end
... ... @@ -40,7 +40,7 @@ module SharedDiffNote
40 40  
41 41 Given 'I preview another diff comment text like "DRY this up"' do
42 42 find("#586fb7c4e1add2d4d24e27566ed7064680098646_57_41.line_holder .js-add-diff-note-button").trigger("click")
43   - within(".file") do
  43 + within(".file form[rel$='586fb7c4e1add2d4d24e27566ed7064680098646_57_41']") do
44 44 fill_in "note[note]", with: "DRY this up"
45 45 find(".js-note-preview-button").trigger("click")
46 46 end
... ...
spec/spec_helper.rb
... ... @@ -10,14 +10,13 @@ require 'capybara/rspec'
10 10 require 'webmock/rspec'
11 11 require 'email_spec'
12 12 require 'sidekiq/testing/inline'
  13 +require 'capybara/poltergeist'
  14 +Capybara.javascript_driver = :poltergeist
13 15  
14 16 # Requires supporting ruby files with custom matchers and macros, etc,
15 17 # in spec/support/ and its subdirectories.
16 18 Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
17 19  
18   -require 'capybara/poltergeist'
19   -Capybara.javascript_driver = :poltergeist
20   -
21 20 WebMock.disable_net_connect!(allow_localhost: true)
22 21  
23 22 RSpec.configure do |config|
... ...