capybara 2.2.1 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +26 -0
  3. data/README.md +36 -14
  4. data/lib/capybara.rb +6 -3
  5. data/lib/capybara/driver/base.rb +37 -1
  6. data/lib/capybara/driver/node.rb +10 -2
  7. data/lib/capybara/helpers.rb +21 -13
  8. data/lib/capybara/node/base.rb +12 -7
  9. data/lib/capybara/node/element.rb +17 -1
  10. data/lib/capybara/node/finders.rb +22 -1
  11. data/lib/capybara/node/matchers.rb +26 -5
  12. data/lib/capybara/node/simple.rb +9 -2
  13. data/lib/capybara/rack_test/css_handlers.rb +3 -1
  14. data/lib/capybara/rack_test/form.rb +3 -2
  15. data/lib/capybara/rack_test/node.rb +3 -3
  16. data/lib/capybara/rspec.rb +1 -0
  17. data/lib/capybara/rspec/features.rb +2 -1
  18. data/lib/capybara/rspec/matchers.rb +50 -5
  19. data/lib/capybara/selenium/driver.rb +76 -12
  20. data/lib/capybara/selenium/node.rb +8 -0
  21. data/lib/capybara/server.rb +1 -1
  22. data/lib/capybara/session.rb +234 -29
  23. data/lib/capybara/spec/public/jquery.js +1 -1
  24. data/lib/capybara/spec/public/test.js +7 -0
  25. data/lib/capybara/spec/session/all_spec.rb +88 -17
  26. data/lib/capybara/spec/session/assert_selector.rb +6 -0
  27. data/lib/capybara/spec/session/attach_file_spec.rb +15 -15
  28. data/lib/capybara/spec/session/body_spec.rb +4 -4
  29. data/lib/capybara/spec/session/check_spec.rb +16 -16
  30. data/lib/capybara/spec/session/choose_spec.rb +5 -5
  31. data/lib/capybara/spec/session/click_button_spec.rb +93 -84
  32. data/lib/capybara/spec/session/click_link_or_button_spec.rb +8 -8
  33. data/lib/capybara/spec/session/click_link_spec.rb +26 -19
  34. data/lib/capybara/spec/session/current_scope_spec.rb +3 -3
  35. data/lib/capybara/spec/session/current_url_spec.rb +8 -8
  36. data/lib/capybara/spec/session/evaluate_script_spec.rb +1 -1
  37. data/lib/capybara/spec/session/execute_script_spec.rb +2 -2
  38. data/lib/capybara/spec/session/fill_in_spec.rb +22 -22
  39. data/lib/capybara/spec/session/find_button_spec.rb +4 -4
  40. data/lib/capybara/spec/session/find_by_id_spec.rb +3 -3
  41. data/lib/capybara/spec/session/find_field_spec.rb +7 -7
  42. data/lib/capybara/spec/session/find_link_spec.rb +4 -4
  43. data/lib/capybara/spec/session/find_spec.rb +46 -46
  44. data/lib/capybara/spec/session/first_spec.rb +23 -23
  45. data/lib/capybara/spec/session/go_back_spec.rb +3 -3
  46. data/lib/capybara/spec/session/go_forward_spec.rb +4 -4
  47. data/lib/capybara/spec/session/has_button_spec.rb +13 -13
  48. data/lib/capybara/spec/session/has_css_spec.rb +87 -87
  49. data/lib/capybara/spec/session/has_field_spec.rb +87 -87
  50. data/lib/capybara/spec/session/has_link_spec.rb +11 -11
  51. data/lib/capybara/spec/session/has_select_spec.rb +58 -58
  52. data/lib/capybara/spec/session/has_selector_spec.rb +48 -48
  53. data/lib/capybara/spec/session/has_table_spec.rb +7 -7
  54. data/lib/capybara/spec/session/has_text_spec.rb +73 -73
  55. data/lib/capybara/spec/session/has_title_spec.rb +10 -10
  56. data/lib/capybara/spec/session/has_xpath_spec.rb +44 -44
  57. data/lib/capybara/spec/session/headers.rb +1 -1
  58. data/lib/capybara/spec/session/html_spec.rb +9 -9
  59. data/lib/capybara/spec/session/node_spec.rb +81 -65
  60. data/lib/capybara/spec/session/reset_session_spec.rb +15 -15
  61. data/lib/capybara/spec/session/response_code.rb +1 -1
  62. data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +46 -0
  63. data/lib/capybara/spec/session/save_page_spec.rb +9 -9
  64. data/lib/capybara/spec/session/{screenshot.rb → screenshot_spec.rb} +4 -2
  65. data/lib/capybara/spec/session/select_spec.rb +22 -22
  66. data/lib/capybara/spec/session/text_spec.rb +15 -10
  67. data/lib/capybara/spec/session/title_spec.rb +2 -2
  68. data/lib/capybara/spec/session/uncheck_spec.rb +7 -7
  69. data/lib/capybara/spec/session/unselect_spec.rb +14 -14
  70. data/lib/capybara/spec/session/visit_spec.rb +24 -17
  71. data/lib/capybara/spec/session/window/become_closed_spec.rb +84 -0
  72. data/lib/capybara/spec/session/window/current_window_spec.rb +25 -0
  73. data/lib/capybara/spec/session/window/open_new_window_spec.rb +28 -0
  74. data/lib/capybara/spec/session/window/switch_to_window_spec.rb +114 -0
  75. data/lib/capybara/spec/session/window/window_opened_by_spec.rb +83 -0
  76. data/lib/capybara/spec/session/window/window_spec.rb +141 -0
  77. data/lib/capybara/spec/session/window/windows_spec.rb +31 -0
  78. data/lib/capybara/spec/session/window/within_window_spec.rb +188 -0
  79. data/lib/capybara/spec/session/within_frame_spec.rb +9 -9
  80. data/lib/capybara/spec/session/within_spec.rb +16 -16
  81. data/lib/capybara/spec/spec_helper.rb +14 -4
  82. data/lib/capybara/spec/views/form.erb +7 -0
  83. data/lib/capybara/spec/views/popup_one.erb +1 -1
  84. data/lib/capybara/spec/views/popup_two.erb +1 -1
  85. data/lib/capybara/spec/views/with_js.erb +2 -0
  86. data/lib/capybara/spec/views/with_windows.erb +38 -0
  87. data/lib/capybara/version.rb +1 -1
  88. data/lib/capybara/window.rb +123 -0
  89. data/spec/basic_node_spec.rb +32 -32
  90. data/spec/capybara_spec.rb +6 -7
  91. data/spec/dsl_spec.rb +48 -48
  92. data/spec/fixtures/selenium_driver_rspec_failure.rb +2 -2
  93. data/spec/fixtures/selenium_driver_rspec_success.rb +2 -2
  94. data/spec/rack_test_spec.rb +33 -19
  95. data/spec/result_spec.rb +13 -13
  96. data/spec/rspec/features_spec.rb +20 -15
  97. data/spec/rspec/matchers_spec.rb +109 -109
  98. data/spec/rspec_spec.rb +10 -10
  99. data/spec/selenium_spec.rb +31 -6
  100. data/spec/selenium_spec_chrome.rb +2 -2
  101. data/spec/server_spec.rb +13 -13
  102. metadata +51 -62
  103. checksums.yaml.gz.sig +0 -0
  104. data.tar.gz.sig +0 -0
  105. data/lib/capybara/spec/session/within_window_spec.rb +0 -45
  106. data/lib/capybara/spec/views/within_popups.erb +0 -25
  107. metadata.gz.sig +0 -0
@@ -4,60 +4,60 @@ Capybara::SpecHelper.spec '#has_xpath?' do
4
4
  end
5
5
 
6
6
  it "should be true if the given selector is on the page" do
7
- @session.should have_xpath("//p")
8
- @session.should have_xpath("//p//a[@id='foo']")
9
- @session.should have_xpath("//p[contains(.,'est')]")
7
+ expect(@session).to have_xpath("//p")
8
+ expect(@session).to have_xpath("//p//a[@id='foo']")
9
+ expect(@session).to have_xpath("//p[contains(.,'est')]")
10
10
  end
11
11
 
12
12
  it "should be false if the given selector is not on the page" do
13
- @session.should_not have_xpath("//abbr")
14
- @session.should_not have_xpath("//p//a[@id='doesnotexist']")
15
- @session.should_not have_xpath("//p[contains(.,'thisstringisnotonpage')]")
13
+ expect(@session).not_to have_xpath("//abbr")
14
+ expect(@session).not_to have_xpath("//p//a[@id='doesnotexist']")
15
+ expect(@session).not_to have_xpath("//p[contains(.,'thisstringisnotonpage')]")
16
16
  end
17
17
 
18
18
  it "should use xpath even if default selector is CSS" do
19
19
  Capybara.default_selector = :css
20
- @session.should_not have_xpath("//p//a[@id='doesnotexist']")
20
+ expect(@session).not_to have_xpath("//p//a[@id='doesnotexist']")
21
21
  end
22
22
 
23
23
  it "should respect scopes" do
24
24
  @session.within "//p[@id='first']" do
25
- @session.should have_xpath(".//a[@id='foo']")
26
- @session.should_not have_xpath(".//a[@id='red']")
25
+ expect(@session).to have_xpath(".//a[@id='foo']")
26
+ expect(@session).not_to have_xpath(".//a[@id='red']")
27
27
  end
28
28
  end
29
29
 
30
30
  it "should wait for content to appear", :requires => [:js] do
31
31
  @session.visit('/with_js')
32
32
  @session.click_link('Click me')
33
- @session.should have_xpath("//input[@type='submit' and @value='New Here']")
33
+ expect(@session).to have_xpath("//input[@type='submit' and @value='New Here']")
34
34
  end
35
35
 
36
36
  context "with count" do
37
37
  it "should be true if the content occurs the given number of times" do
38
- @session.should have_xpath("//p", :count => 3)
39
- @session.should have_xpath("//p//a[@id='foo']", :count => 1)
40
- @session.should have_xpath("//p[contains(.,'est')]", :count => 1)
41
- @session.should have_xpath("//p//a[@id='doesnotexist']", :count => 0)
38
+ expect(@session).to have_xpath("//p", :count => 3)
39
+ expect(@session).to have_xpath("//p//a[@id='foo']", :count => 1)
40
+ expect(@session).to have_xpath("//p[contains(.,'est')]", :count => 1)
41
+ expect(@session).to have_xpath("//p//a[@id='doesnotexist']", :count => 0)
42
42
  end
43
43
 
44
44
  it "should be false if the content occurs a different number of times than the given" do
45
- @session.should_not have_xpath("//p", :count => 6)
46
- @session.should_not have_xpath("//p//a[@id='foo']", :count => 2)
47
- @session.should_not have_xpath("//p[contains(.,'est')]", :count => 5)
48
- @session.should_not have_xpath("//p//a[@id='doesnotexist']", :count => 1)
45
+ expect(@session).not_to have_xpath("//p", :count => 6)
46
+ expect(@session).not_to have_xpath("//p//a[@id='foo']", :count => 2)
47
+ expect(@session).not_to have_xpath("//p[contains(.,'est')]", :count => 5)
48
+ expect(@session).not_to have_xpath("//p//a[@id='doesnotexist']", :count => 1)
49
49
  end
50
50
  end
51
51
 
52
52
  context "with text" do
53
53
  it "should discard all matches where the given string is not contained" do
54
- @session.should have_xpath("//p//a", :text => "Redirect", :count => 1)
55
- @session.should_not have_xpath("//p", :text => "Doesnotexist")
54
+ expect(@session).to have_xpath("//p//a", :text => "Redirect", :count => 1)
55
+ expect(@session).not_to have_xpath("//p", :text => "Doesnotexist")
56
56
  end
57
57
 
58
58
  it "should discard all matches where the given regexp is not matched" do
59
- @session.should have_xpath("//p//a", :text => /re[dab]i/i, :count => 1)
60
- @session.should_not have_xpath("//p//a", :text => /Red$/)
59
+ expect(@session).to have_xpath("//p//a", :text => /re[dab]i/i, :count => 1)
60
+ expect(@session).not_to have_xpath("//p//a", :text => /Red$/)
61
61
  end
62
62
  end
63
63
  end
@@ -68,60 +68,60 @@ Capybara::SpecHelper.spec '#has_no_xpath?' do
68
68
  end
69
69
 
70
70
  it "should be false if the given selector is on the page" do
71
- @session.should_not have_no_xpath("//p")
72
- @session.should_not have_no_xpath("//p//a[@id='foo']")
73
- @session.should_not have_no_xpath("//p[contains(.,'est')]")
71
+ expect(@session).not_to have_no_xpath("//p")
72
+ expect(@session).not_to have_no_xpath("//p//a[@id='foo']")
73
+ expect(@session).not_to have_no_xpath("//p[contains(.,'est')]")
74
74
  end
75
75
 
76
76
  it "should be true if the given selector is not on the page" do
77
- @session.should have_no_xpath("//abbr")
78
- @session.should have_no_xpath("//p//a[@id='doesnotexist']")
79
- @session.should have_no_xpath("//p[contains(.,'thisstringisnotonpage')]")
77
+ expect(@session).to have_no_xpath("//abbr")
78
+ expect(@session).to have_no_xpath("//p//a[@id='doesnotexist']")
79
+ expect(@session).to have_no_xpath("//p[contains(.,'thisstringisnotonpage')]")
80
80
  end
81
81
 
82
82
  it "should use xpath even if default selector is CSS" do
83
83
  Capybara.default_selector = :css
84
- @session.should have_no_xpath("//p//a[@id='doesnotexist']")
84
+ expect(@session).to have_no_xpath("//p//a[@id='doesnotexist']")
85
85
  end
86
86
 
87
87
  it "should respect scopes" do
88
88
  @session.within "//p[@id='first']" do
89
- @session.should_not have_no_xpath(".//a[@id='foo']")
90
- @session.should have_no_xpath(".//a[@id='red']")
89
+ expect(@session).not_to have_no_xpath(".//a[@id='foo']")
90
+ expect(@session).to have_no_xpath(".//a[@id='red']")
91
91
  end
92
92
  end
93
93
 
94
94
  it "should wait for content to disappear", :requires => [:js] do
95
95
  @session.visit('/with_js')
96
96
  @session.click_link('Click me')
97
- @session.should have_no_xpath("//p[@id='change']")
97
+ expect(@session).to have_no_xpath("//p[@id='change']")
98
98
  end
99
99
 
100
100
  context "with count" do
101
101
  it "should be false if the content occurs the given number of times" do
102
- @session.should_not have_no_xpath("//p", :count => 3)
103
- @session.should_not have_no_xpath("//p//a[@id='foo']", :count => 1)
104
- @session.should_not have_no_xpath("//p[contains(.,'est')]", :count => 1)
105
- @session.should_not have_no_xpath("//p//a[@id='doesnotexist']", :count => 0)
102
+ expect(@session).not_to have_no_xpath("//p", :count => 3)
103
+ expect(@session).not_to have_no_xpath("//p//a[@id='foo']", :count => 1)
104
+ expect(@session).not_to have_no_xpath("//p[contains(.,'est')]", :count => 1)
105
+ expect(@session).not_to have_no_xpath("//p//a[@id='doesnotexist']", :count => 0)
106
106
  end
107
107
 
108
108
  it "should be true if the content occurs a different number of times than the given" do
109
- @session.should have_no_xpath("//p", :count => 6)
110
- @session.should have_no_xpath("//p//a[@id='foo']", :count => 2)
111
- @session.should have_no_xpath("//p[contains(.,'est')]", :count => 5)
112
- @session.should have_no_xpath("//p//a[@id='doesnotexist']", :count => 1)
109
+ expect(@session).to have_no_xpath("//p", :count => 6)
110
+ expect(@session).to have_no_xpath("//p//a[@id='foo']", :count => 2)
111
+ expect(@session).to have_no_xpath("//p[contains(.,'est')]", :count => 5)
112
+ expect(@session).to have_no_xpath("//p//a[@id='doesnotexist']", :count => 1)
113
113
  end
114
114
  end
115
115
 
116
116
  context "with text" do
117
117
  it "should discard all matches where the given string is contained" do
118
- @session.should_not have_no_xpath("//p//a", :text => "Redirect", :count => 1)
119
- @session.should have_no_xpath("//p", :text => "Doesnotexist")
118
+ expect(@session).not_to have_no_xpath("//p//a", :text => "Redirect", :count => 1)
119
+ expect(@session).to have_no_xpath("//p", :text => "Doesnotexist")
120
120
  end
121
121
 
122
122
  it "should discard all matches where the given regexp is matched" do
123
- @session.should_not have_no_xpath("//p//a", :text => /re[dab]i/i, :count => 1)
124
- @session.should have_no_xpath("//p//a", :text => /Red$/)
123
+ expect(@session).not_to have_no_xpath("//p//a", :text => /re[dab]i/i, :count => 1)
124
+ expect(@session).to have_no_xpath("//p//a", :text => /Red$/)
125
125
  end
126
126
  end
127
127
  end
@@ -1,6 +1,6 @@
1
1
  Capybara::SpecHelper.spec '#response_headers' do
2
2
  it "should return response headers", :requires => [:response_headers] do
3
3
  @session.visit('/with_simple_html')
4
- @session.response_headers['Content-Type'].should =~ %r(text/html)
4
+ expect(@session.response_headers['Content-Type']).to match %r(text/html)
5
5
  end
6
6
  end
@@ -1,38 +1,38 @@
1
1
  Capybara::SpecHelper.spec '#html' do
2
2
  it "should return the unmodified page body" do
3
3
  @session.visit('/')
4
- @session.html.should include('Hello world!')
4
+ expect(@session.html).to include('Hello world!')
5
5
  end
6
6
 
7
7
  it "should return the current state of the page", :requires => [:js] do
8
8
  @session.visit('/with_js')
9
- @session.html.should include('I changed it')
10
- @session.html.should_not include('This is text')
9
+ expect(@session.html).to include('I changed it')
10
+ expect(@session.html).not_to include('This is text')
11
11
  end
12
12
  end
13
13
 
14
14
  Capybara::SpecHelper.spec '#source' do
15
15
  it "should return the unmodified page source" do
16
16
  @session.visit('/')
17
- @session.source.should include('Hello world!')
17
+ expect(@session.source).to include('Hello world!')
18
18
  end
19
19
 
20
20
  it "should return the current state of the page", :requires => [:js] do
21
21
  @session.visit('/with_js')
22
- @session.source.should include('I changed it')
23
- @session.source.should_not include('This is text')
22
+ expect(@session.source).to include('I changed it')
23
+ expect(@session.source).not_to include('This is text')
24
24
  end
25
25
  end
26
26
 
27
27
  Capybara::SpecHelper.spec '#body' do
28
28
  it "should return the unmodified page source" do
29
29
  @session.visit('/')
30
- @session.body.should include('Hello world!')
30
+ expect(@session.body).to include('Hello world!')
31
31
  end
32
32
 
33
33
  it "should return the current state of the page", :requires => [:js] do
34
34
  @session.visit('/with_js')
35
- @session.body.should include('I changed it')
36
- @session.body.should_not include('This is text')
35
+ expect(@session.body).to include('I changed it')
36
+ expect(@session.body).not_to include('This is text')
37
37
  end
38
38
  end
@@ -6,191 +6,191 @@ Capybara::SpecHelper.spec "node" do
6
6
  it "should act like a session object" do
7
7
  @session.visit('/form')
8
8
  @form = @session.find(:css, '#get-form')
9
- @form.should have_field('Middle Name')
10
- @form.should have_no_field('Languages')
9
+ expect(@form).to have_field('Middle Name')
10
+ expect(@form).to have_no_field('Languages')
11
11
  @form.fill_in('Middle Name', :with => 'Monkey')
12
12
  @form.click_button('med')
13
- extract_results(@session)['middle_name'].should == 'Monkey'
13
+ expect(extract_results(@session)['middle_name']).to eq('Monkey')
14
14
  end
15
15
 
16
16
  it "should scope CSS selectors" do
17
- @session.find(:css, '#second').should have_no_css('h1')
17
+ expect(@session.find(:css, '#second')).to have_no_css('h1')
18
18
  end
19
19
 
20
20
  describe "#parent" do
21
21
  it "should have a reference to its parent if there is one" do
22
22
  @node = @session.find(:css, '#first')
23
- @node.parent.should == @node.session.document
24
- @node.find(:css, '#foo').parent.should == @node
23
+ expect(@node.parent).to eq(@node.session.document)
24
+ expect(@node.find(:css, '#foo').parent).to eq(@node)
25
25
  end
26
26
  end
27
27
 
28
28
  describe "#text" do
29
29
  it "should extract node texts" do
30
- @session.all('//a')[0].text.should == 'labore'
31
- @session.all('//a')[1].text.should == 'ullamco'
30
+ expect(@session.all('//a')[0].text).to eq('labore')
31
+ expect(@session.all('//a')[1].text).to eq('ullamco')
32
32
  end
33
33
 
34
34
  it "should return document text on /html selector" do
35
35
  @session.visit('/with_simple_html')
36
- @session.all('/html')[0].text.should == 'Bar'
36
+ expect(@session.all('/html')[0].text).to eq('Bar')
37
37
  end
38
38
  end
39
39
 
40
40
  describe "#[]" do
41
41
  it "should extract node attributes" do
42
- @session.all('//a')[0][:class].should == 'simple'
43
- @session.all('//a')[1][:id].should == 'foo'
44
- @session.all('//input')[0][:type].should == 'text'
42
+ expect(@session.all('//a')[0][:class]).to eq('simple')
43
+ expect(@session.all('//a')[1][:id]).to eq('foo')
44
+ expect(@session.all('//input')[0][:type]).to eq('text')
45
45
  end
46
46
 
47
47
  it "should extract boolean node attributes" do
48
- @session.find('//input[@id="checked_field"]')[:checked].should be_true
48
+ expect(@session.find('//input[@id="checked_field"]')[:checked]).to be_truthy
49
49
  end
50
50
  end
51
51
 
52
52
  describe "#value" do
53
53
  it "should allow retrieval of the value" do
54
- @session.find('//textarea[@id="normal"]').value.should == 'banana'
54
+ expect(@session.find('//textarea[@id="normal"]').value).to eq('banana')
55
55
  end
56
56
 
57
57
  it "should not swallow extra newlines in textarea" do
58
- @session.find('//textarea[@id="additional_newline"]').value.should == "\nbanana"
58
+ expect(@session.find('//textarea[@id="additional_newline"]').value).to eq("\nbanana")
59
59
  end
60
60
 
61
61
  it "should not swallow leading newlines for set content in textarea" do
62
62
  @session.find('//textarea[@id="normal"]').set("\nbanana")
63
- @session.find('//textarea[@id="normal"]').value.should == "\nbanana"
63
+ expect(@session.find('//textarea[@id="normal"]').value).to eq("\nbanana")
64
64
  end
65
65
 
66
66
  it "return any HTML content in textarea" do
67
67
  @session.find('//textarea[1]').set("some <em>html</em> here")
68
- @session.find('//textarea[1]').value.should == "some <em>html</em> here"
68
+ expect(@session.find('//textarea[1]').value).to eq("some <em>html</em> here")
69
69
  end
70
70
 
71
71
  it "defaults to 'on' for checkbox" do
72
72
  @session.visit('/form')
73
- @session.find('//input[@id="valueless_checkbox"]').value.should == 'on'
73
+ expect(@session.find('//input[@id="valueless_checkbox"]').value).to eq('on')
74
74
  end
75
75
 
76
76
  it "defaults to 'on' for radio buttons" do
77
77
  @session.visit('/form')
78
- @session.find('//input[@id="valueless_radio"]').value.should == 'on'
78
+ expect(@session.find('//input[@id="valueless_radio"]').value).to eq('on')
79
79
  end
80
80
  end
81
81
 
82
82
  describe "#set" do
83
83
  it "should allow assignment of field value" do
84
- @session.first('//input').value.should == 'monkey'
84
+ expect(@session.first('//input').value).to eq('monkey')
85
85
  @session.first('//input').set('gorilla')
86
- @session.first('//input').value.should == 'gorilla'
86
+ expect(@session.first('//input').value).to eq('gorilla')
87
87
  end
88
88
 
89
89
  it "should fill the field even if the caret was not at the end", :requires => [:js] do
90
90
  @session.execute_script("var el = document.getElementById('test_field'); el.focus(); el.setSelectionRange(0, 0);")
91
91
  @session.first('//input').set('')
92
- @session.first('//input').value.should == ''
92
+ expect(@session.first('//input').value).to eq('')
93
93
  end
94
94
 
95
95
  it "should not set if the text field is readonly" do
96
- @session.first('//input[@readonly]').value.should == 'should not change'
96
+ expect(@session.first('//input[@readonly]').value).to eq('should not change')
97
97
  @session.first('//input[@readonly]').set('changed')
98
- @session.first('//input[@readonly]').value.should == 'should not change'
98
+ expect(@session.first('//input[@readonly]').value).to eq('should not change')
99
99
  end
100
100
 
101
101
  it "should not set if the textarea is readonly" do
102
- @session.first('//textarea[@readonly]').value.should == 'textarea should not change'
102
+ expect(@session.first('//textarea[@readonly]').value).to eq('textarea should not change')
103
103
  @session.first('//textarea[@readonly]').set('changed')
104
- @session.first('//textarea[@readonly]').value.should == 'textarea should not change'
104
+ expect(@session.first('//textarea[@readonly]').value).to eq('textarea should not change')
105
105
  end
106
106
 
107
107
  it 'should allow me to change the contents of a contenteditable element', :requires => [:js] do
108
108
  @session.visit('/with_js')
109
109
  @session.find(:css,'#existing_content_editable').set('WYSIWYG')
110
- @session.find(:css,'#existing_content_editable').text.should == 'WYSIWYG'
110
+ expect(@session.find(:css,'#existing_content_editable').text).to eq('WYSIWYG')
111
111
  end
112
112
 
113
113
  it 'should allow me to set the contents of a contenteditable element', :requires => [:js] do
114
114
  @session.visit('/with_js')
115
115
  @session.find(:css,'#blank_content_editable').set('WYSIWYG')
116
- @session.find(:css,'#blank_content_editable').text.should == 'WYSIWYG'
116
+ expect(@session.find(:css,'#blank_content_editable').text).to eq('WYSIWYG')
117
117
  end
118
118
 
119
119
  it 'should allow me to change the contents of a contenteditable elements child', :requires => [:js] do
120
120
  pending "Selenium doesn't like editing nested contents"
121
121
  @session.visit('/with_js')
122
122
  @session.find(:css,'#existing_content_editable_child').set('WYSIWYG')
123
- @session.find(:css,'#existing_content_editable_child').text.should == 'WYSIWYG'
123
+ expect(@session.find(:css,'#existing_content_editable_child').text).to eq('WYSIWYG')
124
124
  end
125
125
  end
126
126
 
127
127
  describe "#tag_name" do
128
128
  it "should extract node tag name" do
129
- @session.all('//a')[0].tag_name.should == 'a'
130
- @session.all('//a')[1].tag_name.should == 'a'
131
- @session.all('//p')[1].tag_name.should == 'p'
129
+ expect(@session.all('//a')[0].tag_name).to eq('a')
130
+ expect(@session.all('//a')[1].tag_name).to eq('a')
131
+ expect(@session.all('//p')[1].tag_name).to eq('p')
132
132
  end
133
133
  end
134
134
 
135
135
  describe "#disabled?" do
136
136
  it "should extract disabled node" do
137
137
  @session.visit('/form')
138
- @session.find('//input[@id="customer_name"]').should be_disabled
139
- @session.find('//input[@id="customer_email"]').should_not be_disabled
138
+ expect(@session.find('//input[@id="customer_name"]')).to be_disabled
139
+ expect(@session.find('//input[@id="customer_email"]')).not_to be_disabled
140
140
  end
141
141
 
142
142
  it "should see disabled options as disabled" do
143
143
  @session.visit('/form')
144
- @session.find('//select[@id="form_title"]/option[1]').should_not be_disabled
145
- @session.find('//select[@id="form_title"]/option[@disabled]').should be_disabled
144
+ expect(@session.find('//select[@id="form_title"]/option[1]')).not_to be_disabled
145
+ expect(@session.find('//select[@id="form_title"]/option[@disabled]')).to be_disabled
146
146
  end
147
147
 
148
148
  it "should see enabled options in disabled select as disabled" do
149
149
  @session.visit('/form')
150
- @session.find('//select[@id="form_disabled_select"]/option').should be_disabled
151
- @session.find('//select[@id="form_title"]/option[1]').should_not be_disabled
150
+ expect(@session.find('//select[@id="form_disabled_select"]/option')).to be_disabled
151
+ expect(@session.find('//select[@id="form_title"]/option[1]')).not_to be_disabled
152
152
  end
153
153
  end
154
154
 
155
155
  describe "#visible?" do
156
156
  it "should extract node visibility" do
157
157
  Capybara.ignore_hidden_elements = false
158
- @session.first('//a').should be_visible
158
+ expect(@session.first('//a')).to be_visible
159
159
 
160
- @session.find('//div[@id="hidden"]').should_not be_visible
161
- @session.find('//div[@id="hidden_via_ancestor"]').should_not be_visible
162
- @session.find('//div[@id="hidden_attr"]').should_not be_visible
163
- @session.find('//a[@id="hidden_attr_via_ancestor"]').should_not be_visible
160
+ expect(@session.find('//div[@id="hidden"]')).not_to be_visible
161
+ expect(@session.find('//div[@id="hidden_via_ancestor"]')).not_to be_visible
162
+ expect(@session.find('//div[@id="hidden_attr"]')).not_to be_visible
163
+ expect(@session.find('//a[@id="hidden_attr_via_ancestor"]')).not_to be_visible
164
164
  end
165
165
  end
166
166
 
167
167
  describe "#checked?" do
168
168
  it "should extract node checked state" do
169
169
  @session.visit('/form')
170
- @session.find('//input[@id="gender_female"]').should be_checked
171
- @session.find('//input[@id="gender_male"]').should_not be_checked
172
- @session.first('//h1').should_not be_checked
170
+ expect(@session.find('//input[@id="gender_female"]')).to be_checked
171
+ expect(@session.find('//input[@id="gender_male"]')).not_to be_checked
172
+ expect(@session.first('//h1')).not_to be_checked
173
173
  end
174
174
  end
175
175
 
176
176
  describe "#selected?" do
177
177
  it "should extract node selected state" do
178
178
  @session.visit('/form')
179
- @session.find('//option[@value="en"]').should be_selected
180
- @session.find('//option[@value="sv"]').should_not be_selected
181
- @session.first('//h1').should_not be_selected
179
+ expect(@session.find('//option[@value="en"]')).to be_selected
180
+ expect(@session.find('//option[@value="sv"]')).not_to be_selected
181
+ expect(@session.first('//h1')).not_to be_selected
182
182
  end
183
183
  end
184
184
 
185
185
  describe "#==" do
186
186
  it "preserve object identity" do
187
- (@session.find('//h1') == @session.find('//h1')).should be_true
188
- (@session.find('//h1') === @session.find('//h1')).should be_true
189
- (@session.find('//h1').eql? @session.find('//h1')).should be_false
187
+ expect(@session.find('//h1') == @session.find('//h1')).to be true
188
+ expect(@session.find('//h1') === @session.find('//h1')).to be true
189
+ expect(@session.find('//h1').eql? @session.find('//h1')).to be false
190
190
  end
191
191
 
192
192
  it "returns false for unrelated object" do
193
- (@session.find('//h1') == "Not Capybara::Node::Base").should be_false
193
+ expect(@session.find('//h1') == "Not Capybara::Node::Base").to be false
194
194
  end
195
195
  end
196
196
 
@@ -198,7 +198,7 @@ Capybara::SpecHelper.spec "node" do
198
198
  it "should allow triggering of custom JS events" do
199
199
  @session.visit('/with_js')
200
200
  @session.find(:css, '#with_focus_event').trigger(:focus)
201
- @session.should have_css('#focus_event_triggered')
201
+ expect(@session).to have_css('#focus_event_triggered')
202
202
  end
203
203
  end
204
204
 
@@ -208,18 +208,34 @@ Capybara::SpecHelper.spec "node" do
208
208
  element = @session.find('//div[@id="drag"]')
209
209
  target = @session.find('//div[@id="drop"]')
210
210
  element.drag_to(target)
211
- @session.find('//div[contains(., "Dropped!")]').should_not be_nil
211
+ expect(@session.find('//div[contains(., "Dropped!")]')).not_to be_nil
212
212
  end
213
213
  end
214
214
 
215
215
  describe '#hover', :requires => [:hover] do
216
216
  it "should allow hovering on an element" do
217
217
  @session.visit('/with_hover')
218
- @session.find(:css,'.hidden_until_hover', :visible => false).should_not be_visible
218
+ expect(@session.find(:css,'.hidden_until_hover', :visible => false)).not_to be_visible
219
219
  @session.find(:css,'.wrapper').hover
220
- @session.find(:css, '.hidden_until_hover', :visible => false).should be_visible
220
+ expect(@session.find(:css, '.hidden_until_hover', :visible => false)).to be_visible
221
221
  end
222
222
  end
223
+
224
+ describe '#double_click', :requires => [:js] do
225
+ it "should double click an element" do
226
+ @session.visit('/with_js')
227
+ @session.find(:css, '#click-test').double_click
228
+ expect(@session.find(:css, '#has-been-double-clicked')).to be
229
+ end
230
+ end
231
+
232
+ describe '#right_click', :requires => [:js] do
233
+ it "should double click an element" do
234
+ @session.visit('/with_js')
235
+ @session.find(:css, '#click-test').right_click
236
+ expect(@session.find(:css, '#has-been-right-clicked')).to be
237
+ end
238
+ end
223
239
 
224
240
  describe '#reload', :requires => [:js] do
225
241
  context "without automatic reload" do
@@ -229,8 +245,8 @@ Capybara::SpecHelper.spec "node" do
229
245
  node = @session.find(:css, '#reload-me')
230
246
  @session.click_link('Reload!')
231
247
  sleep(0.3)
232
- node.reload.text.should == 'has been reloaded'
233
- node.text.should == 'has been reloaded'
248
+ expect(node.reload.text).to eq('has been reloaded')
249
+ expect(node.text).to eq('has been reloaded')
234
250
  end
235
251
 
236
252
  it "should reload a parent node" do
@@ -238,8 +254,8 @@ Capybara::SpecHelper.spec "node" do
238
254
  node = @session.find(:css, '#reload-me').find(:css, 'em')
239
255
  @session.click_link('Reload!')
240
256
  sleep(0.3)
241
- node.reload.text.should == 'has been reloaded'
242
- node.text.should == 'has been reloaded'
257
+ expect(node.reload.text).to eq('has been reloaded')
258
+ expect(node.text).to eq('has been reloaded')
243
259
  end
244
260
 
245
261
  it "should not automatically reload" do
@@ -258,7 +274,7 @@ Capybara::SpecHelper.spec "node" do
258
274
  node = @session.find(:css, '#reload-me')
259
275
  @session.click_link('Reload!')
260
276
  sleep(0.3)
261
- node.text.should == 'has been reloaded'
277
+ expect(node.text).to eq('has been reloaded')
262
278
  end
263
279
 
264
280
  it "should reload a parent node automatically" do
@@ -266,7 +282,7 @@ Capybara::SpecHelper.spec "node" do
266
282
  node = @session.find(:css, '#reload-me').find(:css, 'em')
267
283
  @session.click_link('Reload!')
268
284
  sleep(0.3)
269
- node.text.should == 'has been reloaded'
285
+ expect(node.text).to eq('has been reloaded')
270
286
  end
271
287
 
272
288
  it "should reload a node automatically when using find" do
@@ -274,7 +290,7 @@ Capybara::SpecHelper.spec "node" do
274
290
  node = @session.find(:css, '#reload-me')
275
291
  @session.click_link('Reload!')
276
292
  sleep(0.3)
277
- node.find(:css, 'a').text.should == 'has been reloaded'
293
+ expect(node.find(:css, 'a').text).to eq('has been reloaded')
278
294
  end
279
295
 
280
296
  it "should not reload nodes which haven't been found" do
@@ -291,7 +307,7 @@ Capybara::SpecHelper.spec "node" do
291
307
  node = @session.find(:css, 'em', :text => "reloaded")
292
308
  @session.click_link('Reload!')
293
309
  sleep(1)
294
- node.text.should == 'has been reloaded'
310
+ expect(node.text).to eq('has been reloaded')
295
311
  end
296
312
  end
297
313
  end