capybara-mechanize 1.10.1 → 1.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.mdown +24 -2
- data/lib/capybara/mechanize/browser.rb +41 -37
- data/lib/capybara/mechanize/cucumber.rb +3 -1
- data/lib/capybara/mechanize/driver.rb +9 -3
- data/lib/capybara/mechanize/form.rb +11 -20
- data/lib/capybara/mechanize/node.rb +8 -10
- data/lib/capybara/mechanize/version.rb +3 -1
- data/lib/capybara/mechanize.rb +6 -7
- data/lib/capybara/spec/extended_test_app.rb +19 -16
- data/spec/driver/mechanize_driver_spec.rb +72 -71
- data/spec/driver/remote_mechanize_driver_spec.rb +17 -15
- data/spec/session/mechanize_spec.rb +59 -43
- data/spec/session/remote_mechanize_spec.rb +57 -53
- data/spec/spec_helper.rb +4 -5
- data/spec/support/disable_external_tests.rb +4 -3
- data/spec/support/extended_test_app_setup.rb +2 -0
- data/spec/support/remote_test_url.rb +3 -1
- metadata +73 -18
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module TestSessions
|
4
|
-
|
6
|
+
RemoteMechanize = Capybara::Session.new(:mechanize, TestApp)
|
5
7
|
end
|
6
8
|
|
7
|
-
shared_context
|
9
|
+
shared_context 'remote tests' do
|
8
10
|
before do
|
9
11
|
Capybara.app_host = remote_test_url
|
10
12
|
end
|
@@ -14,29 +16,31 @@ shared_context "remote tests" do
|
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
19
|
+
skipped_tests = %i[
|
20
|
+
about_scheme
|
21
|
+
active_element
|
22
|
+
css
|
23
|
+
download
|
24
|
+
frames
|
25
|
+
hover
|
26
|
+
html_validation
|
27
|
+
js
|
28
|
+
modals
|
29
|
+
screenshot
|
30
|
+
scroll
|
31
|
+
send_keys
|
32
|
+
server
|
33
|
+
shadow_dom
|
34
|
+
spatial
|
35
|
+
windows
|
27
36
|
]
|
28
37
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
['#has_current_path?', 'should compare the full url if url: true is used'],
|
36
|
-
['#reset_session!', 'raises any errors caught inside the server'],
|
37
|
-
['#reset_session!', 'raises any standard errors caught inside the server']
|
38
|
-
]
|
39
|
-
disabler.disable(session_describe)
|
38
|
+
Capybara::SpecHelper.run_specs(TestSessions::RemoteMechanize, 'RemoteMechanize', capybara_skip: skipped_tests) do |example|
|
39
|
+
case example.metadata[:full_description]
|
40
|
+
when /has_css\? should support case insensitive :class and :id options/
|
41
|
+
skip "Nokogiri doesn't support case insensitive CSS attribute matchers"
|
42
|
+
end
|
43
|
+
end
|
40
44
|
|
41
45
|
describe Capybara::Session do
|
42
46
|
context 'with remote mechanize driver' do
|
@@ -45,37 +49,37 @@ describe Capybara::Session do
|
|
45
49
|
let(:session) { Capybara::Session.new(:mechanize, ExtendedTestApp) }
|
46
50
|
|
47
51
|
describe '#driver' do
|
48
|
-
it
|
49
|
-
session.driver.
|
52
|
+
it 'should be a mechanize driver' do
|
53
|
+
expect(session.driver).to be_an_instance_of(Capybara::Mechanize::Driver)
|
50
54
|
end
|
51
55
|
end
|
52
56
|
|
53
57
|
describe '#mode' do
|
54
|
-
it
|
55
|
-
session.mode.
|
58
|
+
it 'should remember the mode' do
|
59
|
+
expect(session.mode).to eq(:mechanize)
|
56
60
|
end
|
57
61
|
end
|
58
62
|
|
59
63
|
describe '#click_link' do
|
60
|
-
it
|
64
|
+
it 'should use data-method if option is true' do
|
61
65
|
session.driver.options[:respect_data_method] = true
|
62
|
-
session.visit
|
63
|
-
session.click_link
|
64
|
-
session.html.
|
66
|
+
session.visit '/with_html'
|
67
|
+
session.click_link 'A link with data-method'
|
68
|
+
expect(session.html).to include('The requested object was deleted')
|
65
69
|
end
|
66
70
|
|
67
|
-
it
|
71
|
+
it 'should not use data-method if option is false' do
|
68
72
|
session.driver.options[:respect_data_method] = false
|
69
|
-
session.visit
|
70
|
-
session.click_link
|
71
|
-
session.html.
|
73
|
+
session.visit '/with_html'
|
74
|
+
session.click_link 'A link with data-method'
|
75
|
+
expect(session.html).to include('Not deleted')
|
72
76
|
end
|
73
77
|
|
74
78
|
it "should use data-method if available even if it's capitalized" do
|
75
79
|
session.driver.options[:respect_data_method] = true
|
76
|
-
session.visit
|
77
|
-
session.click_link
|
78
|
-
session.html.
|
80
|
+
session.visit '/with_html'
|
81
|
+
session.click_link 'A link with capitalized data-method'
|
82
|
+
expect(session.html).to include('The requested object was deleted')
|
79
83
|
end
|
80
84
|
|
81
85
|
after do
|
@@ -83,27 +87,27 @@ describe Capybara::Session do
|
|
83
87
|
end
|
84
88
|
end
|
85
89
|
|
86
|
-
describe
|
87
|
-
context
|
88
|
-
it
|
89
|
-
session.visit(
|
90
|
-
session.click_button(
|
91
|
-
session.html.
|
90
|
+
describe '#attach_file' do
|
91
|
+
context 'with multipart form' do
|
92
|
+
it 'should submit an empty form-data section if no file is submitted' do
|
93
|
+
session.visit('/form')
|
94
|
+
session.click_button('Upload Empty')
|
95
|
+
expect(session.html).to include('Successfully ignored empty file field.')
|
92
96
|
end
|
93
97
|
end
|
94
98
|
end
|
95
99
|
|
96
|
-
context
|
97
|
-
it
|
98
|
-
session.visit
|
99
|
-
session.click_link
|
100
|
-
session.body.
|
100
|
+
context 'remote app in a sub-path' do
|
101
|
+
it 'follows relative link correctly' do
|
102
|
+
session.visit '/subsite/relative_link_to_host'
|
103
|
+
session.click_link 'host'
|
104
|
+
expect(session.body).to include('request_info2/host')
|
101
105
|
end
|
102
106
|
|
103
|
-
it
|
104
|
-
session.visit
|
105
|
-
session.click_link
|
106
|
-
session.body.
|
107
|
+
it 'follows local link correctly' do
|
108
|
+
session.visit '/subsite/local_link_to_host'
|
109
|
+
session.click_link 'host'
|
110
|
+
expect(session.body).to include('request_info2/host')
|
107
111
|
end
|
108
112
|
end
|
109
113
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'capybara/spec/spec_helper'
|
2
4
|
require 'capybara/mechanize'
|
3
5
|
require 'capybara/spec/extended_test_app'
|
@@ -9,10 +11,8 @@ $LOAD_PATH << File.join(PROJECT_ROOT, 'lib')
|
|
9
11
|
Dir[File.join(PROJECT_ROOT, 'spec', 'support', '**', '*.rb')].each { |file| require(file) }
|
10
12
|
|
11
13
|
RSpec.configure do |config|
|
12
|
-
|
13
|
-
# config.filter_run :focus => true
|
14
|
+
config.filter_run focus: true unless ENV['CI']
|
14
15
|
config.run_all_when_everything_filtered = true
|
15
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
16
16
|
|
17
17
|
# Used with DisableExternalTests
|
18
18
|
config.filter_run_excluding :external_test_disabled
|
@@ -27,8 +27,7 @@ RSpec.configure do |config|
|
|
27
27
|
|
28
28
|
Capybara::SpecHelper.configure(config)
|
29
29
|
|
30
|
-
config.order =
|
30
|
+
config.order = 'random'
|
31
31
|
|
32
32
|
CAPYBARA_DEFAULT_HOST = Capybara.default_host
|
33
33
|
end
|
34
|
-
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class DisableExternalTests
|
2
4
|
attr_accessor :tests_to_disable
|
3
5
|
|
@@ -8,13 +10,12 @@ class DisableExternalTests
|
|
8
10
|
example_description = to_disable.pop
|
9
11
|
|
10
12
|
to_disable.each do |description|
|
11
|
-
example_group = example_group.children.find{ |g| g.description == description }
|
13
|
+
example_group = example_group.children.find { |g| g.description == description }
|
12
14
|
end
|
13
15
|
|
14
|
-
example = example_group.examples.find{ |e| e.description == example_description }
|
16
|
+
example = example_group.examples.find { |e| e.description == example_description }
|
15
17
|
|
16
18
|
example.metadata[:external_test_disabled] = true unless example.nil?
|
17
19
|
end
|
18
|
-
|
19
20
|
end
|
20
21
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This class works around some weirdness with Capybara's test suite and sinatra's behavior.
|
2
4
|
# We need to make sure that sinatra uses TestApp for at least one request before the Capybara session
|
3
5
|
# specs run. Without this we get errors from sinatra trying to handle requests with TestApp.clone
|
metadata
CHANGED
@@ -1,49 +1,105 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara-mechanize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeroen van Dijk
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capybara
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.0.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.37.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.0.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.37.0
|
13
33
|
- !ruby/object:Gem::Dependency
|
14
34
|
name: mechanize
|
15
35
|
requirement: !ruby/object:Gem::Requirement
|
16
36
|
requirements:
|
17
37
|
- - "~>"
|
18
38
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
39
|
+
version: 2.8.5
|
20
40
|
type: :runtime
|
21
41
|
prerelease: false
|
22
42
|
version_requirements: !ruby/object:Gem::Requirement
|
23
43
|
requirements:
|
24
44
|
- - "~>"
|
25
45
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
46
|
+
version: 2.8.5
|
27
47
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
48
|
+
name: launchy
|
29
49
|
requirement: !ruby/object:Gem::Requirement
|
30
50
|
requirements:
|
31
51
|
- - ">="
|
32
52
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
34
|
-
|
53
|
+
version: 2.0.4
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
35
59
|
- !ruby/object:Gem::Version
|
36
|
-
version:
|
37
|
-
|
60
|
+
version: 2.0.4
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rake
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
38
69
|
prerelease: false
|
39
70
|
version_requirements: !ruby/object:Gem::Requirement
|
40
71
|
requirements:
|
41
72
|
- - ">="
|
42
73
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
44
|
-
|
74
|
+
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rdoc
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rspec
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
45
94
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
95
|
+
version: '3.5'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '3.5'
|
47
103
|
description: RackTest driver for Capybara, but with remote request support thanks
|
48
104
|
to mechanize
|
49
105
|
email: jeroen@jeevidee.nl
|
@@ -71,7 +127,7 @@ files:
|
|
71
127
|
homepage: https://github.com/jeroenvandijk/capybara-mechanize
|
72
128
|
licenses: []
|
73
129
|
metadata: {}
|
74
|
-
post_install_message:
|
130
|
+
post_install_message:
|
75
131
|
rdoc_options:
|
76
132
|
- "--charset=UTF-8"
|
77
133
|
require_paths:
|
@@ -80,16 +136,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
80
136
|
requirements:
|
81
137
|
- - ">="
|
82
138
|
- !ruby/object:Gem::Version
|
83
|
-
version:
|
139
|
+
version: 2.6.0
|
84
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
141
|
requirements:
|
86
142
|
- - ">="
|
87
143
|
- !ruby/object:Gem::Version
|
88
144
|
version: '0'
|
89
145
|
requirements: []
|
90
|
-
|
91
|
-
|
92
|
-
signing_key:
|
146
|
+
rubygems_version: 3.1.4
|
147
|
+
signing_key:
|
93
148
|
specification_version: 4
|
94
149
|
summary: RackTest driver for Capybara with remote request support
|
95
150
|
test_files: []
|