dom_glancy 1.0.1 → 1.1.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 -2
- data/Gemfile +4 -0
- data/README.md +5 -0
- data/app/controllers/dom_glancy_controller.rb +9 -12
- data/app/views/dom_glancy/about.html.erb +2 -2
- data/app/views/dom_glancy/path_config.html.erb +10 -8
- data/app/views/dom_glancy/show.html.erb +3 -18
- data/app/views/layouts/dom_glancy.html.erb +10 -19
- data/app/views/shared/_dom_glancy_nav.html.erb +1 -1
- data/app/views/shared/_dom_set.html.erb +17 -2
- data/lib/assets/javascripts/dom_glancy/dom_glancy.js +37 -0
- data/{app/assets/stylesheets → lib/assets/stylesheets/dom_glancy}/1236_grid.css +0 -0
- data/{app/assets/stylesheets → lib/assets/stylesheets/dom_glancy}/720_grid.css +0 -0
- data/{app/assets/stylesheets → lib/assets/stylesheets/dom_glancy}/986_grid.css +0 -0
- data/{app/assets/stylesheets → lib/assets/stylesheets/dom_glancy}/dom_glancy.css +35 -4
- data/{app/assets/stylesheets → lib/assets/stylesheets/dom_glancy}/normalize.css +0 -0
- data/lib/dom_glancy.rb +6 -2
- data/lib/dom_glancy/analysis_reporter.rb +39 -0
- data/lib/dom_glancy/analyzer.rb +139 -0
- data/lib/dom_glancy/change_anlyzer.rb +22 -0
- data/lib/dom_glancy/dom_glancy.rb +35 -83
- data/lib/dom_glancy/element.rb +63 -12
- data/lib/dom_glancy/file_name_builder.rb +21 -0
- data/lib/dom_glancy/map_file.rb +14 -0
- data/lib/dom_glancy/page_mapper.rb +81 -0
- data/lib/dom_glancy/svg.rb +41 -2
- data/lib/dom_glancy/version.rb +1 -1
- data/test/page_objects/dom_glancy/show_page.rb +6 -0
- data/test/selenium/mapping_test.rb +28 -5
- data/test/selenium/viewer_test.rb +2 -2
- data/test/selenium_test_helper.rb +26 -43
- data/test/test_app/app/assets/stylesheets/local_app.css +9 -1
- data/test/test_app/app/views/local/index.html.erb +11 -1
- data/test/test_helper.rb +7 -5
- data/test/test_helpers/artifacts_helpers.rb +54 -0
- data/test/test_helpers/location_helpers.rb +5 -3
- data/test/test_objects/options_file_1.yaml +2145 -0
- data/test/test_objects/options_file_2.yaml +2177 -0
- data/test/test_objects/test_objects.rb +57 -6
- data/test/unit/analysis_reporter_test.rb +28 -0
- data/test/unit/analyzer_test.rb +146 -0
- data/test/unit/change_analyzer_test.rb +72 -0
- data/test/unit/dom_glancy_test.rb +16 -11
- data/test/unit/element_test.rb +56 -0
- data/test/unit/file_name_builder_test.rb +28 -0
- data/test/unit/map_file_test.rb +47 -0
- data/test/unit/page_mapper_test.rb +27 -0
- data/test/unit/svg_test.rb +17 -0
- metadata +35 -13
- data/app/assets/javascripts/application.js +0 -7
- data/lib/dom_glancy/analysis.rb +0 -146
- data/lib/dom_glancy/locations.rb +0 -16
- data/test/unit/analysis_test.rb +0 -110
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class FileNameBuilderTest < DomGlancyTestCase
|
4
|
+
def setup
|
5
|
+
locations_root = '/path/to/dom_glancy/files/'
|
6
|
+
|
7
|
+
DomGlancy.configure do |config|
|
8
|
+
config.master_file_location = File.join(locations_root, 'masters')
|
9
|
+
config.current_file_location = File.join(locations_root, 'current')
|
10
|
+
config.diff_file_location = File.join(locations_root, 'diff')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_filenames
|
15
|
+
fnb = DomGlancy::FileNameBuilder.new('test_of_the_year')
|
16
|
+
assert_equal '/path/to/dom_glancy/files/masters/test_of_the_year_master.yaml', fnb.master
|
17
|
+
assert_equal '/path/to/dom_glancy/files/current/test_of_the_year.yaml', fnb.current
|
18
|
+
assert_equal '/path/to/dom_glancy/files/diff/test_of_the_year_diff.html', fnb.diff
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_filenames__no_test_root
|
22
|
+
fnb = DomGlancy::FileNameBuilder.new
|
23
|
+
|
24
|
+
assert_equal '/path/to/dom_glancy/files/masters/_master.yaml', fnb.master
|
25
|
+
assert_equal '/path/to/dom_glancy/files/current/.yaml', fnb.current
|
26
|
+
assert_equal '/path/to/dom_glancy/files/diff/_diff.html', fnb.diff
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class MapFileTest < DomGlancyTestCase
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
def setup
|
7
|
+
prep_locations_for_test
|
8
|
+
|
9
|
+
@test_root = 'alberto_moreno'
|
10
|
+
@map_file = DomGlancy::MapFile.new
|
11
|
+
@fnb = DomGlancy::FileNameBuilder.new(@test_root)
|
12
|
+
@filename = @fnb.master
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
delete_test_locations
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_read__no_file
|
20
|
+
results = @map_file.read(@filename)
|
21
|
+
|
22
|
+
refute results[0]
|
23
|
+
assert_match 'Error reading data from file', results[1]
|
24
|
+
assert_match @filename, results[1]
|
25
|
+
assert_nil results[2]
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_read
|
29
|
+
raw_data = array_of_elements_small
|
30
|
+
File.open(@filename, 'w') { |file| file.write(raw_data.to_json) }
|
31
|
+
|
32
|
+
results = @map_file.read(@filename)
|
33
|
+
|
34
|
+
assert results[0]
|
35
|
+
assert_equal '', results[1]
|
36
|
+
assert_equal 2, results[2].count
|
37
|
+
|
38
|
+
assert_equal '12', results[2][0]['id']
|
39
|
+
assert_equal 238, results[2][0]['height']
|
40
|
+
assert_equal true, results[2][0]['visible']
|
41
|
+
assert_equal 'DIV', results[2][0]['tag']
|
42
|
+
assert_equal 720, results[2][0]['width']
|
43
|
+
assert_equal 'grid', results[2][0]['class']
|
44
|
+
assert_equal 43, results[2][0]['left']
|
45
|
+
assert_equal 14, results[2][0]['top']
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class PageMapperTest < DomGlancyTestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
prep_locations_for_test
|
7
|
+
end
|
8
|
+
|
9
|
+
def teardown
|
10
|
+
delete_test_locations
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_file_mapper_run
|
14
|
+
test_name = 'gram_parsons'
|
15
|
+
|
16
|
+
file_mapper = DomGlancy::PageMapper.new
|
17
|
+
file_mapper.stubs(:map_page).returns(mapping_json)
|
18
|
+
result = file_mapper.run(test_name)
|
19
|
+
|
20
|
+
assert result[0], 'Mapping result should be true to indicate successful mapping'
|
21
|
+
assert_equal '', result[1], 'empty string error message from a successful mapping'
|
22
|
+
|
23
|
+
files_in_current_dir = Dir[File.join(DomGlancy.configuration.current_file_location, '*')]
|
24
|
+
assert_equal 1, files_in_current_dir.count
|
25
|
+
assert_equal files_in_current_dir.first, File.join(DomGlancy.configuration.current_file_location, "#{test_name}.yaml")
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class SVGTest < DomGlancyTestCase
|
4
|
+
def test_same_elements
|
5
|
+
set_current_not_master = array_of_elements[0..3].to_set
|
6
|
+
set_master_not_current = array_of_elements[8..9].to_set
|
7
|
+
set_changed_master = Set.new
|
8
|
+
|
9
|
+
assert_equal 4, set_current_not_master.length
|
10
|
+
assert_equal 2, set_master_not_current.length
|
11
|
+
|
12
|
+
svg = DomGlancy::SVG.new(set_current_not_master, set_master_not_current, set_changed_master)
|
13
|
+
rectangles = svg.send(:make_rectangles)
|
14
|
+
|
15
|
+
assert_equal 6, rectangles.length
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dom_glancy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- geordie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -87,12 +87,6 @@ files:
|
|
87
87
|
- LICENSE.txt
|
88
88
|
- README.md
|
89
89
|
- Rakefile
|
90
|
-
- app/assets/javascripts/application.js
|
91
|
-
- app/assets/stylesheets/1236_grid.css
|
92
|
-
- app/assets/stylesheets/720_grid.css
|
93
|
-
- app/assets/stylesheets/986_grid.css
|
94
|
-
- app/assets/stylesheets/dom_glancy.css
|
95
|
-
- app/assets/stylesheets/normalize.css
|
96
90
|
- app/controllers/dom_glancy_application_controller.rb
|
97
91
|
- app/controllers/dom_glancy_controller.rb
|
98
92
|
- app/views/dom_glancy/about.html.erb
|
@@ -106,13 +100,23 @@ files:
|
|
106
100
|
- app/views/shared/_dom_set.html.erb
|
107
101
|
- config/routes.rb
|
108
102
|
- dom_glancy.gemspec
|
103
|
+
- lib/assets/javascripts/dom_glancy/dom_glancy.js
|
104
|
+
- lib/assets/stylesheets/dom_glancy/1236_grid.css
|
105
|
+
- lib/assets/stylesheets/dom_glancy/720_grid.css
|
106
|
+
- lib/assets/stylesheets/dom_glancy/986_grid.css
|
107
|
+
- lib/assets/stylesheets/dom_glancy/dom_glancy.css
|
108
|
+
- lib/assets/stylesheets/dom_glancy/normalize.css
|
109
109
|
- lib/dom_glancy.rb
|
110
|
-
- lib/dom_glancy/
|
110
|
+
- lib/dom_glancy/analysis_reporter.rb
|
111
|
+
- lib/dom_glancy/analyzer.rb
|
112
|
+
- lib/dom_glancy/change_anlyzer.rb
|
111
113
|
- lib/dom_glancy/configuration.rb
|
112
114
|
- lib/dom_glancy/dom_glancy.rb
|
113
115
|
- lib/dom_glancy/element.rb
|
114
116
|
- lib/dom_glancy/engine.rb
|
115
|
-
- lib/dom_glancy/
|
117
|
+
- lib/dom_glancy/file_name_builder.rb
|
118
|
+
- lib/dom_glancy/map_file.rb
|
119
|
+
- lib/dom_glancy/page_mapper.rb
|
116
120
|
- lib/dom_glancy/svg.rb
|
117
121
|
- lib/dom_glancy/version.rb
|
118
122
|
- test/page_objects.rb
|
@@ -143,12 +147,21 @@ files:
|
|
143
147
|
- test/test_app/config/routes.rb
|
144
148
|
- test/test_app/script/rails
|
145
149
|
- test/test_helper.rb
|
150
|
+
- test/test_helpers/artifacts_helpers.rb
|
146
151
|
- test/test_helpers/location_helpers.rb
|
152
|
+
- test/test_objects/options_file_1.yaml
|
153
|
+
- test/test_objects/options_file_2.yaml
|
147
154
|
- test/test_objects/test_objects.rb
|
148
|
-
- test/unit/
|
155
|
+
- test/unit/analysis_reporter_test.rb
|
156
|
+
- test/unit/analyzer_test.rb
|
157
|
+
- test/unit/change_analyzer_test.rb
|
149
158
|
- test/unit/dom_glancy_test.rb
|
150
159
|
- test/unit/element_test.rb
|
160
|
+
- test/unit/file_name_builder_test.rb
|
151
161
|
- test/unit/location_test.rb
|
162
|
+
- test/unit/map_file_test.rb
|
163
|
+
- test/unit/page_mapper_test.rb
|
164
|
+
- test/unit/svg_test.rb
|
152
165
|
- watchr_script.rb
|
153
166
|
homepage: https://github.com/QuantumGeordie/dom_glancy
|
154
167
|
licenses:
|
@@ -170,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
183
|
version: '0'
|
171
184
|
requirements: []
|
172
185
|
rubyforge_project:
|
173
|
-
rubygems_version: 2.
|
186
|
+
rubygems_version: 2.4.3
|
174
187
|
signing_key:
|
175
188
|
specification_version: 4
|
176
189
|
summary: Map the page DOM and get some stats on it compared to a known default map.
|
@@ -203,9 +216,18 @@ test_files:
|
|
203
216
|
- test/test_app/config/routes.rb
|
204
217
|
- test/test_app/script/rails
|
205
218
|
- test/test_helper.rb
|
219
|
+
- test/test_helpers/artifacts_helpers.rb
|
206
220
|
- test/test_helpers/location_helpers.rb
|
221
|
+
- test/test_objects/options_file_1.yaml
|
222
|
+
- test/test_objects/options_file_2.yaml
|
207
223
|
- test/test_objects/test_objects.rb
|
208
|
-
- test/unit/
|
224
|
+
- test/unit/analysis_reporter_test.rb
|
225
|
+
- test/unit/analyzer_test.rb
|
226
|
+
- test/unit/change_analyzer_test.rb
|
209
227
|
- test/unit/dom_glancy_test.rb
|
210
228
|
- test/unit/element_test.rb
|
229
|
+
- test/unit/file_name_builder_test.rb
|
211
230
|
- test/unit/location_test.rb
|
231
|
+
- test/unit/map_file_test.rb
|
232
|
+
- test/unit/page_mapper_test.rb
|
233
|
+
- test/unit/svg_test.rb
|
data/lib/dom_glancy/analysis.rb
DELETED
@@ -1,146 +0,0 @@
|
|
1
|
-
module DomGlancy
|
2
|
-
class DomGlancy
|
3
|
-
def analyze(master_data, current_data, test_root = nil)
|
4
|
-
output_hash = {}
|
5
|
-
|
6
|
-
master_set = master_data.to_set
|
7
|
-
current_set = current_data.to_set
|
8
|
-
|
9
|
-
set_current_not_master = current_set - master_set
|
10
|
-
set_master_not_current = master_set - current_set
|
11
|
-
set_changed_master = Set.new
|
12
|
-
|
13
|
-
changed_element_pairs = []
|
14
|
-
if set_master_not_current.count > 0 || set_current_not_master.count > 0
|
15
|
-
|
16
|
-
ok_pairs = pairs_that_are_close_enough(set_current_not_master, set_master_not_current)
|
17
|
-
|
18
|
-
ok_pairs.each do |item1, item2|
|
19
|
-
set_current_not_master.delete(item1)
|
20
|
-
set_master_not_current.delete(item2)
|
21
|
-
end
|
22
|
-
|
23
|
-
changed_element_pairs = get_set_of_same_but_different(set_current_not_master, set_master_not_current)
|
24
|
-
|
25
|
-
changed_element_pairs.each do |item1, item2|
|
26
|
-
set_current_not_master.delete(item1)
|
27
|
-
set_current_not_master.delete(item2)
|
28
|
-
|
29
|
-
set_master_not_current.delete(item1)
|
30
|
-
set_master_not_current.delete(item2)
|
31
|
-
end
|
32
|
-
|
33
|
-
changed_element_pairs.select!{ |pair| !DOMElement.new(add_similarity(pair[0])).close_enough?(DOMElement.new(add_similarity(pair[1]))) }
|
34
|
-
changed_element_pairs.each do |pair|
|
35
|
-
set_changed_master.add(pair.first)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
all_same = set_current_not_master.count == 0 && set_master_not_current.count == 0 && changed_element_pairs.count == 0
|
40
|
-
|
41
|
-
create_diff_file(set_current_not_master, set_master_not_current, set_changed_master, test_root) if test_root && !all_same
|
42
|
-
|
43
|
-
output_hash[:not_in_master] = set_current_not_master
|
44
|
-
output_hash[:not_in_current] = set_master_not_current
|
45
|
-
output_hash[:changed_element_pairs] = changed_element_pairs
|
46
|
-
output_hash[:same] = all_same
|
47
|
-
output_hash[:test_root] = test_root
|
48
|
-
output_hash
|
49
|
-
end
|
50
|
-
|
51
|
-
def make_svg(set_master_not_current, set_current_not_master, set_changed_master)
|
52
|
-
js_id = 0
|
53
|
-
set_master_not_current.each do |item|
|
54
|
-
item[:js_id] = js_id
|
55
|
-
js_id += 1
|
56
|
-
end
|
57
|
-
set_current_not_master.each do |item|
|
58
|
-
item[:js_id] = js_id
|
59
|
-
js_id += 1
|
60
|
-
end
|
61
|
-
set_changed_master.each do |item|
|
62
|
-
item[:js_id] = js_id
|
63
|
-
js_id += 1
|
64
|
-
end
|
65
|
-
|
66
|
-
rectangles = set_current_not_master.map { |item| item.merge(format__not_in_master) }
|
67
|
-
rectangles << set_master_not_current.map { |item| item.merge(format__not_in_current) }
|
68
|
-
rectangles << set_changed_master.map { |item| item.merge(format__same_but_different) }
|
69
|
-
rectangles.flatten!
|
70
|
-
|
71
|
-
generate_svg(rectangles)
|
72
|
-
end
|
73
|
-
|
74
|
-
def create_diff_file(set_current_not_master, set_master_not_current, set_changed_master, test_root)
|
75
|
-
filename = DomGlancy.diff_filename(test_root)
|
76
|
-
svg = make_svg(set_current_not_master, set_master_not_current, set_changed_master)
|
77
|
-
File.open(filename, 'w') { |file| file.write(svg) }
|
78
|
-
save_set_info(test_root, 'current_not_master', set_current_not_master)
|
79
|
-
save_set_info(test_root, 'master_not_current', set_master_not_current)
|
80
|
-
save_set_info(test_root, 'changed_master', set_changed_master)
|
81
|
-
end
|
82
|
-
|
83
|
-
def save_set_info(test_root, suffix, data_set)
|
84
|
-
filename = File.join(::DomGlancy.configuration.diff_file_location, "#{test_root}__#{suffix}__diff.yaml")
|
85
|
-
|
86
|
-
data_array = data_set.to_a
|
87
|
-
|
88
|
-
File.open(filename, 'w') { |file| file.write(data_array.to_yaml) }
|
89
|
-
end
|
90
|
-
|
91
|
-
def get_set_of_same_but_different(set1, set2)
|
92
|
-
same_but_different_pairs = []
|
93
|
-
set1.each do |item1|
|
94
|
-
element1 = DOMElement.new(item1)
|
95
|
-
set2.each do |item2|
|
96
|
-
element2 = DOMElement.new(item2)
|
97
|
-
if element1.same_element?(element2)
|
98
|
-
same_but_different_pairs << [item1, item2]
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
same_but_different_pairs
|
103
|
-
end
|
104
|
-
|
105
|
-
def pairs_that_are_close_enough(set1, set2)
|
106
|
-
ok_pairs = []
|
107
|
-
set1.each do |item1|
|
108
|
-
element1 = DOMElement.new(add_similarity(item1))
|
109
|
-
set2.each do |item2|
|
110
|
-
element2 = DOMElement.new(add_similarity(item2))
|
111
|
-
if element1.same_element?(element2) && element1.close_enough?(element2)
|
112
|
-
ok_pairs << [item1, item2]
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
ok_pairs
|
117
|
-
end
|
118
|
-
|
119
|
-
def make_analysis_failure_report(analysis_data)
|
120
|
-
return '' if analysis_data[:same]
|
121
|
-
|
122
|
-
msg = ["\n------- DOM Comparison Failure ------"]
|
123
|
-
msg << "Elements not in master: #{analysis_data[:not_in_master].count}"
|
124
|
-
msg << "Elements not in current: #{analysis_data[:not_in_current].count}"
|
125
|
-
msg << "Changed elements: #{analysis_data[:changed_element_pairs].count}"
|
126
|
-
msg << "Files:"
|
127
|
-
msg << "\tcurrent: #{DomGlancy.current_filename(analysis_data[:test_root])}"
|
128
|
-
msg << "\tmaster: #{DomGlancy.master_filename(analysis_data[:test_root])}"
|
129
|
-
msg << "\tdifference: #{DomGlancy.diff_filename(analysis_data[:test_root])}"
|
130
|
-
msg << "Bless this current data set:"
|
131
|
-
msg << "\t#{blessing_copy_string(analysis_data[:test_root])}"
|
132
|
-
msg<< "-------------------------------------"
|
133
|
-
|
134
|
-
msg.join("\n")
|
135
|
-
end
|
136
|
-
|
137
|
-
def add_similarity(element)
|
138
|
-
element.merge(:similarity => ::DomGlancy.configuration.similarity)
|
139
|
-
end
|
140
|
-
|
141
|
-
|
142
|
-
def blessing_copy_string(test_root)
|
143
|
-
"cp #{DomGlancy.current_filename(test_root)} #{DomGlancy.master_filename(test_root)}"
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
data/lib/dom_glancy/locations.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
module DomGlancy
|
2
|
-
class DomGlancy
|
3
|
-
|
4
|
-
def self.master_filename(test_root)
|
5
|
-
File.join(::DomGlancy.configuration.master_file_location, "#{test_root}_master.yaml")
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.current_filename(test_root)
|
9
|
-
File.join(::DomGlancy.configuration.current_file_location, "#{test_root}.yaml")
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.diff_filename(test_root)
|
13
|
-
File.join(::DomGlancy.configuration.diff_file_location, "#{test_root}_diff.html")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
data/test/unit/analysis_test.rb
DELETED
@@ -1,110 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class AnalysisTest < DomGlancyTestCase
|
4
|
-
|
5
|
-
def test_same_elements
|
6
|
-
master_data = array_of_elements
|
7
|
-
current_data = array_of_elements
|
8
|
-
|
9
|
-
analysis = @dom_glancy.analyze(master_data, current_data)
|
10
|
-
|
11
|
-
assert_equal 0, analysis[:not_in_master].count, 'results of data analysis: not_in_master'
|
12
|
-
assert_equal 0, analysis[:not_in_current].count, 'results of data analysis: not_in_current'
|
13
|
-
assert analysis[:same], 'results of data analysis.same'
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_one_id_different
|
17
|
-
master_data = array_of_elements_small
|
18
|
-
current_data = array_of_elements_small
|
19
|
-
current_data.first['id'] = 'some-new-id'
|
20
|
-
|
21
|
-
analysis = @dom_glancy.analyze(master_data, current_data)
|
22
|
-
|
23
|
-
assert_equal 1, analysis[:not_in_master].count, 'results of data analysis: not_in_master'
|
24
|
-
assert_equal 1, analysis[:not_in_current].count, 'results of data analysis: not_in_current'
|
25
|
-
refute analysis[:same], 'results of data analysis.same'
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_one_new_element
|
29
|
-
master_data = array_of_elements
|
30
|
-
current_data = array_of_elements
|
31
|
-
current_data << single_element_hash
|
32
|
-
|
33
|
-
analysis = @dom_glancy.analyze(master_data, current_data)
|
34
|
-
|
35
|
-
assert_equal 1, analysis[:not_in_master].count, 'results of data analysis: not_in_master'
|
36
|
-
assert_equal 0, analysis[:not_in_current].count, 'results of data analysis: not_in_current'
|
37
|
-
refute analysis[:same], 'results of data analysis.same'
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_two_changed
|
41
|
-
master_data = array_of_elements
|
42
|
-
current_data = array_of_elements
|
43
|
-
current_data[0]['height'] = current_data[0]['height'] + 16
|
44
|
-
current_data[1]['width'] = current_data[1]['width'] + 25
|
45
|
-
|
46
|
-
analysis = @dom_glancy.analyze(master_data, current_data)
|
47
|
-
|
48
|
-
assert_equal 0, analysis[:not_in_master].count, 'results of data analysis: not_in_master'
|
49
|
-
assert_equal 0, analysis[:not_in_current].count, 'results of data analysis: not_in_current'
|
50
|
-
assert_equal 2, analysis[:changed_element_pairs].count, 'changed element pairs'
|
51
|
-
refute analysis[:same], 'results of data analysis.same'
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_one_changed_less_than_similarity_factor
|
56
|
-
master_data = array_of_elements
|
57
|
-
current_data = array_of_elements
|
58
|
-
|
59
|
-
current_data[1]['height'] = current_data[1]['height'] + 3
|
60
|
-
|
61
|
-
analysis = @dom_glancy.analyze(master_data, current_data)
|
62
|
-
|
63
|
-
assert_equal 0, analysis[:not_in_master].count, 'results of data analysis: not_in_master'
|
64
|
-
assert_equal 0, analysis[:not_in_current].count, 'results of data analysis: not_in_current'
|
65
|
-
assert_equal 0, analysis[:changed_element_pairs].count, 'changed element pairs'
|
66
|
-
assert analysis[:same], 'results of data analysis.same'
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_one_changed_one_missing_one_added
|
70
|
-
master_data = array_of_elements
|
71
|
-
current_data = array_of_elements
|
72
|
-
|
73
|
-
current_data[0]['height'] = current_data[0]['height'] + 23 ## the one changed (by more than similarity factor)
|
74
|
-
current_data[1]['height'] = current_data[1]['height'] + 3 ## the one changed (by less than similarity factor and therefor not counted)
|
75
|
-
current_data.delete_at(5) ## the one missing
|
76
|
-
current_data << single_element_hash ## the one added
|
77
|
-
|
78
|
-
analysis = @dom_glancy.analyze(master_data, current_data)
|
79
|
-
|
80
|
-
assert_equal 1, analysis[:not_in_master].count, 'results of data analysis: not_in_master'
|
81
|
-
assert_equal 1, analysis[:not_in_current].count, 'results of data analysis: not_in_current'
|
82
|
-
assert_equal 1, analysis[:changed_element_pairs].count, 'changed element pairs'
|
83
|
-
refute analysis[:same], 'results of data analysis.same'
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_huge_list_of_similarly_named_elements
|
87
|
-
master_data = travis_local_generated_master
|
88
|
-
current_data = travis_generated_current
|
89
|
-
|
90
|
-
analysis = @dom_glancy.analyze(master_data, current_data)
|
91
|
-
assert_equal 0, analysis[:not_in_master].count, 'results of data analysis: not_in_master'
|
92
|
-
assert_equal 0, analysis[:not_in_current].count, 'results of data analysis: not_in_current'
|
93
|
-
assert_equal 0, analysis[:changed_element_pairs].count, 'changed element pairs'
|
94
|
-
assert analysis[:same], 'results of data analysis.same'
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_huge_another_list_of_similarly_named_elements
|
98
|
-
master_data = travis_local_generated_master_2
|
99
|
-
current_data = travis_generated_current_2
|
100
|
-
|
101
|
-
analysis = @dom_glancy.analyze(master_data, current_data)
|
102
|
-
|
103
|
-
## real difference that was found on travis with the INPUT tags being different styles/sizes if not css-styled
|
104
|
-
assert_equal 0, analysis[:not_in_master].count, 'results of data analysis: not_in_master'
|
105
|
-
assert_equal 0, analysis[:not_in_current].count, 'results of data analysis: not_in_current'
|
106
|
-
assert_equal 1, analysis[:changed_element_pairs].count, 'changed element pairs'
|
107
|
-
refute analysis[:same], 'results of data analysis.same'
|
108
|
-
end
|
109
|
-
|
110
|
-
end
|