capybara-differ 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +47 -0
- data/lib/capybara-differ.rb +5 -4
- data/lib/capybara-differ/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da944f1ddac2de0f625a87481381c1bf50e75935
|
4
|
+
data.tar.gz: 3bd50c89ecda57360a1152ea77a9a95cabcac9b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30c4d6052314aab6cf43752b092c72fadb65cf0c065f536e5cf2818074153c569ba6acd29997dac1c20700277618ba8dec6392db5e8421ccbdd412609bec487a
|
7
|
+
data.tar.gz: ae72367a15a00623ccbe5f85142d43bb56efc98dbdf51d5639569a7b67fb52649c31a42fb74340c6637970f9675ac3cf35b0100c2cb922be8098cbb6c1f7cfde
|
data/README.md
CHANGED
@@ -22,6 +22,53 @@ Expected use cases are
|
|
22
22
|
* Tracking sites
|
23
23
|
* visit -> save_page -> check_page
|
24
24
|
|
25
|
+
### An example of tracking site
|
26
|
+
|
27
|
+
When you run the following commands periodically,
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
Capybara.save_path = 'tmp/capybara'
|
31
|
+
session = Capybara::Session.new(:selenium)
|
32
|
+
session.visit 'http://rubyonrails.org/'
|
33
|
+
session.check_page('rails_page')
|
34
|
+
```
|
35
|
+
|
36
|
+
you could get the following output.
|
37
|
+
|
38
|
+
```diff
|
39
|
+
Comparing two files
|
40
|
+
--- tmp/capybara/rails_page/20180407095217.html.beauty 2018-04-11 17:04:28.000000000 +0900
|
41
|
+
+++ tmp/capybara/rails_page/20180411170428.html.beauty 2018-04-11 17:04:28.000000000 +0900
|
42
|
+
@@ -21,5 +21,5 @@
|
43
|
+
<section>
|
44
|
+
<p class="mobile-center">
|
45
|
+
- <img src="/images/rails-logo.svg" width="220" height="78" alt="Ruby on Rails">
|
46
|
+
+ <img src="/images/rails-logo.svg" alt="Ruby on Rails" height="78" width="220">
|
47
|
+
</p>
|
48
|
+
</section>
|
49
|
+
@@ -48,15 +48,15 @@
|
50
|
+
</section>
|
51
|
+
<section class="version">
|
52
|
+
- <p><a href="http://weblog.rubyonrails.org/2018/3/29/Rails-5-0-7-and-5-1-6-have-been-released/">
|
53
|
+
- Latest version — Rails 5.1.6
|
54
|
+
+ <p><a href="http://weblog.rubyonrails.org/2018/4/9/Rails-5-2-0-final/">
|
55
|
+
+ Latest version — Rails 5.2.0
|
56
|
+
<span class="hide-mobile">
|
57
|
+
- released March 29, 2018
|
58
|
+
+ released April 9, 2018
|
59
|
+
</span></a></p>
|
60
|
+
<p class="show-mobile"><small>
|
61
|
+
- Released March 29, 2018
|
62
|
+
+ Released April 9, 2018
|
63
|
+
</small></p>
|
64
|
+
</section>
|
65
|
+
<section class="video-container">
|
66
|
+
- <iframe src="https://www.youtube.com/embed/OaDhY_y8WTo" frameborder="0" allowfullscreen="" class="video"></iframe>
|
67
|
+
+ <iframe src="https://www.youtube.com/embed/OaDhY_y8WTo" allowfullscreen="" class="video" frameborder="0"></iframe>
|
68
|
+
</section>
|
69
|
+
<section class="interior">
|
70
|
+
```
|
71
|
+
|
25
72
|
### Dependencies
|
26
73
|
|
27
74
|
* https://github.com/samg/diffy
|
data/lib/capybara-differ.rb
CHANGED
@@ -37,7 +37,7 @@ module Capybara
|
|
37
37
|
end
|
38
38
|
|
39
39
|
node = doc.css(target_selector || default_selector)
|
40
|
-
raise("Couldn't find the selector [#{target_selector}]") if node.empty?
|
40
|
+
raise("Couldn't find the selector [#{target_selector}] in #{file}") if node.empty?
|
41
41
|
beautified_html = HtmlBeautifier.beautify(node.to_html)
|
42
42
|
|
43
43
|
beautified_html_path = file + '.beauty'
|
@@ -61,10 +61,11 @@ module Capybara
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def check_page(name, options = {})
|
64
|
-
|
64
|
+
path_from_name = name.gsub(/[^a-z0-9\-_]+/i, '_')
|
65
|
+
filename = File.join(path_from_name, Time.now.strftime('%Y%m%d%H%M%S') + '.html')
|
65
66
|
save_page(filename)
|
66
67
|
|
67
|
-
base_dir = File.join([Capybara.save_path,
|
68
|
+
base_dir = File.join([Capybara.save_path, path_from_name].compact)
|
68
69
|
file_list = Dir[File.join(base_dir, '*.html')]
|
69
70
|
old_html_path = options[:compare_with] == :previous ? file_list[-2] : file_list.first
|
70
71
|
new_html_path = file_list.last
|
@@ -73,7 +74,7 @@ module Capybara
|
|
73
74
|
if (result = comparator.compare).strip.size > 0
|
74
75
|
puts result
|
75
76
|
else
|
76
|
-
puts "No difference on '#{
|
77
|
+
puts "No difference on '#{path_from_name}' snapshots"
|
77
78
|
end
|
78
79
|
end
|
79
80
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara-differ
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kazuho Yamaguchi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|