capybara-timeout_reporter 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c75044935f3b90eccb9b68217ffd681dcef0791
4
- data.tar.gz: 016704a5707be87444ed2d5def7b64bf7080d65c
3
+ metadata.gz: 12c6543ef86e3a77f0a6511c619f37f8aaf7d740
4
+ data.tar.gz: 0ed245bd57ae3264e67b9f34bdb20e111a9ca3ad
5
5
  SHA512:
6
- metadata.gz: 73582179dbfec194a715b1491af97a9fcfc0b3116306cf345f8664026a2d97d49c0aeb49d97ee2cf913b08ee6894091145bd6f5d35f56e3b0017025db1b013eb
7
- data.tar.gz: ea9c565633cb53479aee624868cd9167ec04e3ad4403b61ee49a606be1c303e537104430c715429e310f4e33d022b6540b4ef401132cdc6b24dbf9140a85d000
6
+ metadata.gz: 617862199f0d0225f13ad059d93b995d10bb5eb51e8a84b28ea8439b432d018dbb9d52f285b0ba5e3aa92820b27c273b51a79206c7509aac184e2c47cab62ef7
7
+ data.tar.gz: 6f15109092dd9d2410b79bf5e23df7ba846ffb1f29be46cd8425e4f22dcdd13404e55962fa70132c9be5c1d7698137dea853ac22b8c0e44c2b3b93c845c6d697
data/README.md CHANGED
@@ -61,7 +61,7 @@ Default beviour, in case of Capybara sync timeout the following warning will be
61
61
 
62
62
  ```
63
63
  # somewhere in your test_helper.rb, spec_helper.rb, evn.rb, etc.
64
- Capybara::TimeoutReporter.on_timeout = Proc.new do |timeout_value, src_line|
64
+ Capybara::TimeoutReporter.on_timeout do |timeout_value, src_line|
65
65
  # do whatever you want, for example:
66
66
  # - raise an exception, if you want to make this strict
67
67
  # - add an entry to test report, if you have one
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "capybara-timeout_reporter"
5
- spec.version = "0.0.4"
5
+ spec.version = "0.0.5"
6
6
  spec.authors = ["Vitalii Grygoruk"]
7
7
  spec.email = ["vitaliy[dot]grigoruk[at]gmail[dot]com"]
8
8
  spec.summary = %q{Detecting and reporting capybara sync timeouts}
@@ -2,17 +2,20 @@ require 'capybara'
2
2
 
3
3
  module Capybara
4
4
  class TimeoutReporter
5
- @on_timeout = Proc.new do |seconds, src_line|
6
- puts "[WARNING] Capybara find timed out after #{seconds} seconds in #{src_line}"
7
- end
8
5
 
9
6
  class << self
10
- attr_accessor :on_timeout
7
+ def on_timeout(&block)
8
+ @block = block
9
+ end
11
10
 
12
- def on_timeout=(proc)
13
- @on_timeout = proc
11
+ def report(seconds, src_line)
12
+ @block.call(seconds, src_line)
14
13
  end
15
14
  end
15
+
16
+ on_timeout do |seconds, src_line|
17
+ puts "[WARNING] Capybara find timed out after #{seconds} seconds in #{src_line}"
18
+ end
16
19
  end
17
20
 
18
21
  module Node
@@ -24,7 +27,7 @@ module Capybara
24
27
  if Time.now-start_time > seconds
25
28
  trace_line = Thread.current.backtrace.find { |l| !l.include?('gems/capybara') }
26
29
  src_line = trace_line.match(/(.*):.*/).captures.first
27
- Capybara::TimeoutReporter.on_timeout.call(seconds, src_line)
30
+ Capybara::TimeoutReporter.report(seconds, src_line)
28
31
  end
29
32
  raise e
30
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-timeout_reporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vitalii Grygoruk