capybara 2.13.0 → 2.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +82 -17
- data/README.md +29 -0
- data/lib/capybara.rb +81 -116
- data/lib/capybara/config.rb +121 -0
- data/lib/capybara/cucumber.rb +1 -0
- data/lib/capybara/driver/base.rb +6 -0
- data/lib/capybara/dsl.rb +1 -3
- data/lib/capybara/helpers.rb +3 -3
- data/lib/capybara/node/actions.rb +2 -2
- data/lib/capybara/node/base.rb +7 -2
- data/lib/capybara/node/element.rb +7 -1
- data/lib/capybara/node/finders.rb +13 -3
- data/lib/capybara/node/matchers.rb +15 -4
- data/lib/capybara/node/simple.rb +5 -0
- data/lib/capybara/queries/base_query.rb +8 -3
- data/lib/capybara/queries/selector_query.rb +11 -9
- data/lib/capybara/queries/text_query.rb +9 -4
- data/lib/capybara/rack_test/browser.rb +8 -5
- data/lib/capybara/rspec.rb +3 -1
- data/lib/capybara/rspec/matcher_proxies.rb +41 -0
- data/lib/capybara/rspec/matchers.rb +19 -5
- data/lib/capybara/selector.rb +13 -4
- data/lib/capybara/selector/selector.rb +3 -3
- data/lib/capybara/selenium/driver.rb +20 -6
- data/lib/capybara/selenium/node.rb +6 -2
- data/lib/capybara/server.rb +6 -5
- data/lib/capybara/session.rb +71 -14
- data/lib/capybara/session/config.rb +100 -0
- data/lib/capybara/spec/public/test.js +1 -1
- data/lib/capybara/spec/session/all_spec.rb +11 -0
- data/lib/capybara/spec/session/assert_all_of_selectors_spec.rb +24 -8
- data/lib/capybara/spec/session/fill_in_spec.rb +6 -0
- data/lib/capybara/spec/session/find_field_spec.rb +1 -0
- data/lib/capybara/spec/session/find_spec.rb +4 -3
- data/lib/capybara/spec/session/has_selector_spec.rb +1 -3
- data/lib/capybara/spec/session/node_spec.rb +23 -17
- data/lib/capybara/spec/session/reset_session_spec.rb +1 -1
- data/lib/capybara/spec/session/window/become_closed_spec.rb +4 -4
- data/lib/capybara/spec/spec_helper.rb +22 -0
- data/lib/capybara/spec/views/form.erb +6 -1
- data/lib/capybara/spec/views/with_html.erb +1 -0
- data/lib/capybara/version.rb +1 -1
- data/lib/capybara/window.rb +1 -1
- data/spec/capybara_spec.rb +14 -2
- data/spec/dsl_spec.rb +1 -0
- data/spec/per_session_config_spec.rb +67 -0
- data/spec/rspec/shared_spec_matchers.rb +2 -2
- data/spec/rspec/views_spec.rb +4 -0
- data/spec/rspec_spec.rb +77 -0
- data/spec/session_spec.rb +44 -0
- data/spec/shared_selenium_session.rb +9 -0
- data/spec/spec_helper.rb +4 -0
- metadata +7 -3
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'capybara/dsl'
|
4
|
+
|
5
|
+
RSpec.describe Capybara::SessionConfig do
|
6
|
+
describe "threadsafe" do
|
7
|
+
it "defaults to global session options" do
|
8
|
+
Capybara.threadsafe = true
|
9
|
+
session = Capybara::Session.new(:rack_test, TestApp)
|
10
|
+
[:default_host, :app_host, :save_and_open_page_path,
|
11
|
+
:always_include_port, :run_server, :default_selector, :default_max_wait_time, :ignore_hidden_elements,
|
12
|
+
:automatic_reload, :match, :exact, :raise_server_errors, :visible_text_only, :wait_on_first_by_default,
|
13
|
+
:automatic_label_click, :enable_aria_label,
|
14
|
+
:save_path, :exact_options, :asset_host].each do |m|
|
15
|
+
expect(session.config.public_send(m)).to eq Capybara.public_send(m)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "doesn't change global session when changed" do
|
20
|
+
Capybara.threadsafe = true
|
21
|
+
host = "http://my.example.com"
|
22
|
+
session = Capybara::Session.new(:rack_test, TestApp) do |config|
|
23
|
+
config.default_host = host
|
24
|
+
config.automatic_label_click = !config.automatic_label_click
|
25
|
+
config.server_errors << ArgumentError
|
26
|
+
end
|
27
|
+
expect(Capybara.default_host).not_to eq host
|
28
|
+
expect(session.config.default_host).to eq host
|
29
|
+
expect(Capybara.automatic_label_click).not_to eq session.config.automatic_label_click
|
30
|
+
expect(Capybara.server_errors).not_to eq session.config.server_errors
|
31
|
+
end
|
32
|
+
|
33
|
+
it "doesn't allow session configuration block when false" do
|
34
|
+
Capybara.threadsafe = false
|
35
|
+
expect do
|
36
|
+
Capybara::Session.new(:rack_test, TestApp) { |config| }
|
37
|
+
end.to raise_error "A configuration block is only accepted when Capybara.threadsafe == true"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "doesn't allow session config when false" do
|
41
|
+
Capybara.threadsafe = false
|
42
|
+
session = Capybara::Session.new(:rack_test, TestApp)
|
43
|
+
expect { session.config.default_selector = :title }.to raise_error /Per session settings are only supported when Capybara.threadsafe == true/
|
44
|
+
expect do
|
45
|
+
session.configure do |config|
|
46
|
+
config.exact = true
|
47
|
+
end
|
48
|
+
end.to raise_error /Session configuration is only supported when Capybara.threadsafe == true/
|
49
|
+
end
|
50
|
+
|
51
|
+
it "uses the config from the session" do
|
52
|
+
Capybara.threadsafe = true
|
53
|
+
session = Capybara::Session.new(:rack_test, TestApp) do |config|
|
54
|
+
config.default_selector = :link
|
55
|
+
end
|
56
|
+
session.visit('/with_html')
|
57
|
+
expect(session.find('foo').tag_name).to eq 'a'
|
58
|
+
end
|
59
|
+
|
60
|
+
it "won't change threadsafe once a session is created" do
|
61
|
+
Capybara.threadsafe = true
|
62
|
+
Capybara.threadsafe = false
|
63
|
+
session = Capybara::Session.new(:rack_test, TestApp)
|
64
|
+
expect { Capybara.threadsafe = true }.to raise_error /Threadsafe setting cannot be changed once a session is created/
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -555,8 +555,8 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, mode|
|
|
555
555
|
|
556
556
|
it "doesn't wait if wait time is less than timeout" do
|
557
557
|
@session.click_link("Change title")
|
558
|
-
using_wait_time
|
559
|
-
expect(@session).not_to have_title('changed title')
|
558
|
+
using_wait_time 3 do
|
559
|
+
expect(@session).not_to have_title('changed title', wait: 0)
|
560
560
|
end
|
561
561
|
end
|
562
562
|
end
|
data/spec/rspec/views_spec.rb
CHANGED
@@ -5,4 +5,8 @@ RSpec.describe "capybara/rspec", type: :view do
|
|
5
5
|
it "allows matchers to be used on strings" do
|
6
6
|
expect(%{<h1>Test header</h1>}).to have_css("h1", text: "Test header")
|
7
7
|
end
|
8
|
+
|
9
|
+
it "doesn't include RSpecMatcherProxies" do
|
10
|
+
expect(self.class.ancestors).not_to include(Capybara::RSpecMatcherProxies)
|
11
|
+
end
|
8
12
|
end
|
data/spec/rspec_spec.rb
CHANGED
@@ -7,6 +7,10 @@ RSpec.describe 'capybara/rspec', :type => :feature do
|
|
7
7
|
expect(page.body).to include('Another World')
|
8
8
|
end
|
9
9
|
|
10
|
+
it "should include RSpec matcher proxies" do
|
11
|
+
expect(self.class.ancestors).to include Capybara::RSpecMatcherProxies
|
12
|
+
end
|
13
|
+
|
10
14
|
context "resetting session" do
|
11
15
|
it "sets a cookie in one example..." do
|
12
16
|
visit('/set_cookie')
|
@@ -36,6 +40,79 @@ RSpec.describe 'capybara/rspec', :type => :feature do
|
|
36
40
|
it "switches to the given driver when giving it as metadata", :driver => :culerity do
|
37
41
|
expect(Capybara.current_driver).to eq(:culerity)
|
38
42
|
end
|
43
|
+
|
44
|
+
context "#all" do
|
45
|
+
it "allows access to the Capybara finder" do
|
46
|
+
visit('/with_html')
|
47
|
+
expect(all(:css, 'h2.head').size).to eq(5)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "allows access to the RSpec matcher" do
|
51
|
+
skip "RSpec < 3 doesn't have an `all` matcher" if rspec2?
|
52
|
+
|
53
|
+
visit('/with_html')
|
54
|
+
expect(["test1", "test2"]).to all(be_a(String))
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "#within" do
|
59
|
+
it "allows access to the Capybara scoper" do
|
60
|
+
visit('/with_html')
|
61
|
+
expect do
|
62
|
+
within(:css, "#does_not_exist") { click_link "Go to simple" }
|
63
|
+
end.to raise_error(Capybara::ElementNotFound)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "allows access to the RSpec matcher" do
|
67
|
+
skip "RSpec version doesn't have a 'within' matcher" unless ::RSpec::Matchers.instance_methods.include?(:within)
|
68
|
+
visit('/with_html')
|
69
|
+
# This reads terribly, but must call #within
|
70
|
+
expect(find(:css, 'span.number').text.to_i).to within(1).of(41)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
RSpec.describe 'capybara/rspec', :type => :other do
|
76
|
+
context "when RSpec::Matchers is included after Capybara::DSL" do
|
77
|
+
before do
|
78
|
+
class DSL_MatchersTest
|
79
|
+
include Capybara::DSL
|
80
|
+
include RSpec::Matchers
|
81
|
+
end
|
82
|
+
|
83
|
+
@test_class_instance = DSL_MatchersTest.new
|
84
|
+
end
|
85
|
+
|
86
|
+
context "#all" do
|
87
|
+
it "allows access to the Capybara finder" do
|
88
|
+
@test_class_instance.visit('/with_html')
|
89
|
+
expect(@test_class_instance.all(:css, 'h2.head').size).to eq(5)
|
90
|
+
end
|
91
|
+
|
92
|
+
it "allows access to the RSpec matcher" do
|
93
|
+
skip "RSpec < 3 doesn't have an `all` matcher" if rspec2?
|
94
|
+
|
95
|
+
@test_class_instance.visit('/with_html')
|
96
|
+
expect(["test1", "test2"]).to @test_class_instance.all(be_a(String))
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "#within" do
|
101
|
+
it "allows access to the Capybara scoper" do
|
102
|
+
@test_class_instance.visit('/with_html')
|
103
|
+
expect do
|
104
|
+
@test_class_instance.within(:css, "#does_not_exist") { @test_class_instance.click_link "Go to simple" }
|
105
|
+
end.to raise_error(Capybara::ElementNotFound)
|
106
|
+
end
|
107
|
+
|
108
|
+
it "allows access to the RSpec matcher" do
|
109
|
+
skip "RSpec version doesn't have a 'within' matcher" unless ::RSpec::Matchers.instance_methods.include?(:within)
|
110
|
+
@test_class_instance.visit('/with_html')
|
111
|
+
# This reads terribly, but must call #within
|
112
|
+
expect(@test_class_instance.find(:css, 'span.number').text.to_i).to @test_class_instance.within(1).of(41)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
39
116
|
end
|
40
117
|
|
41
118
|
RSpec.describe 'capybara/rspec', :type => :other do
|
data/spec/session_spec.rb
CHANGED
@@ -7,4 +7,48 @@ RSpec.describe Capybara::Session do
|
|
7
7
|
Capybara::Session.new(:unknown, { random: "hash"})
|
8
8
|
end.to raise_error TypeError, "The second parameter to Session::new should be a rack app if passed."
|
9
9
|
end
|
10
|
+
|
11
|
+
context "current_driver" do
|
12
|
+
it "is global when threadsafe false" do
|
13
|
+
Capybara.threadsafe = false
|
14
|
+
Capybara.current_driver = :selenium
|
15
|
+
thread = Thread.new do
|
16
|
+
Capybara.current_driver = :random
|
17
|
+
end
|
18
|
+
thread.join
|
19
|
+
expect(Capybara.current_driver).to eq :random
|
20
|
+
end
|
21
|
+
|
22
|
+
it "is thread specific threadsafe true" do
|
23
|
+
Capybara.threadsafe = true
|
24
|
+
Capybara.current_driver = :selenium
|
25
|
+
thread = Thread.new do
|
26
|
+
Capybara.current_driver = :random
|
27
|
+
end
|
28
|
+
thread.join
|
29
|
+
expect(Capybara.current_driver).to eq :selenium
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "session_name" do
|
34
|
+
it "is global when threadsafe false" do
|
35
|
+
Capybara.threadsafe = false
|
36
|
+
Capybara.session_name = "sess1"
|
37
|
+
thread = Thread.new do
|
38
|
+
Capybara.session_name = "sess2"
|
39
|
+
end
|
40
|
+
thread.join
|
41
|
+
expect(Capybara.session_name).to eq "sess2"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "is thread specific when threadsafe true" do
|
45
|
+
Capybara.threadsafe = true
|
46
|
+
Capybara.session_name = "sess1"
|
47
|
+
thread = Thread.new do
|
48
|
+
Capybara.session_name = "sess2"
|
49
|
+
end
|
50
|
+
thread.join
|
51
|
+
expect(Capybara.session_name).to eq "sess1"
|
52
|
+
end
|
53
|
+
end
|
10
54
|
end
|
@@ -147,5 +147,14 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
|
|
147
147
|
})
|
148
148
|
end
|
149
149
|
end
|
150
|
+
|
151
|
+
describe "Element#inspect" do
|
152
|
+
it "outputs obsolete elements" do
|
153
|
+
@session.visit('/form')
|
154
|
+
el = @session.find(:button, 'Click me!').click
|
155
|
+
sleep 2
|
156
|
+
expect(el.inspect).to eq "Obsolete #<Capybara::Node::Element>"
|
157
|
+
end
|
158
|
+
end
|
150
159
|
end
|
151
160
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -8,3 +8,7 @@ RSpec.configure do |config|
|
|
8
8
|
config.filter_run_including focus_: true unless ENV['TRAVIS']
|
9
9
|
config.run_all_when_everything_filtered = true
|
10
10
|
end
|
11
|
+
|
12
|
+
def rspec2?
|
13
|
+
!defined?(::RSpec::Expectations::Version) || (Gem::Version.new(RSpec::Expectations::Version::STRING) < Gem::Version.new('3.0'))
|
14
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Walpole
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain:
|
12
12
|
- gem-public_cert.pem
|
13
|
-
date: 2017-
|
13
|
+
date: 2017-05-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
@@ -273,6 +273,7 @@ files:
|
|
273
273
|
- License.txt
|
274
274
|
- README.md
|
275
275
|
- lib/capybara.rb
|
276
|
+
- lib/capybara/config.rb
|
276
277
|
- lib/capybara/cucumber.rb
|
277
278
|
- lib/capybara/driver/base.rb
|
278
279
|
- lib/capybara/driver/node.rb
|
@@ -304,6 +305,7 @@ files:
|
|
304
305
|
- lib/capybara/result.rb
|
305
306
|
- lib/capybara/rspec.rb
|
306
307
|
- lib/capybara/rspec/features.rb
|
308
|
+
- lib/capybara/rspec/matcher_proxies.rb
|
307
309
|
- lib/capybara/rspec/matchers.rb
|
308
310
|
- lib/capybara/selector.rb
|
309
311
|
- lib/capybara/selector/css.rb
|
@@ -314,6 +316,7 @@ files:
|
|
314
316
|
- lib/capybara/selenium/node.rb
|
315
317
|
- lib/capybara/server.rb
|
316
318
|
- lib/capybara/session.rb
|
319
|
+
- lib/capybara/session/config.rb
|
317
320
|
- lib/capybara/session/matchers.rb
|
318
321
|
- lib/capybara/spec/fixtures/another_test_file.txt
|
319
322
|
- lib/capybara/spec/fixtures/capybara.jpg
|
@@ -435,6 +438,7 @@ files:
|
|
435
438
|
- spec/fixtures/selenium_driver_rspec_success.rb
|
436
439
|
- spec/minitest_spec.rb
|
437
440
|
- spec/minitest_spec_spec.rb
|
441
|
+
- spec/per_session_config_spec.rb
|
438
442
|
- spec/rack_test_spec.rb
|
439
443
|
- spec/result_spec.rb
|
440
444
|
- spec/rspec/features_spec.rb
|
@@ -470,7 +474,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
470
474
|
version: '0'
|
471
475
|
requirements: []
|
472
476
|
rubyforge_project:
|
473
|
-
rubygems_version: 2.
|
477
|
+
rubygems_version: 2.6.11
|
474
478
|
signing_key:
|
475
479
|
specification_version: 4
|
476
480
|
summary: Capybara aims to simplify the process of integration testing Rack applications,
|