capybara-timeout_reporter 0.0.2 → 0.0.3

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: 03703999c0f4fd8d190a040d1841e44a3f4e854d
4
- data.tar.gz: 3d0933e28205bdfd4d893d343a84ad99cdbea023
3
+ metadata.gz: 62b6f37fe93057ed0c1681182ec3fb4e532856c4
4
+ data.tar.gz: 80f921a198fea2ceb8c738732aa9804c4f471ed4
5
5
  SHA512:
6
- metadata.gz: 1c8d91abedf02fa191b066c11dda154072c3c3bba5199a30c98a68d2a618e9498fe9e56eac98979fc3f4b5302b20ee6aeef8b69f641fc7e3297075daf1da259c
7
- data.tar.gz: 5fcfbc394e8b8c63e993c095fc678d4d3f8992d5e4ee8c1b7bc61ec91d07f4035dd0bc01dbf78a8da7e605965fe2c7c74a41b7c8246279b3ea09615798176c7e
6
+ metadata.gz: c677a85c395346f16872102ec32fbc755c7e9de6ec035db9495d9a020b656e2749011d84cc0ba84517d83e022b5a3de419a60ac1f5e33ec2c76a796a84e3a1a8
7
+ data.tar.gz: d8142a55529e44ad4419e8f34454e60d0276b48037847dfa52486607ac3111ea56ac2dfd4df5c37ae2b8f81787a4f622b4cdf18e88f49239d363da6081e22132
data/README.md CHANGED
@@ -1,10 +1,78 @@
1
1
  # Capybara::TimeoutReporter
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/capybara-timeout_reporter.svg)](http://badge.fury.io/rb/capybara-timeout_reporter)
4
+
3
5
  Speed up your Capybara tests by detecting and fixing finders that reach sync timeout.
4
6
 
7
+ # Description
8
+
9
+ Capybara gem is very popular in ruby community for browser-based UI test automation of web apps. Capybara has quite powerful [synchronization mechanism](https://github.com/jnicklas/capybara#asynchronous-javascript-ajax-and-friends) built in, which allows you to write tests that wait automatically until AJAX requests are completed, elements become visible, etc. However, very often engineers do not keep this Capybara feature in mind and write code like this:
10
+
11
+ ```
12
+ # this line will be executing for 'Capybara.default_wait_time' seconds
13
+ refute page.has_css?('.some-non-existent-class')
14
+ ```
15
+
16
+ Or like this:
17
+
18
+ ```
19
+ if page.has_css?('.some_class')
20
+ # no timeout occured in this case
21
+ else
22
+ # "has_css?(...)" will be executing for 'Capybara.default_wait_time' seconds in this case
23
+ end
24
+ ```
25
+
26
+ Wrong usage of Capybara makes your tests slow!
27
+
28
+ capybara-timeout_reporter gem helps you to detect all places where your finders are reaching a timeout and report them.
29
+
30
+
31
+ # Installation
32
+
33
+ ```
34
+ gem install capybara-timeout_reporter
35
+ ```
36
+ or if you're using bundler, add this line to Gemfile:
37
+
38
+ ```
39
+ gem 'capybara-timeout_reporter
40
+ ```
41
+
42
+ # Usage
43
+
44
+ Just load it after capybara gem:
45
+
46
+ ```
47
+ require 'capybara'
48
+ # load timeout_reporter after capybara
49
+ require 'capybara/timeout_reporter'
50
+ ```
51
+
52
+ ## Basic usage
53
+
54
+ Default beviour, in case of Capybara sync timeout the following warning will be printed into STDOUT:
55
+
56
+ ```
57
+ [WARNING] Capybara find timed out after <number_of_seconds> seconds in </path/to/file.rb>:<line_number>
58
+ ```
59
+
60
+ ## Advanced usage
61
+
62
+ ```
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|
65
+ # do whatever you want, for example:
66
+ # - raise an exception, if you want to make this strict
67
+ # - add an entry to test report, if you have one
68
+ # - write to a log file
69
+ # - collect all timeouts and then report a total time wasted
70
+ end
71
+ ```
72
+
5
73
  ## Contributing
6
74
 
7
- 1. Fork it `https://github.com/vgiroguk/capybara-timeout_reporter/fork`
75
+ 1. Fork it `https://github.com/vgrigoruk/capybara-timeout_reporter/fork`
8
76
  2. Create your feature branch (`git checkout -b new-feature`)
9
77
  3. Commit your changes (`git commit -am 'Added feature'`)
10
78
  4. Push to the branch (`git push origin new-feature`)
@@ -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.2"
5
+ spec.version = "0.0.3"
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}
@@ -8,10 +8,10 @@ module Capybara
8
8
 
9
9
  class << self
10
10
  attr_accessor :on_timeout
11
- end
12
11
 
13
- def self.on_timeout=(proc)
14
- @on_timeout = proc
12
+ def on_timeout=(proc)
13
+ @on_timeout = proc
14
+ end
15
15
  end
16
16
  end
17
17
 
@@ -22,7 +22,7 @@ module Capybara
22
22
  synchronize_without_warning(seconds, options, &block)
23
23
  rescue Capybara::ElementNotFound => e
24
24
  if Time.now-start_time > seconds
25
- trace_line = Thread.current.backtrace.find { |l| !l.include?('gems/capybara')}
25
+ trace_line = Thread.current.backtrace.find { |l| !l.include?('gems/capybara') }
26
26
  src_line = trace_line.match(/(.*):.*/).captures.first
27
27
  Capybara::TimeoutReporter.on_timeout.call(seconds, src_line)
28
28
  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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vitalii Grygoruk