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
@@ -2,39 +2,39 @@ Capybara::SpecHelper.spec '#reset_session!' do
2
2
  it "removes cookies" do
3
3
  @session.visit('/set_cookie')
4
4
  @session.visit('/get_cookie')
5
- @session.should have_content('test_cookie')
5
+ expect(@session).to have_content('test_cookie')
6
6
 
7
7
  @session.reset_session!
8
8
  @session.visit('/get_cookie')
9
- @session.body.should_not include('test_cookie')
9
+ expect(@session.body).not_to include('test_cookie')
10
10
  end
11
11
 
12
12
  it "resets current url, host, path" do
13
13
  @session.visit '/foo'
14
- @session.current_url.should_not be_empty
15
- @session.current_host.should_not be_empty
16
- @session.current_path.should == '/foo'
14
+ expect(@session.current_url).not_to be_empty
15
+ expect(@session.current_host).not_to be_empty
16
+ expect(@session.current_path).to eq('/foo')
17
17
 
18
18
  @session.reset_session!
19
- [nil, '', 'about:blank'].should include(@session.current_url)
20
- ['', nil].should include(@session.current_path)
21
- @session.current_host.should be_nil
19
+ expect([nil, '', 'about:blank']).to include(@session.current_url)
20
+ expect(['', nil]).to include(@session.current_path)
21
+ expect(@session.current_host).to be_nil
22
22
  end
23
23
 
24
24
  it "resets page body" do
25
25
  @session.visit('/with_html')
26
- @session.should have_content('This is a test')
27
- @session.find('.//h1').text.should include('This is a test')
26
+ expect(@session).to have_content('This is a test')
27
+ expect(@session.find('.//h1').text).to include('This is a test')
28
28
 
29
29
  @session.reset_session!
30
- @session.body.should_not include('This is a test')
31
- @session.should have_no_selector('.//h1')
30
+ expect(@session.body).not_to include('This is a test')
31
+ expect(@session).to have_no_selector('.//h1')
32
32
  end
33
33
 
34
34
  it "is synchronous" do
35
35
  @session.visit("/with_html")
36
36
  @session.reset_session!
37
- @session.should have_no_selector :xpath, "/html/body/*", wait: false
37
+ expect(@session).to have_no_selector :xpath, "/html/body/*", wait: false
38
38
  end
39
39
 
40
40
  it "raises any errors caught inside the server", :requires => [:server] do
@@ -43,7 +43,7 @@ Capybara::SpecHelper.spec '#reset_session!' do
43
43
  @session.reset_session!
44
44
  end.to raise_error(TestApp::TestAppError)
45
45
  @session.visit("/")
46
- @session.current_path.should == "/"
46
+ expect(@session.current_path).to eq("/")
47
47
  end
48
48
 
49
49
  it "ignores server errors when `Capybara.raise_server_errors = false`", :requires => [:server] do
@@ -51,6 +51,6 @@ Capybara::SpecHelper.spec '#reset_session!' do
51
51
  quietly { @session.visit("/error") }
52
52
  @session.reset_session!
53
53
  @session.visit("/")
54
- @session.current_path.should == "/"
54
+ expect(@session.current_path).to eq("/")
55
55
  end
56
56
  end
@@ -1,6 +1,6 @@
1
1
  Capybara::SpecHelper.spec '#status_code' do
2
2
  it "should return response codes", :requires => [:status_code] do
3
3
  @session.visit('/with_simple_html')
4
- @session.status_code.should == 200
4
+ expect(@session.status_code).to eq(200)
5
5
  end
6
6
  end
@@ -0,0 +1,46 @@
1
+ require 'launchy'
2
+
3
+ Capybara::SpecHelper.spec '#save_and_open_screenshot' do
4
+ before do
5
+ @session.visit '/'
6
+ end
7
+
8
+ it 'opens file from the default directory', :requires => [:screenshot] do
9
+ expected_file_regex = %r{capybara/capybara-\d+\.png}
10
+ allow(@session.driver).to receive(:save_screenshot)
11
+ allow(Launchy).to receive(:open)
12
+
13
+ @session.save_and_open_screenshot
14
+
15
+ expect(@session.driver).to have_received(:save_screenshot).
16
+ with(expected_file_regex, {})
17
+ expect(Launchy).to have_received(:open).with(expected_file_regex)
18
+ end
19
+
20
+ it 'opens file from the provided directory', :requires => [:screenshot] do
21
+ custom_path = 'screenshots/1.png'
22
+ allow(@session.driver).to receive(:save_screenshot)
23
+ allow(Launchy).to receive(:open)
24
+
25
+ @session.save_and_open_screenshot(custom_path)
26
+
27
+ expect(@session.driver).to have_received(:save_screenshot).
28
+ with(custom_path, {})
29
+ expect(Launchy).to have_received(:open).with(custom_path)
30
+ end
31
+
32
+ context 'when launchy cannot be required' do
33
+ it 'prints out a correct warning message', :requires => [:screenshot] do
34
+ file_path = File.join(Dir.tmpdir, 'test.png')
35
+ allow(@session).to receive(:require).with('launchy').and_raise(LoadError)
36
+ allow(@session).to receive(:warn)
37
+
38
+ @session.save_and_open_screenshot(file_path)
39
+
40
+ expect(@session).to have_received(:warn).
41
+ with("File saved to #{file_path}.")
42
+ expect(@session).to have_received(:warn).
43
+ with('Please install the launchy gem to open the file automatically.')
44
+ end
45
+ end
46
+ end
@@ -15,39 +15,39 @@ Capybara::SpecHelper.spec '#save_page' do
15
15
  it "saves the page in the root directory" do
16
16
  @session.save_page
17
17
  path = Dir.glob("capybara-*.html").first
18
- File.read(path).should include("Another World")
18
+ expect(File.read(path)).to include("Another World")
19
19
  end
20
20
 
21
21
  it "generates a sensible filename" do
22
22
  @session.save_page
23
23
  path = Dir.glob("capybara-*.html").first
24
24
  filename = path.split("/").last
25
- filename.should =~ /^capybara-\d+\.html$/
25
+ expect(filename).to match /^capybara-\d+\.html$/
26
26
  end
27
27
 
28
28
  it "can store files in a specified directory" do
29
29
  Capybara.save_and_open_page_path = alternative_path
30
30
  @session.save_page
31
31
  path = Dir.glob(alternative_path + "/capybara-*.html").first
32
- File.read(path).should include("Another World")
32
+ expect(File.read(path)).to include("Another World")
33
33
  end
34
34
 
35
35
  it "uses the given filename" do
36
36
  @session.save_page("capybara-001122.html")
37
- File.read("capybara-001122.html").should include("Another World")
37
+ expect(File.read("capybara-001122.html")).to include("Another World")
38
38
  end
39
39
 
40
40
  it "returns an absolute path in pwd" do
41
41
  result = @session.save_page
42
42
  path = File.expand_path(Dir.glob("capybara-*.html").first, Dir.pwd)
43
- result.should == path
43
+ expect(result).to eq(path)
44
44
  end
45
45
 
46
46
  it "returns an absolute path in given directory" do
47
47
  Capybara.save_and_open_page_path = alternative_path
48
48
  result = @session.save_page
49
49
  path = File.expand_path(Dir.glob(alternative_path + "/capybara-*.html").first, alternative_path)
50
- result.should == path
50
+ expect(result).to eq(path)
51
51
  end
52
52
 
53
53
  context "asset_host contains a string" do
@@ -59,7 +59,7 @@ Capybara::SpecHelper.spec '#save_page' do
59
59
  path = @session.save_page
60
60
 
61
61
  result = File.read(path)
62
- result.should include("<head><base href='http://example.com' />")
62
+ expect(result).to include("<head><base href='http://example.com' />")
63
63
  end
64
64
 
65
65
  it "doesn't prepend base tag to pages when asset_host is nil" do
@@ -68,7 +68,7 @@ Capybara::SpecHelper.spec '#save_page' do
68
68
  path = @session.save_page
69
69
 
70
70
  result = File.read(path)
71
- result.should_not include("http://example.com")
71
+ expect(result).not_to include("http://example.com")
72
72
  end
73
73
 
74
74
  it "doesn't prepend base tag to pages which already have it" do
@@ -76,7 +76,7 @@ Capybara::SpecHelper.spec '#save_page' do
76
76
  path = @session.save_page
77
77
 
78
78
  result = File.read(path)
79
- result.should_not include("http://example.com")
79
+ expect(result).not_to include("http://example.com")
80
80
  end
81
81
  end
82
82
  end
@@ -4,11 +4,13 @@ Capybara::SpecHelper.spec "#save_screenshot" do
4
4
 
5
5
  before do
6
6
  @session.visit '/'
7
- @session.save_screenshot image_path
8
7
  end
9
8
 
10
9
  it "should generate PNG file", :requires => [:screenshot] do
10
+ path = @session.save_screenshot image_path
11
+
11
12
  magic = File.read(image_path, 4)
12
- magic.should eq "\x89PNG"
13
+ expect(magic).to eq "\x89PNG"
14
+ expect(path).to eq image_path
13
15
  end
14
16
  end
@@ -4,22 +4,22 @@ Capybara::SpecHelper.spec "#select" do
4
4
  end
5
5
 
6
6
  it "should return value of the first option" do
7
- @session.find_field('Title').value.should == 'Mrs'
7
+ expect(@session.find_field('Title').value).to eq('Mrs')
8
8
  end
9
9
 
10
10
  it "should return value of the selected option" do
11
11
  @session.select("Miss", :from => 'Title')
12
- @session.find_field('Title').value.should == 'Miss'
12
+ expect(@session.find_field('Title').value).to eq('Miss')
13
13
  end
14
14
 
15
15
  it "should allow selecting options where there are inexact matches" do
16
16
  @session.select("Mr", :from => 'Title')
17
- @session.find_field('Title').value.should == 'Mr'
17
+ expect(@session.find_field('Title').value).to eq('Mr')
18
18
  end
19
19
 
20
20
  it "should allow selecting options where they are the only inexact match" do
21
21
  @session.select("Mis", :from => 'Title')
22
- @session.find_field('Title').value.should == 'Miss'
22
+ expect(@session.find_field('Title').value).to eq('Miss')
23
23
  end
24
24
 
25
25
  it "should not allow selecting options where they are the only inexact match if `Capybara.exact_options = true`" do
@@ -36,50 +36,50 @@ Capybara::SpecHelper.spec "#select" do
36
36
  end
37
37
 
38
38
  it "should return the value attribute rather than content if present" do
39
- @session.find_field('Locale').value.should == 'en'
39
+ expect(@session.find_field('Locale').value).to eq('en')
40
40
  end
41
41
 
42
42
  it "should select an option from a select box by id" do
43
43
  @session.select("Finish", :from => 'form_locale')
44
44
  @session.click_button('awesome')
45
- extract_results(@session)['locale'].should == 'fi'
45
+ expect(extract_results(@session)['locale']).to eq('fi')
46
46
  end
47
47
 
48
48
  it "should select an option from a select box by label" do
49
49
  @session.select("Finish", :from => 'Locale')
50
50
  @session.click_button('awesome')
51
- extract_results(@session)['locale'].should == 'fi'
51
+ expect(extract_results(@session)['locale']).to eq('fi')
52
52
  end
53
53
 
54
54
  it "should select an option without giving a select box" do
55
55
  @session.select("Swedish")
56
56
  @session.click_button('awesome')
57
- extract_results(@session)['locale'].should == 'sv'
57
+ expect(extract_results(@session)['locale']).to eq('sv')
58
58
  end
59
59
 
60
60
  it "should escape quotes" do
61
61
  @session.select("John's made-up language", :from => 'Locale')
62
62
  @session.click_button('awesome')
63
- extract_results(@session)['locale'].should == 'jo'
63
+ expect(extract_results(@session)['locale']).to eq('jo')
64
64
  end
65
65
 
66
66
  it "should obey from" do
67
67
  @session.select("Miss", :from => "Other title")
68
68
  @session.click_button('awesome')
69
69
  results = extract_results(@session)
70
- results['other_title'].should == "Miss"
71
- results['title'].should_not == "Miss"
70
+ expect(results['other_title']).to eq("Miss")
71
+ expect(results['title']).not_to eq("Miss")
72
72
  end
73
73
 
74
74
  it "show match labels with preceding or trailing whitespace" do
75
75
  @session.select("Lojban", :from => 'Locale')
76
76
  @session.click_button('awesome')
77
- extract_results(@session)['locale'].should == 'jbo'
77
+ expect(extract_results(@session)['locale']).to eq('jbo')
78
78
  end
79
79
 
80
80
  it "casts to string" do
81
81
  @session.select(:"Miss", :from => :'Title')
82
- @session.find_field('Title').value.should == 'Miss'
82
+ expect(@session.find_field('Title').value).to eq('Miss')
83
83
  end
84
84
 
85
85
  context "with a locator that doesn't exist" do
@@ -110,26 +110,26 @@ Capybara::SpecHelper.spec "#select" do
110
110
 
111
111
  context "with multiple select" do
112
112
  it "should return an empty value" do
113
- @session.find_field('Language').value.should == []
113
+ expect(@session.find_field('Language').value).to eq([])
114
114
  end
115
115
 
116
116
  it "should return value of the selected options" do
117
117
  @session.select("Ruby", :from => 'Language')
118
118
  @session.select("Javascript", :from => 'Language')
119
- @session.find_field('Language').value.should include('Ruby', 'Javascript')
119
+ expect(@session.find_field('Language').value).to include('Ruby', 'Javascript')
120
120
  end
121
121
 
122
122
  it "should select one option" do
123
123
  @session.select("Ruby", :from => 'Language')
124
124
  @session.click_button('awesome')
125
- extract_results(@session)['languages'].should == ['Ruby']
125
+ expect(extract_results(@session)['languages']).to eq(['Ruby'])
126
126
  end
127
127
 
128
128
  it "should select multiple options" do
129
129
  @session.select("Ruby", :from => 'Language')
130
130
  @session.select("Javascript", :from => 'Language')
131
131
  @session.click_button('awesome')
132
- extract_results(@session)['languages'].should include('Ruby', 'Javascript')
132
+ expect(extract_results(@session)['languages']).to include('Ruby', 'Javascript')
133
133
  end
134
134
 
135
135
  it "should remain selected if already selected" do
@@ -137,11 +137,11 @@ Capybara::SpecHelper.spec "#select" do
137
137
  @session.select("Javascript", :from => 'Language')
138
138
  @session.select("Ruby", :from => 'Language')
139
139
  @session.click_button('awesome')
140
- extract_results(@session)['languages'].should include('Ruby', 'Javascript')
140
+ expect(extract_results(@session)['languages']).to include('Ruby', 'Javascript')
141
141
  end
142
142
 
143
143
  it "should return value attribute rather than content if present" do
144
- @session.find_field('Underwear').value.should include('thermal')
144
+ expect(@session.find_field('Underwear').value).to include('thermal')
145
145
  end
146
146
  end
147
147
 
@@ -150,19 +150,19 @@ Capybara::SpecHelper.spec "#select" do
150
150
  it "can match select box approximately" do
151
151
  @session.select("Finish", :from => "Loc", :exact => false)
152
152
  @session.click_button("awesome")
153
- extract_results(@session)["locale"].should == "fi"
153
+ expect(extract_results(@session)["locale"]).to eq("fi")
154
154
  end
155
155
 
156
156
  it "can match option approximately" do
157
157
  @session.select("Fin", :from => "Locale", :exact => false)
158
158
  @session.click_button("awesome")
159
- extract_results(@session)["locale"].should == "fi"
159
+ expect(extract_results(@session)["locale"]).to eq("fi")
160
160
  end
161
161
 
162
162
  it "can match option approximately when :from not given" do
163
163
  @session.select("made-up language", :exact => false)
164
164
  @session.click_button("awesome")
165
- extract_results(@session)["locale"].should == "jo"
165
+ expect(extract_results(@session)["locale"]).to eq("jo")
166
166
  end
167
167
  end
168
168
 
@@ -1,45 +1,50 @@
1
1
  Capybara::SpecHelper.spec '#text' do
2
2
  it "should print the text of the page" do
3
3
  @session.visit('/with_simple_html')
4
- @session.text.should == 'Bar'
4
+ expect(@session.text).to eq('Bar')
5
5
  end
6
6
 
7
7
  it "ignores invisible text by default" do
8
8
  @session.visit('/with_html')
9
- @session.find(:id, "hidden-text").text.should == 'Some of this text is'
9
+ expect(@session.find(:id, "hidden-text").text).to eq('Some of this text is')
10
10
  end
11
11
 
12
12
  it "shows invisible text if `:all` given" do
13
13
  @session.visit('/with_html')
14
- @session.find(:id, "hidden-text").text(:all).should == 'Some of this text is hidden!'
14
+ expect(@session.find(:id, "hidden-text").text(:all)).to eq('Some of this text is hidden!')
15
15
  end
16
16
 
17
17
  it "ignores invisible text if `:visible` given" do
18
18
  Capybara.ignore_hidden_elements = false
19
19
  @session.visit('/with_html')
20
- @session.find(:id, "hidden-text").text(:visible).should == 'Some of this text is'
20
+ expect(@session.find(:id, "hidden-text").text(:visible)).to eq('Some of this text is')
21
21
  end
22
22
 
23
23
  it "ignores invisible text if `Capybara.ignore_hidden_elements = true`" do
24
24
  @session.visit('/with_html')
25
- @session.find(:id, "hidden-text").text.should == 'Some of this text is'
25
+ expect(@session.find(:id, "hidden-text").text).to eq('Some of this text is')
26
26
  Capybara.ignore_hidden_elements = false
27
- @session.find(:id, "hidden-text").text.should == 'Some of this text is hidden!'
27
+ expect(@session.find(:id, "hidden-text").text).to eq('Some of this text is hidden!')
28
28
  end
29
29
 
30
30
  it "ignores invisible text if `Capybara.visible_text_only = true`" do
31
31
  @session.visit('/with_html')
32
32
  Capybara.visible_text_only = true
33
- @session.find(:id, "hidden-text").text.should == 'Some of this text is'
33
+ expect(@session.find(:id, "hidden-text").text).to eq('Some of this text is')
34
34
  Capybara.ignore_hidden_elements = false
35
- @session.find(:id, "hidden-text").text.should == 'Some of this text is'
35
+ expect(@session.find(:id, "hidden-text").text).to eq('Some of this text is')
36
+ end
37
+
38
+ it "ignores invisible text if ancestor is invisible" do
39
+ @session.visit('/with_html')
40
+ expect(@session.find(:id, "hidden_via_ancestor", visible: false).text).to eq('')
36
41
  end
37
42
 
38
43
  context "with css as default selector" do
39
44
  before { Capybara.default_selector = :css }
40
45
  it "should print the text of the page" do
41
46
  @session.visit('/with_simple_html')
42
- @session.text.should == 'Bar'
47
+ expect(@session.text).to eq('Bar')
43
48
  end
44
49
  after { Capybara.default_selector = :xpath }
45
50
  end
@@ -47,7 +52,7 @@ Capybara::SpecHelper.spec '#text' do
47
52
  it "should strip whitespace" do
48
53
  @session.visit('/with_html')
49
54
  n = @session.find(:css, '#second')
50
- @session.find(:css, '#second').text.should =~ \
55
+ expect(@session.find(:css, '#second').text).to match \
51
56
  /\ADuis aute .* text with whitespace .* est laborum\.\z/
52
57
  end
53
58
  end
@@ -2,14 +2,14 @@ Capybara::SpecHelper.spec '#title' do
2
2
 
3
3
  it "should print the title of the page" do
4
4
  @session.visit('/with_title')
5
- @session.title.should == 'Test Title'
5
+ expect(@session.title).to eq('Test Title')
6
6
  end
7
7
 
8
8
  context "with css as default selector" do
9
9
  before { Capybara.default_selector = :css }
10
10
  it "should print the title of the page" do
11
11
  @session.visit('/with_title')
12
- @session.title.should == 'Test Title'
12
+ expect(@session.title).to eq('Test Title')
13
13
  end
14
14
  after { Capybara.default_selector = :xpath }
15
15
  end