dom_glancy 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +1 -3
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -2
- data/README.md +69 -2
- data/app/assets/javascripts/application.js +7 -1
- data/app/assets/stylesheets/dom_glancy.css +19 -3
- data/app/controllers/dom_glancy_controller.rb +15 -15
- data/app/views/dom_glancy/index.html.erb +15 -10
- data/app/views/dom_glancy/path_config.html.erb +3 -3
- data/app/views/dom_glancy/show.html.erb +4 -4
- data/app/views/layouts/dom_glancy.html.erb +7 -7
- data/dom_glancy.gemspec +2 -2
- data/lib/dom_glancy/analysis.rb +108 -108
- data/lib/dom_glancy/configuration.rb +22 -0
- data/lib/dom_glancy/dom_glancy.rb +110 -96
- data/lib/dom_glancy/engine.rb +4 -0
- data/lib/dom_glancy/locations.rb +10 -43
- data/lib/dom_glancy/svg.rb +45 -43
- data/lib/dom_glancy/version.rb +1 -1
- data/lib/dom_glancy.rb +5 -1
- data/test/selenium/mapping_test.rb +14 -14
- data/test/selenium/viewer_test.rb +4 -9
- data/test/selenium_test_helper.rb +86 -85
- data/test/test_app/Gemfile +0 -2
- data/test/test_app/Rakefile +3 -0
- data/test/test_app/app/views/layouts/local.html.erb +2 -3
- data/test/test_app/config/application.rb +29 -0
- data/test/test_app/config/boot.rb +6 -0
- data/test/test_app/config/environment.rb +2 -0
- data/test/test_app/config/initializers/dom_glancy_initializer.rb +8 -4
- data/test/test_app/config.ru +2 -29
- data/test/test_app/script/rails +6 -0
- data/test/test_helper.rb +5 -7
- data/test/test_helpers/location_helpers.rb +23 -21
- data/test/test_objects/test_objects.rb +40 -42
- data/test/unit/analysis_test.rb +9 -10
- data/test/unit/{kracker_test.rb → dom_glancy_test.rb} +20 -21
- data/test/unit/element_test.rb +8 -8
- data/test/unit/location_test.rb +8 -7
- metadata +25 -13
- data/lib/dom_glancy/rails/engine.rb +0 -7
- data/test/test_app/config/database.yml +0 -13
- data/test/test_app/test_app.rb +0 -30
- data/test/test_helpers/kracker_class_for_stubbing.rb +0 -3
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class DomGlancyTest <
|
3
|
+
class DomGlancyTest < DomGlancyTestCase
|
4
|
+
|
4
5
|
def setup
|
6
|
+
super
|
5
7
|
@test_root = 'elbow'
|
6
8
|
prep_locations_for_test
|
7
9
|
make_master_test_file(@test_root, array_of_elements_small)
|
8
|
-
@DomGlancy_object = DomGlancyClassForStubbing.new
|
9
10
|
end
|
10
11
|
|
11
12
|
def teardown
|
@@ -14,37 +15,35 @@ class DomGlancyTest < DomGlancy::DomGlancyTestCase
|
|
14
15
|
|
15
16
|
def test_dom_glancy__missing_master
|
16
17
|
this_test_root = 'not_elbow'
|
17
|
-
blessing_copy_string = "cp #{DomGlancy.current_filename(this_test_root)} #{DomGlancy.master_filename(this_test_root)}"
|
18
|
+
blessing_copy_string = "cp #{DomGlancy::DomGlancy.current_filename(this_test_root)} #{DomGlancy::DomGlancy.master_filename(this_test_root)}"
|
18
19
|
|
19
|
-
@
|
20
|
-
mapping_results = @
|
20
|
+
@dom_glancy.stubs(:perform_mapping_operation).returns(array_of_elements_small)
|
21
|
+
mapping_results = @dom_glancy.page_map_same?(this_test_root)
|
21
22
|
|
22
23
|
refute mapping_results[0], 'test should fail because no master'
|
23
24
|
assert_match 'Master file does not exist', mapping_results[1], 'failure message when no master'
|
24
25
|
assert_match blessing_copy_string, mapping_results[1], 'blessing copy string should be in the error message'
|
25
26
|
|
26
27
|
`#{blessing_copy_string}`
|
27
|
-
@
|
28
|
+
@dom_glancy.stubs(:perform_mapping_operation).returns(array_of_elements_small)
|
28
29
|
|
29
|
-
mapping_results = @
|
30
|
+
mapping_results = @dom_glancy.page_map_same?(this_test_root)
|
30
31
|
assert mapping_results[0], 'test should now pass with copied master'
|
31
|
-
|
32
32
|
end
|
33
33
|
|
34
34
|
def test_dom_glancy__pass
|
35
|
-
@
|
36
|
-
mapping_results = @
|
35
|
+
@dom_glancy.stubs(:perform_mapping_operation).returns(array_of_elements_small)
|
36
|
+
mapping_results = @dom_glancy.page_map_same?(@test_root)
|
37
37
|
|
38
38
|
assert mapping_results[0], mapping_results[1]
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_dom_glancy__fail_one_new_element
|
42
|
-
blessing_copy_string = "cp #{DomGlancy.current_filename(@test_root)} #{DomGlancy.master_filename(@test_root)}"
|
43
|
-
|
42
|
+
blessing_copy_string = "cp #{DomGlancy::DomGlancy.current_filename(@test_root)} #{DomGlancy::DomGlancy.master_filename(@test_root)}"
|
44
43
|
|
45
44
|
current_data = array_of_elements_small << single_element_hash
|
46
|
-
@
|
47
|
-
mapping_results = @
|
45
|
+
@dom_glancy.stubs(:perform_mapping_operation).returns(current_data)
|
46
|
+
mapping_results = @dom_glancy.page_map_same?(@test_root)
|
48
47
|
|
49
48
|
refute mapping_results[0], 'page same results should be false'
|
50
49
|
|
@@ -52,26 +51,26 @@ class DomGlancyTest < DomGlancy::DomGlancyTestCase
|
|
52
51
|
assert_match 'Elements not in current: 0', mapping_results[1], 'error message contents'
|
53
52
|
assert_match 'Changed elements: 0', mapping_results[1], 'error message contents'
|
54
53
|
|
55
|
-
assert_match "current: #{DomGlancy.current_filename(@test_root)}", mapping_results[1], 'error message contents'
|
56
|
-
assert_match "master: #{DomGlancy.master_filename(@test_root)}", mapping_results[1], 'error message contents'
|
57
|
-
assert_match "difference: #{DomGlancy.diff_filename(@test_root)}", mapping_results[1], 'error message contents'
|
54
|
+
assert_match "current: #{DomGlancy::DomGlancy.current_filename(@test_root)}", mapping_results[1], 'error message contents'
|
55
|
+
assert_match "master: #{DomGlancy::DomGlancy.master_filename(@test_root)}", mapping_results[1], 'error message contents'
|
56
|
+
assert_match "difference: #{DomGlancy::DomGlancy.diff_filename(@test_root)}", mapping_results[1], 'error message contents'
|
58
57
|
|
59
58
|
assert_match blessing_copy_string, mapping_results[1], 'blessing copy string should be in the error message'
|
60
59
|
|
61
|
-
files_in_diff_location = Dir[File.join(DomGlancy.diff_file_location, '*')]
|
60
|
+
files_in_diff_location = Dir[File.join(DomGlancy.configuration.diff_file_location, '*')]
|
62
61
|
assert_equal 4, files_in_diff_location.count, 'the number of files in the diff location after a failure.'
|
63
62
|
|
64
63
|
`#{blessing_copy_string}`
|
65
64
|
|
66
|
-
@
|
67
|
-
mapping_results = @
|
65
|
+
@dom_glancy.stubs(:perform_mapping_operation).returns(current_data)
|
66
|
+
mapping_results = @dom_glancy.page_map_same?(@test_root)
|
68
67
|
|
69
68
|
assert mapping_results[0], 'should pass now that the blessing copy string has been run'
|
70
69
|
|
71
70
|
end
|
72
71
|
|
73
72
|
def make_master_test_file(test_root, data)
|
74
|
-
filename = DomGlancy.master_filename(test_root)
|
73
|
+
filename = DomGlancy::DomGlancy.master_filename(test_root)
|
75
74
|
yaml_data = data.to_yaml
|
76
75
|
File.open(filename, 'w') { |file| file.write(yaml_data) }
|
77
76
|
end
|
data/test/unit/element_test.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class ElementTest <
|
3
|
+
class ElementTest < DomGlancyTestCase
|
4
4
|
|
5
5
|
def test_sameness
|
6
|
-
element1 = DOMElement.new(single_element_hash)
|
7
|
-
element2 = DOMElement.new(single_element_hash.merge({"left" => 72}))
|
6
|
+
element1 = DomGlancy::DOMElement.new(single_element_hash)
|
7
|
+
element2 = DomGlancy::DOMElement.new(single_element_hash.merge({"left" => 72}))
|
8
8
|
|
9
9
|
assert element1.same_element?(element2), 'should be the same element'
|
10
10
|
refute element1.all_same?(element2), 'should not be all same'
|
@@ -19,9 +19,9 @@ class ElementTest < DomGlancy::DomGlancyTestCase
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_similarity
|
22
|
-
element1 = DOMElement.new(single_element_hash.merge({"similarity" => 2}))
|
23
|
-
element2 = DOMElement.new(single_element_hash.merge({"left" => 72}))
|
24
|
-
element3 = DOMElement.new(single_element_hash.merge({"left" => 74}))
|
22
|
+
element1 = DomGlancy::DOMElement.new(single_element_hash.merge({"similarity" => 2}))
|
23
|
+
element2 = DomGlancy::DOMElement.new(single_element_hash.merge({"left" => 72}))
|
24
|
+
element3 = DomGlancy::DOMElement.new(single_element_hash.merge({"left" => 74}))
|
25
25
|
|
26
26
|
assert element1.same_element?(element2), 'should be the same element'
|
27
27
|
assert element1.same_element?(element3), 'should be the same element'
|
@@ -37,8 +37,8 @@ class ElementTest < DomGlancy::DomGlancyTestCase
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_changed_element__width
|
40
|
-
element1 = DOMElement.new(array_of_elements.last)
|
41
|
-
element2 = DOMElement.new(array_of_elements.last.merge("width" => 20))
|
40
|
+
element1 = DomGlancy::DOMElement.new(array_of_elements.last)
|
41
|
+
element2 = DomGlancy::DOMElement.new(array_of_elements.last.merge("width" => 20))
|
42
42
|
|
43
43
|
assert element1.same_element?(element2), 'should be same element'
|
44
44
|
refute element1.close_enough?(element2), 'elements not close enough'
|
data/test/unit/location_test.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class LocationTest <
|
3
|
+
class LocationTest < DomGlancyTestCase
|
4
4
|
|
5
5
|
def setup
|
6
|
+
super
|
6
7
|
prep_locations_for_test
|
7
8
|
end
|
8
9
|
|
@@ -11,13 +12,13 @@ class LocationTest < DomGlancy::DomGlancyTestCase
|
|
11
12
|
end
|
12
13
|
|
13
14
|
def test_locations
|
14
|
-
assert_equal File.join(@locations_root, 'masters'), DomGlancy.master_file_location , 'master file location value'
|
15
|
-
assert_equal File.join(@locations_root, 'current'), DomGlancy.current_file_location , 'current file location value'
|
16
|
-
assert_equal File.join(@locations_root, 'diff'), DomGlancy.diff_file_location , 'difference file location value'
|
15
|
+
assert_equal File.join(@locations_root, 'masters'), DomGlancy.configuration.master_file_location , 'master file location value'
|
16
|
+
assert_equal File.join(@locations_root, 'current'), DomGlancy.configuration.current_file_location , 'current file location value'
|
17
|
+
assert_equal File.join(@locations_root, 'diff'), DomGlancy.configuration.diff_file_location , 'difference file location value'
|
17
18
|
|
18
|
-
assert Dir.exist?(DomGlancy.master_file_location) , 'master file location created'
|
19
|
-
assert Dir.exist?(DomGlancy.current_file_location) , 'current file location created'
|
20
|
-
assert Dir.exist?(DomGlancy.diff_file_location) , 'difference file location created'
|
19
|
+
assert Dir.exist?(DomGlancy.configuration.master_file_location) , 'master file location created'
|
20
|
+
assert Dir.exist?(DomGlancy.configuration.current_file_location) , 'current file location created'
|
21
|
+
assert Dir.exist?(DomGlancy.configuration.diff_file_location) , 'difference file location created'
|
21
22
|
end
|
22
23
|
|
23
24
|
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:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- geordie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,14 +58,20 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
61
|
+
version: '1.0'
|
62
|
+
- - "<"
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '3'
|
62
65
|
type: :runtime
|
63
66
|
prerelease: false
|
64
67
|
version_requirements: !ruby/object:Gem::Requirement
|
65
68
|
requirements:
|
66
69
|
- - ">="
|
67
70
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
71
|
+
version: '1.0'
|
72
|
+
- - "<"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '3'
|
69
75
|
description: DOM Mapping
|
70
76
|
email:
|
71
77
|
- george.speake@gmail.com
|
@@ -76,6 +82,7 @@ files:
|
|
76
82
|
- ".gitignore"
|
77
83
|
- ".ruby-version"
|
78
84
|
- ".travis.yml"
|
85
|
+
- CHANGELOG.md
|
79
86
|
- Gemfile
|
80
87
|
- LICENSE.txt
|
81
88
|
- README.md
|
@@ -101,10 +108,11 @@ files:
|
|
101
108
|
- dom_glancy.gemspec
|
102
109
|
- lib/dom_glancy.rb
|
103
110
|
- lib/dom_glancy/analysis.rb
|
111
|
+
- lib/dom_glancy/configuration.rb
|
104
112
|
- lib/dom_glancy/dom_glancy.rb
|
105
113
|
- lib/dom_glancy/element.rb
|
114
|
+
- lib/dom_glancy/engine.rb
|
106
115
|
- lib/dom_glancy/locations.rb
|
107
|
-
- lib/dom_glancy/rails/engine.rb
|
108
116
|
- lib/dom_glancy/svg.rb
|
109
117
|
- lib/dom_glancy/version.rb
|
110
118
|
- test/page_objects.rb
|
@@ -121,23 +129,25 @@ files:
|
|
121
129
|
- test/selenium/viewer_test.rb
|
122
130
|
- test/selenium_test_helper.rb
|
123
131
|
- test/test_app/Gemfile
|
132
|
+
- test/test_app/Rakefile
|
124
133
|
- test/test_app/app/assets/stylesheets/local_app.css
|
125
134
|
- test/test_app/app/controllers/application_controller.rb
|
126
135
|
- test/test_app/app/controllers/local_controller.rb
|
127
136
|
- test/test_app/app/views/layouts/local.html.erb
|
128
137
|
- test/test_app/app/views/local/index.html.erb
|
129
138
|
- test/test_app/config.ru
|
130
|
-
- test/test_app/config/
|
139
|
+
- test/test_app/config/application.rb
|
140
|
+
- test/test_app/config/boot.rb
|
141
|
+
- test/test_app/config/environment.rb
|
131
142
|
- test/test_app/config/initializers/dom_glancy_initializer.rb
|
132
143
|
- test/test_app/config/routes.rb
|
133
|
-
- test/test_app/
|
144
|
+
- test/test_app/script/rails
|
134
145
|
- test/test_helper.rb
|
135
|
-
- test/test_helpers/kracker_class_for_stubbing.rb
|
136
146
|
- test/test_helpers/location_helpers.rb
|
137
147
|
- test/test_objects/test_objects.rb
|
138
148
|
- test/unit/analysis_test.rb
|
149
|
+
- test/unit/dom_glancy_test.rb
|
139
150
|
- test/unit/element_test.rb
|
140
|
-
- test/unit/kracker_test.rb
|
141
151
|
- test/unit/location_test.rb
|
142
152
|
- watchr_script.rb
|
143
153
|
homepage: https://github.com/QuantumGeordie/dom_glancy
|
@@ -179,21 +189,23 @@ test_files:
|
|
179
189
|
- test/selenium/viewer_test.rb
|
180
190
|
- test/selenium_test_helper.rb
|
181
191
|
- test/test_app/Gemfile
|
192
|
+
- test/test_app/Rakefile
|
182
193
|
- test/test_app/app/assets/stylesheets/local_app.css
|
183
194
|
- test/test_app/app/controllers/application_controller.rb
|
184
195
|
- test/test_app/app/controllers/local_controller.rb
|
185
196
|
- test/test_app/app/views/layouts/local.html.erb
|
186
197
|
- test/test_app/app/views/local/index.html.erb
|
187
198
|
- test/test_app/config.ru
|
188
|
-
- test/test_app/config/
|
199
|
+
- test/test_app/config/application.rb
|
200
|
+
- test/test_app/config/boot.rb
|
201
|
+
- test/test_app/config/environment.rb
|
189
202
|
- test/test_app/config/initializers/dom_glancy_initializer.rb
|
190
203
|
- test/test_app/config/routes.rb
|
191
|
-
- test/test_app/
|
204
|
+
- test/test_app/script/rails
|
192
205
|
- test/test_helper.rb
|
193
|
-
- test/test_helpers/kracker_class_for_stubbing.rb
|
194
206
|
- test/test_helpers/location_helpers.rb
|
195
207
|
- test/test_objects/test_objects.rb
|
196
208
|
- test/unit/analysis_test.rb
|
209
|
+
- test/unit/dom_glancy_test.rb
|
197
210
|
- test/unit/element_test.rb
|
198
|
-
- test/unit/kracker_test.rb
|
199
211
|
- test/unit/location_test.rb
|
data/test/test_app/test_app.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
db_name = "dom_glancy_#{Rails.env}"
|
2
|
-
|
3
|
-
`mysql -uroot -e "DROP DATABASE IF EXISTS #{db_name}; CREATE DATABASE IF NOT EXISTS #{db_name};"`
|
4
|
-
|
5
|
-
log_file = File.expand_path(File.join(__FILE__, '..', 'log', '*'))
|
6
|
-
`rm -rf #{log_file}`
|
7
|
-
|
8
|
-
module DomGlancyApp
|
9
|
-
class Application < Rails::Application
|
10
|
-
config.root = File.expand_path(File.join(__FILE__, '..', '..', 'test_app'))
|
11
|
-
config.eager_load = true
|
12
|
-
config.cache_classes = true
|
13
|
-
config.active_support.deprecation = :stderr
|
14
|
-
|
15
|
-
# Enable the asset pipeline
|
16
|
-
config.assets.enabled = true
|
17
|
-
|
18
|
-
# Configure static asset server for tests with Cache-Control for performance
|
19
|
-
config.serve_static_assets = true
|
20
|
-
config.static_cache_control = "public, max-age=3600"
|
21
|
-
|
22
|
-
# Configure cookies
|
23
|
-
config.secret_token = (('a'..'z').to_a * 2).join
|
24
|
-
config.session_store :cookie_store
|
25
|
-
|
26
|
-
I18n.enforce_available_locales = false
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
DomGlancyApp::Application.initialize!
|