capybara-webkit 1.12.0 → 1.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/Appraisals +3 -2
- data/Gemfile.lock +26 -18
- data/NEWS.md +9 -0
- data/README.md +4 -1
- data/capybara-webkit.gemspec +1 -1
- data/gemfiles/{2.11.gemfile → 2.12.gemfile} +1 -1
- data/gemfiles/2.7.gemfile +1 -0
- data/lib/capybara/webkit/browser.rb +25 -1
- data/lib/capybara/webkit/configuration.rb +4 -1
- data/lib/capybara/webkit/driver.rb +4 -0
- data/lib/capybara/webkit/errors.rb +9 -0
- data/lib/capybara/webkit/matchers.rb +5 -3
- data/lib/capybara/webkit/node.rb +1 -1
- data/lib/capybara/webkit/version.rb +1 -1
- data/spec/browser_spec.rb +22 -8
- data/spec/capybara_webkit_builder_spec.rb +4 -4
- data/spec/connection_spec.rb +3 -4
- data/spec/cookie_jar_spec.rb +10 -10
- data/spec/driver_rendering_spec.rb +14 -14
- data/spec/driver_resize_window_spec.rb +8 -8
- data/spec/driver_spec.rb +388 -349
- data/spec/errors_spec.rb +1 -1
- data/spec/integration/session_spec.rb +31 -31
- data/spec/selenium_compatibility_spec.rb +1 -1
- data/spec/server_spec.rb +11 -11
- data/spec/spec_helper.rb +11 -4
- data/spec/support/app_runner.rb +1 -0
- data/spec/support/matchers/include_response.rb +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f6bbf1dc179252a2f808fee415bcf4f94f3b0e0
|
4
|
+
data.tar.gz: 320d1b94e5241d9aca6195f246487d018bc2d4d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfe1194befdf9b3792390dab329ff59dab8ea834e132cf6d6c56d8f7a4df4748164593a5dd51c21c553b6a0c801f8bd6a9f0134b9b87d41a780c9a5d0dff75ff
|
7
|
+
data.tar.gz: 27309b5dcd287b804d83c97c64bcc9f11bdac110891160ace21bb908ab8b7b68b9691165c226e87a5d1d7fb5c5a180e49ded3f1f44c75e46b6e4e720f3f32127
|
data/.travis.yml
CHANGED
@@ -28,15 +28,15 @@ matrix:
|
|
28
28
|
gemfile: gemfiles/2.7.gemfile
|
29
29
|
env: QMAKE=/usr/lib/x86_64-linux-gnu/qt4/bin/qmake
|
30
30
|
- rvm: 1.9.3
|
31
|
-
gemfile: gemfiles/2.
|
31
|
+
gemfile: gemfiles/2.12.gemfile
|
32
32
|
env: QMAKE=/usr/lib/x86_64-linux-gnu/qt4/bin/qmake
|
33
|
-
- rvm: 2.3.
|
33
|
+
- rvm: 2.3.3
|
34
34
|
gemfile: gemfiles/master.gemfile
|
35
35
|
allow_failures:
|
36
36
|
- gemfile: gemfiles/master.gemfile
|
37
37
|
gemfile:
|
38
38
|
- gemfiles/2.7.gemfile
|
39
|
-
- gemfiles/2.
|
39
|
+
- gemfiles/2.12.gemfile
|
40
40
|
before_install:
|
41
41
|
- gem install bundler
|
42
42
|
install: bundle
|
data/Appraisals
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
appraise "2.7" do
|
2
2
|
gem "capybara", "~> 2.7.0"
|
3
|
+
gem "rspec", "~> 2.14.0"
|
3
4
|
gem 'addressable', '< 2.5.0', :platforms=>[:ruby_19, :jruby_19] # 2.5 requires public_suffix which requires ruby 2.0
|
4
5
|
gem 'nokogiri', '< 1.7.0', :platforms=>[:ruby_19, :jruby_19] # 1.7.0 requires ruby 2.1+
|
5
6
|
end
|
6
7
|
|
7
|
-
appraise "2.
|
8
|
-
gem "capybara", "~> 2.
|
8
|
+
appraise "2.12" do
|
9
|
+
gem "capybara", "~> 2.12.0"
|
9
10
|
gem 'addressable', '< 2.5.0', :platforms=>[:ruby_19, :jruby_19] # 2.5 requires public_suffix which requires ruby 2.0
|
10
11
|
gem 'nokogiri', '< 1.7.0', :platforms=>[:ruby_19, :jruby_19] # 1.7.0 requires ruby 2.1+
|
11
12
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
capybara-webkit (1.
|
4
|
+
capybara-webkit (1.13.0)
|
5
5
|
capybara (>= 2.3.0, < 2.13.0)
|
6
6
|
json
|
7
7
|
|
@@ -13,17 +13,17 @@ GEM
|
|
13
13
|
appraisal (0.4.1)
|
14
14
|
bundler
|
15
15
|
rake
|
16
|
-
capybara (2.
|
16
|
+
capybara (2.12.0)
|
17
17
|
addressable
|
18
18
|
mime-types (>= 1.16)
|
19
19
|
nokogiri (>= 1.3.3)
|
20
20
|
rack (>= 1.0.0)
|
21
21
|
rack-test (>= 0.5.4)
|
22
22
|
xpath (~> 2.0)
|
23
|
-
diff-lcs (1.
|
24
|
-
ffi (1.9.
|
25
|
-
json (1.8.
|
26
|
-
json (1.8.
|
23
|
+
diff-lcs (1.3)
|
24
|
+
ffi (1.9.17-java)
|
25
|
+
json (1.8.6)
|
26
|
+
json (1.8.6-java)
|
27
27
|
launchy (2.4.3)
|
28
28
|
addressable (~> 2.3)
|
29
29
|
launchy (2.4.3-java)
|
@@ -34,6 +34,9 @@ GEM
|
|
34
34
|
mini_portile2 (2.1.0)
|
35
35
|
nokogiri (1.7.0.1)
|
36
36
|
mini_portile2 (~> 2.1.0)
|
37
|
+
nokogiri (1.7.0.1-java)
|
38
|
+
nokogiri (1.7.0.1-x86-mingw32)
|
39
|
+
mini_portile2 (~> 2.1.0)
|
37
40
|
public_suffix (2.0.5)
|
38
41
|
rack (1.6.5)
|
39
42
|
rack-protection (1.5.3)
|
@@ -41,21 +44,26 @@ GEM
|
|
41
44
|
rack-test (0.6.3)
|
42
45
|
rack (>= 1.0)
|
43
46
|
rake (11.3.0)
|
44
|
-
rspec (
|
45
|
-
rspec-core (~>
|
46
|
-
rspec-expectations (~>
|
47
|
-
rspec-mocks (~>
|
48
|
-
rspec-core (
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
47
|
+
rspec (3.5.0)
|
48
|
+
rspec-core (~> 3.5.0)
|
49
|
+
rspec-expectations (~> 3.5.0)
|
50
|
+
rspec-mocks (~> 3.5.0)
|
51
|
+
rspec-core (3.5.4)
|
52
|
+
rspec-support (~> 3.5.0)
|
53
|
+
rspec-expectations (3.5.0)
|
54
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
55
|
+
rspec-support (~> 3.5.0)
|
56
|
+
rspec-mocks (3.5.0)
|
57
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
58
|
+
rspec-support (~> 3.5.0)
|
59
|
+
rspec-support (3.5.0)
|
60
|
+
sinatra (1.4.8)
|
53
61
|
rack (~> 1.5)
|
54
62
|
rack-protection (~> 1.4)
|
55
63
|
tilt (>= 1.3, < 3)
|
56
64
|
spoon (0.0.6)
|
57
65
|
ffi
|
58
|
-
tilt (2.0.
|
66
|
+
tilt (2.0.6)
|
59
67
|
xpath (2.0.0)
|
60
68
|
nokogiri (~> 1.3)
|
61
69
|
|
@@ -72,8 +80,8 @@ DEPENDENCIES
|
|
72
80
|
mime-types (< 3.0)
|
73
81
|
mini_magick
|
74
82
|
rake (< 12.0.0)
|
75
|
-
rspec (~>
|
83
|
+
rspec (~> 3.5)
|
76
84
|
sinatra
|
77
85
|
|
78
86
|
BUNDLED WITH
|
79
|
-
1.
|
87
|
+
1.14.3
|
data/NEWS.md
CHANGED
data/README.md
CHANGED
@@ -129,6 +129,9 @@ Capybara::Webkit.configure do |config|
|
|
129
129
|
user: "proxy",
|
130
130
|
pass: "secret"
|
131
131
|
)
|
132
|
+
|
133
|
+
# Raise JavaScript errors as exceptions
|
134
|
+
config.raise_javascript_errors = true
|
132
135
|
end
|
133
136
|
```
|
134
137
|
|
@@ -206,7 +209,7 @@ The capybara WebKit driver is maintained by Joe Ferris and Matt Horan.
|
|
206
209
|
Code for rendering the current webpage to a PNG is borrowed from Phantom.js'
|
207
210
|
implementation.
|
208
211
|
|
209
|
-
![thoughtbot](
|
212
|
+
![thoughtbot](http://presskit.thoughtbot.com/images/thoughtbot-logo-for-readmes.svg)
|
210
213
|
|
211
214
|
capybara-webkit is maintained and funded by thoughtbot, inc.
|
212
215
|
The names and logos for thoughtbot are trademarks of thoughtbot, inc.
|
data/capybara-webkit.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_runtime_dependency("capybara", ">= 2.3.0", "< 2.13.0")
|
25
25
|
s.add_runtime_dependency("json")
|
26
26
|
|
27
|
-
s.add_development_dependency("rspec", "~>
|
27
|
+
s.add_development_dependency("rspec", "~> 3.5")
|
28
28
|
# Sinatra is used by Capybara's TestApp
|
29
29
|
s.add_development_dependency("sinatra")
|
30
30
|
s.add_development_dependency("mini_magick")
|
@@ -4,7 +4,7 @@ source "https://rubygems.org"
|
|
4
4
|
|
5
5
|
gem "mime-types", "< 3.0", :platforms=>[:ruby_19, :jruby_19]
|
6
6
|
gem "json", "< 2.0", :platforms=>[:ruby_19, :jruby_19]
|
7
|
-
gem "capybara", "~> 2.
|
7
|
+
gem "capybara", "~> 2.12.0"
|
8
8
|
gem "addressable", "< 2.5.0", :platforms=>[:ruby_19, :jruby_19]
|
9
9
|
gem "nokogiri", "< 1.7.0", :platforms=>[:ruby_19, :jruby_19]
|
10
10
|
|
data/gemfiles/2.7.gemfile
CHANGED
@@ -5,6 +5,7 @@ source "https://rubygems.org"
|
|
5
5
|
gem "mime-types", "< 3.0", :platforms=>[:ruby_19, :jruby_19]
|
6
6
|
gem "json", "< 2.0", :platforms=>[:ruby_19, :jruby_19]
|
7
7
|
gem "capybara", "~> 2.7.0"
|
8
|
+
gem "rspec", "~> 2.14.0"
|
8
9
|
gem "addressable", "< 2.5.0", :platforms=>[:ruby_19, :jruby_19]
|
9
10
|
gem "nokogiri", "< 1.7.0", :platforms=>[:ruby_19, :jruby_19]
|
10
11
|
|
@@ -5,6 +5,7 @@ module Capybara::Webkit
|
|
5
5
|
class Browser
|
6
6
|
def initialize(connection)
|
7
7
|
@connection = connection
|
8
|
+
apply_defaults
|
8
9
|
end
|
9
10
|
|
10
11
|
def authenticate(username, password)
|
@@ -36,6 +37,7 @@ module Capybara::Webkit
|
|
36
37
|
end
|
37
38
|
|
38
39
|
def reset!
|
40
|
+
apply_defaults
|
39
41
|
command("Reset")
|
40
42
|
end
|
41
43
|
|
@@ -99,6 +101,14 @@ module Capybara::Webkit
|
|
99
101
|
command("SetSkipImageLoading", skip_image_loading)
|
100
102
|
end
|
101
103
|
|
104
|
+
def set_raise_javascript_errors(is_enabled)
|
105
|
+
@raise_javascript_errors = is_enabled
|
106
|
+
end
|
107
|
+
|
108
|
+
def raise_javascript_errors?
|
109
|
+
@raise_javascript_errors
|
110
|
+
end
|
111
|
+
|
102
112
|
def window_focus(selector)
|
103
113
|
command("WindowFocus", selector)
|
104
114
|
end
|
@@ -209,7 +219,9 @@ module Capybara::Webkit
|
|
209
219
|
@connection.print arg.to_s
|
210
220
|
end
|
211
221
|
check
|
212
|
-
read_response
|
222
|
+
response = read_response
|
223
|
+
check_javascript_errors(name)
|
224
|
+
response
|
213
225
|
rescue SystemCallError => exception
|
214
226
|
@connection.restart
|
215
227
|
raise(Capybara::Webkit::CrashError, <<-MESSAGE.strip)
|
@@ -295,6 +307,10 @@ https://github.com/thoughtbot/capybara-webkit/wiki/Reporting-Crashes
|
|
295
307
|
|
296
308
|
private
|
297
309
|
|
310
|
+
def apply_defaults
|
311
|
+
@raise_javascript_errors = false
|
312
|
+
end
|
313
|
+
|
298
314
|
def check
|
299
315
|
result = @connection.gets
|
300
316
|
result.strip! if result
|
@@ -308,6 +324,14 @@ https://github.com/thoughtbot/capybara-webkit/wiki/Reporting-Crashes
|
|
308
324
|
result
|
309
325
|
end
|
310
326
|
|
327
|
+
def check_javascript_errors(command_name)
|
328
|
+
return if command_name == "ConsoleMessages"
|
329
|
+
|
330
|
+
if raise_javascript_errors? && error_messages.any?
|
331
|
+
raise JavaScriptError, error_messages
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
311
335
|
def read_response
|
312
336
|
response_length = @connection.gets.to_i
|
313
337
|
if response_length > 0
|
@@ -30,6 +30,7 @@ module Capybara
|
|
30
30
|
attr_accessor :stderr
|
31
31
|
attr_accessor :timeout
|
32
32
|
attr_writer :skip_image_loading
|
33
|
+
attr_accessor :raise_javascript_errors
|
33
34
|
|
34
35
|
def initialize
|
35
36
|
@allowed_urls = []
|
@@ -41,6 +42,7 @@ module Capybara
|
|
41
42
|
@skip_image_loading = false
|
42
43
|
@stderr = $stderr
|
43
44
|
@timeout = -1
|
45
|
+
@raise_javascript_errors = false
|
44
46
|
end
|
45
47
|
|
46
48
|
def allow_url(url)
|
@@ -93,7 +95,8 @@ module Capybara
|
|
93
95
|
proxy: proxy,
|
94
96
|
skip_image_loading: skip_image_loading?,
|
95
97
|
stderr: stderr,
|
96
|
-
timeout: timeout
|
98
|
+
timeout: timeout,
|
99
|
+
raise_javascript_errors: raise_javascript_errors,
|
97
100
|
}
|
98
101
|
end
|
99
102
|
end
|
@@ -398,6 +398,10 @@ module Capybara::Webkit
|
|
398
398
|
@browser.timeout = @options[:timeout]
|
399
399
|
end
|
400
400
|
|
401
|
+
if @options.has_key? :raise_javascript_errors
|
402
|
+
@browser.set_raise_javascript_errors(@options[:raise_javascript_errors])
|
403
|
+
end
|
404
|
+
|
401
405
|
Array(@options[:allowed_urls]).each { |url| @browser.allow_url(url) }
|
402
406
|
Array(@options[:blocked_urls]).each { |url| @browser.block_url(url) }
|
403
407
|
end
|
@@ -44,4 +44,13 @@ module Capybara::Webkit
|
|
44
44
|
Capybara::Webkit.const_get @class_name
|
45
45
|
end
|
46
46
|
end
|
47
|
+
|
48
|
+
class JavaScriptError < StandardError
|
49
|
+
def initialize(errors)
|
50
|
+
@javascript_errors = errors
|
51
|
+
super(errors.join(","))
|
52
|
+
end
|
53
|
+
|
54
|
+
attr_reader :javascript_errors
|
55
|
+
end
|
47
56
|
end
|
@@ -7,11 +7,13 @@ module Capybara
|
|
7
7
|
actual.error_messages.any?
|
8
8
|
end
|
9
9
|
|
10
|
-
|
10
|
+
#RSpec 2 compatability
|
11
|
+
send(respond_to?(:failure_message) ? :failure_message : :failure_message_for_should) do |_actual|
|
11
12
|
"Expected Javascript errors, but there were none."
|
12
13
|
end
|
13
|
-
|
14
|
-
|
14
|
+
|
15
|
+
#RSpec 2 compatability
|
16
|
+
send(respond_to?(:failure_message_when_negated) ? :failure_message_when_negated : :failure_message_for_should_not) do |actual|
|
15
17
|
actual = resolve(actual)
|
16
18
|
"Expected no Javascript errors, got:\n#{error_messages_for(actual)}"
|
17
19
|
end
|
data/lib/capybara/webkit/node.rb
CHANGED
data/spec/browser_spec.rb
CHANGED
@@ -21,11 +21,9 @@ describe Capybara::Webkit::Browser do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "doesn't try to read an empty response" do
|
24
|
-
connection = double("connection")
|
25
|
-
connection.
|
26
|
-
connection.
|
27
|
-
connection.stub(:gets).and_return("ok\n", "0\n")
|
28
|
-
connection.stub(:read).and_raise(StandardError.new("tried to read empty response"))
|
24
|
+
connection = double("connection", puts: nil, print: nil)
|
25
|
+
allow(connection).to receive(:gets).and_return("ok\n", "0\n")
|
26
|
+
allow(connection).to receive(:read).and_raise(StandardError.new("tried to read empty response"))
|
29
27
|
|
30
28
|
browser = Capybara::Webkit::Browser.new(connection)
|
31
29
|
|
@@ -37,12 +35,28 @@ describe Capybara::Webkit::Browser do
|
|
37
35
|
it 'raises an error of given class' do
|
38
36
|
error_json = '{"class": "ClickFailed"}'
|
39
37
|
|
40
|
-
connection.
|
41
|
-
connection.
|
42
|
-
connection.
|
38
|
+
expect(connection).to receive(:gets).ordered.and_return 'error'
|
39
|
+
expect(connection).to receive(:gets).ordered.and_return error_json.bytesize
|
40
|
+
allow(connection).to receive(:read).and_return(error_json)
|
43
41
|
|
44
42
|
expect { browser.command 'blah', 'meh' }.to raise_error(Capybara::Webkit::ClickFailed)
|
45
43
|
end
|
46
44
|
end
|
47
45
|
end
|
46
|
+
|
47
|
+
describe "#reset!" do
|
48
|
+
it "resets to the default state" do
|
49
|
+
connection = double("connection", puts: nil, print: nil)
|
50
|
+
allow(connection).to receive(:gets).and_return("ok\n", "{}\n")
|
51
|
+
|
52
|
+
browser = Capybara::Webkit::Browser.new(connection)
|
53
|
+
browser.set_raise_javascript_errors(true)
|
54
|
+
|
55
|
+
expect(browser.raise_javascript_errors?).to be true
|
56
|
+
|
57
|
+
browser.reset!
|
58
|
+
|
59
|
+
expect(browser.raise_javascript_errors?).to be false
|
60
|
+
end
|
61
|
+
end
|
48
62
|
end
|
@@ -6,25 +6,25 @@ describe CapybaraWebkitBuilder do
|
|
6
6
|
|
7
7
|
it "will use the env variable for #make_bin" do
|
8
8
|
with_env_vars("MAKE" => "fake_make") do
|
9
|
-
builder.make_bin.
|
9
|
+
expect(builder.make_bin).to eq "fake_make"
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
it "will use the env variable for #qmake_bin" do
|
14
14
|
with_env_vars("QMAKE" => "fake_qmake") do
|
15
|
-
builder.qmake_bin.
|
15
|
+
expect(builder.qmake_bin).to eq "fake_qmake"
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
it "defaults the #make_bin" do
|
20
20
|
with_env_vars("MAKE_BIN" => nil) do
|
21
|
-
builder.make_bin.
|
21
|
+
expect(builder.make_bin).to eq 'make'
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
it "defaults the #qmake_bin" do
|
26
26
|
with_env_vars("QMAKE" => nil) do
|
27
|
-
builder.qmake_bin.
|
27
|
+
expect(builder.qmake_bin).to eq 'qmake'
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
data/spec/connection_spec.rb
CHANGED
@@ -5,13 +5,12 @@ describe Capybara::Webkit::Connection do
|
|
5
5
|
it "sets appropriate options on its socket" do
|
6
6
|
socket = double("socket")
|
7
7
|
server = double(:Server, start: nil, port: 123)
|
8
|
-
TCPSocket.
|
8
|
+
allow(TCPSocket).to receive(:open).and_return(socket)
|
9
9
|
if defined?(Socket::TCP_NODELAY)
|
10
|
-
socket.
|
11
|
-
should_receive(:setsockopt).
|
10
|
+
expect(socket).to receive(:setsockopt).
|
12
11
|
with(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, true)
|
13
12
|
else
|
14
|
-
socket.
|
13
|
+
expect(socket).not_to receive(:setsockopt)
|
15
14
|
end
|
16
15
|
|
17
16
|
Capybara::Webkit::Connection.new(server: server)
|