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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: efdcc01079f8576da25de8dff0b6c127170509e5
4
- data.tar.gz: 48a04c108401162206fb5961fd2fa44fabd18e2d
3
+ metadata.gz: 8f6bbf1dc179252a2f808fee415bcf4f94f3b0e0
4
+ data.tar.gz: 320d1b94e5241d9aca6195f246487d018bc2d4d9
5
5
  SHA512:
6
- metadata.gz: 234683f1ab1be1f2c7a1ddbdcac6c0389b705a385947e5a86d142b92d6317f6ad4e9fce7d19a55e07f398f3822bd1dcb214d92295301b74c38d72fb6479a6f1c
7
- data.tar.gz: 9b6ad7da59e67012182e27044619b229674f961429cf272dc0c96298eac4fee1fd3aed74c15dbaf7c2db44b724b510b0a99542e9b0abbc7b87a8584b9fa66ce8
6
+ metadata.gz: cfe1194befdf9b3792390dab329ff59dab8ea834e132cf6d6c56d8f7a4df4748164593a5dd51c21c553b6a0c801f8bd6a9f0134b9b87d41a780c9a5d0dff75ff
7
+ data.tar.gz: 27309b5dcd287b804d83c97c64bcc9f11bdac110891160ace21bb908ab8b7b68b9691165c226e87a5d1d7fb5c5a180e49ded3f1f44c75e46b6e4e720f3f32127
@@ -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.11.gemfile
31
+ gemfile: gemfiles/2.12.gemfile
32
32
  env: QMAKE=/usr/lib/x86_64-linux-gnu/qt4/bin/qmake
33
- - rvm: 2.3.1
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.11.gemfile
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.11" do
8
- gem "capybara", "~> 2.11.0"
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capybara-webkit (1.12.0)
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.11.0)
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.2.5)
24
- ffi (1.9.14-java)
25
- json (1.8.3)
26
- json (1.8.3-java)
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 (2.99.0)
45
- rspec-core (~> 2.99.0)
46
- rspec-expectations (~> 2.99.0)
47
- rspec-mocks (~> 2.99.0)
48
- rspec-core (2.99.2)
49
- rspec-expectations (2.99.2)
50
- diff-lcs (>= 1.1.3, < 2.0)
51
- rspec-mocks (2.99.4)
52
- sinatra (1.4.7)
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.5)
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 (~> 2.14)
83
+ rspec (~> 3.5)
76
84
  sinatra
77
85
 
78
86
  BUNDLED WITH
79
- 1.13.6
87
+ 1.14.3
data/NEWS.md CHANGED
@@ -1,3 +1,12 @@
1
+ New for 1.13.0:
2
+
3
+ * Allow JavaScript errors to be raised as Ruby exceptions
4
+ (`config.raise_javascript_errors` option)
5
+
6
+ New for 1.12.0:
7
+
8
+ * Capybara 2.11 compatibility
9
+
1
10
  New for 1.11.1:
2
11
 
3
12
  * Fix compiling on OS X with Qt 4.8
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](https://thoughtbot.com/logo.png)
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.
@@ -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", "~> 2.14")
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.11.0"
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
 
@@ -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
- failure_message_for_should do |actual|
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
- failure_message_for_should_not do |actual|
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
@@ -59,7 +59,7 @@ module Capybara::Webkit
59
59
  when String
60
60
  key.to_s
61
61
  else
62
- raise Capybara::NotSupportedByDriverError.new
62
+ raise Capybara::NotSupportedByDriverError.new, "Unrecognized key(s) in #{key}"
63
63
  end
64
64
  }.join)
65
65
  end
@@ -1,7 +1,7 @@
1
1
  module Capybara
2
2
  module Driver
3
3
  class Webkit
4
- VERSION = "1.12.0".freeze
4
+ VERSION = "1.13.0".freeze
5
5
  end
6
6
  end
7
7
  end
@@ -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.stub(:puts)
26
- connection.stub(:print)
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.should_receive(:gets).ordered.and_return 'error'
41
- connection.should_receive(:gets).ordered.and_return error_json.bytesize
42
- connection.stub read: error_json
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.should == "fake_make"
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.should == "fake_qmake"
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.should == 'make'
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.should == 'qmake'
27
+ expect(builder.qmake_bin).to eq 'qmake'
28
28
  end
29
29
  end
30
30
  end
@@ -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.stub(:open).and_return(socket)
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.should_not_receive(:setsockopt)
13
+ expect(socket).not_to receive(:setsockopt)
15
14
  end
16
15
 
17
16
  Capybara::Webkit::Connection.new(server: server)