kracker 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/.ruby-version +1 -0
- data/.travis.yml +14 -0
- data/Gemfile +16 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +23 -0
- data/app/assets/javascripts/application.js +1 -0
- data/app/assets/stylesheets/1236_grid.css +21 -0
- data/app/assets/stylesheets/720_grid.css +33 -0
- data/app/assets/stylesheets/986_grid.css +24 -0
- data/app/assets/stylesheets/kracker.css +134 -0
- data/app/assets/stylesheets/normalize.css +425 -0
- data/app/controllers/kracker_application_controller.rb +8 -0
- data/app/controllers/kracker_controller.rb +114 -0
- data/app/views/kracker/about.html.erb +3 -0
- data/app/views/kracker/artifacts.html.erb +16 -0
- data/app/views/kracker/index.html.erb +12 -0
- data/app/views/kracker/new.html.erb +15 -0
- data/app/views/kracker/path_config.html.erb +8 -0
- data/app/views/kracker/show.html.erb +42 -0
- data/app/views/layouts/kracker.html.erb +32 -0
- data/app/views/shared/_dom_set.html.erb +35 -0
- data/app/views/shared/_kracker_nav.html.erb +8 -0
- data/config/routes.rb +17 -0
- data/kracker.gemspec +27 -0
- data/lib/kracker/analysis.rb +114 -0
- data/lib/kracker/element.rb +92 -0
- data/lib/kracker/kracker.rb +112 -0
- data/lib/kracker/locations.rb +49 -0
- data/lib/kracker/rails/engine.rb +7 -0
- data/lib/kracker/svg.rb +71 -0
- data/lib/kracker/version.rb +3 -0
- data/lib/kracker.rb +7 -0
- data/test/page_objects/kracker/about_page.rb +7 -0
- data/test/page_objects/kracker/artifacts_page.rb +7 -0
- data/test/page_objects/kracker/config_page.rb +19 -0
- data/test/page_objects/kracker/index_page.rb +9 -0
- data/test/page_objects/kracker/local_index_page.rb +7 -0
- data/test/page_objects/kracker/new_page.rb +7 -0
- data/test/page_objects/kracker/show_page.rb +15 -0
- data/test/page_objects/kracker/viewer_page.rb +15 -0
- data/test/page_objects/navigation.rb +34 -0
- data/test/page_objects.rb +13 -0
- data/test/selenium/mapping_test.rb +98 -0
- data/test/selenium/viewer_test.rb +25 -0
- data/test/selenium_test_helper.rb +102 -0
- data/test/test_app/Gemfile +10 -0
- data/test/test_app/app/assets/stylesheets/local_app.css +25 -0
- data/test/test_app/app/controllers/application_controller.rb +2 -0
- data/test/test_app/app/controllers/local_controller.rb +8 -0
- data/test/test_app/app/views/layouts/local.html.erb +14 -0
- data/test/test_app/app/views/local/index.html.erb +45 -0
- data/test/test_app/config/database.yml +13 -0
- data/test/test_app/config/initializers/kracker_initializer.rb +5 -0
- data/test/test_app/config/routes.rb +4 -0
- data/test/test_app/config.ru +31 -0
- data/test/test_app/test_app.rb +30 -0
- data/test/test_helper.rb +41 -0
- data/test/test_helpers/kracker_class_for_stubbing.rb +3 -0
- data/test/test_helpers/location_helpers.rb +29 -0
- data/test/test_objects/test_objects.rb +30 -0
- data/test/unit/analysis_test.rb +87 -0
- data/test/unit/element_test.rb +47 -0
- data/test/unit/kracker_test.rb +79 -0
- data/test/unit/location_test.rb +23 -0
- data/watchr_script.rb +3 -0
- metadata +199 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ElementTest < Kracker::KrackerTestCase
|
4
|
+
|
5
|
+
def test_sameness
|
6
|
+
element1 = DOMElement.new(single_element_hash)
|
7
|
+
element2 = DOMElement.new(single_element_hash.merge({"left" => 72}))
|
8
|
+
|
9
|
+
assert element1.same_element?(element2), 'should be the same element'
|
10
|
+
refute element1.all_same?(element2), 'should not be all same'
|
11
|
+
assert element1.close_enough?(element2), 'should be the same element, but with slight differences'
|
12
|
+
|
13
|
+
element1.left = 72
|
14
|
+
assert element1.all_same?(element2), 'should be the same now'
|
15
|
+
|
16
|
+
element2.id = 'stupid_id'
|
17
|
+
refute element1.all_same?(element2)
|
18
|
+
refute element1.same_element?(element2)
|
19
|
+
end
|
20
|
+
|
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}))
|
25
|
+
|
26
|
+
assert element1.same_element?(element2), 'should be the same element'
|
27
|
+
assert element1.same_element?(element3), 'should be the same element'
|
28
|
+
|
29
|
+
refute element1.all_same?(element2), 'should not be exactly the same'
|
30
|
+
refute element1.all_same?(element3), 'should not be exactly the same'
|
31
|
+
|
32
|
+
assert element1.close_enough?(element2), 'should be close enough'
|
33
|
+
refute element1.close_enough?(element3), 'should not be close enough'
|
34
|
+
|
35
|
+
element1.similarity = 4
|
36
|
+
assert element1.close_enough?(element3), 'should not be close enough'
|
37
|
+
end
|
38
|
+
|
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))
|
42
|
+
|
43
|
+
assert element1.same_element?(element2), 'should be same element'
|
44
|
+
refute element1.close_enough?(element2), 'elements not close enough'
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class KrackerTest < Kracker::KrackerTestCase
|
4
|
+
def setup
|
5
|
+
@test_root = 'elbow'
|
6
|
+
prep_locations_for_test
|
7
|
+
make_master_test_file(@test_root, array_of_elements_small)
|
8
|
+
@kracker_object = KrackerClassForStubbing.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
delete_test_locations
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_kracker__missing_master
|
16
|
+
this_test_root = 'not_elbow'
|
17
|
+
blessing_copy_string = "cp #{Kracker.current_filename(this_test_root)} #{Kracker.master_filename(this_test_root)}"
|
18
|
+
|
19
|
+
@kracker_object.stubs(:perform_mapping_operation).returns(array_of_elements_small)
|
20
|
+
mapping_results = @kracker_object.page_map_same?(this_test_root)
|
21
|
+
|
22
|
+
refute mapping_results[0], 'test should fail because no master'
|
23
|
+
assert_match 'Master file does not exist', mapping_results[1], 'failure message when no master'
|
24
|
+
assert_match blessing_copy_string, mapping_results[1], 'blessing copy string should be in the error message'
|
25
|
+
|
26
|
+
`#{blessing_copy_string}`
|
27
|
+
@kracker_object.stubs(:perform_mapping_operation).returns(array_of_elements_small)
|
28
|
+
|
29
|
+
mapping_results = @kracker_object.page_map_same?(this_test_root)
|
30
|
+
assert mapping_results[0], 'test should now pass with copied master'
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_kracker__pass
|
35
|
+
@kracker_object.stubs(:perform_mapping_operation).returns(array_of_elements_small)
|
36
|
+
mapping_results = @kracker_object.page_map_same?(@test_root)
|
37
|
+
|
38
|
+
assert mapping_results[0], mapping_results[1]
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_kracker__fail_one_new_element
|
42
|
+
blessing_copy_string = "cp #{Kracker.current_filename(@test_root)} #{Kracker.master_filename(@test_root)}"
|
43
|
+
|
44
|
+
|
45
|
+
current_data = array_of_elements_small << single_element_hash
|
46
|
+
@kracker_object.stubs(:perform_mapping_operation).returns(current_data)
|
47
|
+
mapping_results = @kracker_object.page_map_same?(@test_root)
|
48
|
+
|
49
|
+
refute mapping_results[0], 'page same results should be false'
|
50
|
+
|
51
|
+
assert_match 'Elements not in master: 1', mapping_results[1], 'error message contents'
|
52
|
+
assert_match 'Elements not in current: 0', mapping_results[1], 'error message contents'
|
53
|
+
assert_match 'Changed elements: 0', mapping_results[1], 'error message contents'
|
54
|
+
|
55
|
+
assert_match "current: #{Kracker.current_filename(@test_root)}", mapping_results[1], 'error message contents'
|
56
|
+
assert_match "master: #{Kracker.master_filename(@test_root)}", mapping_results[1], 'error message contents'
|
57
|
+
assert_match "difference: #{Kracker.diff_filename(@test_root)}", mapping_results[1], 'error message contents'
|
58
|
+
|
59
|
+
assert_match blessing_copy_string, mapping_results[1], 'blessing copy string should be in the error message'
|
60
|
+
|
61
|
+
files_in_diff_location = Dir[File.join(Kracker.diff_file_location, '*')]
|
62
|
+
assert_equal 4, files_in_diff_location.count, 'the number of files in the diff location after a failure.'
|
63
|
+
|
64
|
+
`#{blessing_copy_string}`
|
65
|
+
|
66
|
+
@kracker_object.stubs(:perform_mapping_operation).returns(current_data)
|
67
|
+
mapping_results = @kracker_object.page_map_same?(@test_root)
|
68
|
+
|
69
|
+
assert mapping_results[0], 'should pass now that the blessing copy string has been run'
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
def make_master_test_file(test_root, data)
|
74
|
+
filename = Kracker.master_filename(test_root)
|
75
|
+
yaml_data = data.to_yaml
|
76
|
+
File.open(filename, 'w') { |file| file.write(yaml_data) }
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class LocationTest < Kracker::KrackerTestCase
|
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_locations
|
14
|
+
assert_equal File.join(@locations_root, 'masters'), Kracker.master_file_location , 'master file location value'
|
15
|
+
assert_equal File.join(@locations_root, 'current'), Kracker.current_file_location , 'current file location value'
|
16
|
+
assert_equal File.join(@locations_root, 'diff'), Kracker.diff_file_location , 'difference file location value'
|
17
|
+
|
18
|
+
assert Dir.exist?(Kracker.master_file_location) , 'master file location created'
|
19
|
+
assert Dir.exist?(Kracker.current_file_location) , 'current file location created'
|
20
|
+
assert Dir.exist?(Kracker.diff_file_location) , 'difference file location created'
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/watchr_script.rb
ADDED
metadata
ADDED
@@ -0,0 +1,199 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kracker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- geordie
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: kramdown
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.1.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.1.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: capybara
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: DOM Mapping
|
70
|
+
email:
|
71
|
+
- george.speake@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- .ruby-version
|
78
|
+
- .travis.yml
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- app/assets/javascripts/application.js
|
84
|
+
- app/assets/stylesheets/1236_grid.css
|
85
|
+
- app/assets/stylesheets/720_grid.css
|
86
|
+
- app/assets/stylesheets/986_grid.css
|
87
|
+
- app/assets/stylesheets/kracker.css
|
88
|
+
- app/assets/stylesheets/normalize.css
|
89
|
+
- app/controllers/kracker_application_controller.rb
|
90
|
+
- app/controllers/kracker_controller.rb
|
91
|
+
- app/views/kracker/about.html.erb
|
92
|
+
- app/views/kracker/artifacts.html.erb
|
93
|
+
- app/views/kracker/index.html.erb
|
94
|
+
- app/views/kracker/new.html.erb
|
95
|
+
- app/views/kracker/path_config.html.erb
|
96
|
+
- app/views/kracker/show.html.erb
|
97
|
+
- app/views/layouts/kracker.html.erb
|
98
|
+
- app/views/shared/_dom_set.html.erb
|
99
|
+
- app/views/shared/_kracker_nav.html.erb
|
100
|
+
- config/routes.rb
|
101
|
+
- kracker.gemspec
|
102
|
+
- lib/kracker.rb
|
103
|
+
- lib/kracker/analysis.rb
|
104
|
+
- lib/kracker/element.rb
|
105
|
+
- lib/kracker/kracker.rb
|
106
|
+
- lib/kracker/locations.rb
|
107
|
+
- lib/kracker/rails/engine.rb
|
108
|
+
- lib/kracker/svg.rb
|
109
|
+
- lib/kracker/version.rb
|
110
|
+
- test/page_objects.rb
|
111
|
+
- test/page_objects/kracker/about_page.rb
|
112
|
+
- test/page_objects/kracker/artifacts_page.rb
|
113
|
+
- test/page_objects/kracker/config_page.rb
|
114
|
+
- test/page_objects/kracker/index_page.rb
|
115
|
+
- test/page_objects/kracker/local_index_page.rb
|
116
|
+
- test/page_objects/kracker/new_page.rb
|
117
|
+
- test/page_objects/kracker/show_page.rb
|
118
|
+
- test/page_objects/kracker/viewer_page.rb
|
119
|
+
- test/page_objects/navigation.rb
|
120
|
+
- test/selenium/mapping_test.rb
|
121
|
+
- test/selenium/viewer_test.rb
|
122
|
+
- test/selenium_test_helper.rb
|
123
|
+
- test/test_app/Gemfile
|
124
|
+
- test/test_app/app/assets/stylesheets/local_app.css
|
125
|
+
- test/test_app/app/controllers/application_controller.rb
|
126
|
+
- test/test_app/app/controllers/local_controller.rb
|
127
|
+
- test/test_app/app/views/layouts/local.html.erb
|
128
|
+
- test/test_app/app/views/local/index.html.erb
|
129
|
+
- test/test_app/config.ru
|
130
|
+
- test/test_app/config/database.yml
|
131
|
+
- test/test_app/config/initializers/kracker_initializer.rb
|
132
|
+
- test/test_app/config/routes.rb
|
133
|
+
- test/test_app/test_app.rb
|
134
|
+
- test/test_helper.rb
|
135
|
+
- test/test_helpers/kracker_class_for_stubbing.rb
|
136
|
+
- test/test_helpers/location_helpers.rb
|
137
|
+
- test/test_objects/test_objects.rb
|
138
|
+
- test/unit/analysis_test.rb
|
139
|
+
- test/unit/element_test.rb
|
140
|
+
- test/unit/kracker_test.rb
|
141
|
+
- test/unit/location_test.rb
|
142
|
+
- watchr_script.rb
|
143
|
+
homepage: https://github.com/QuantumGeordie/kracker
|
144
|
+
licenses:
|
145
|
+
- MIT
|
146
|
+
metadata: {}
|
147
|
+
post_install_message:
|
148
|
+
rdoc_options: []
|
149
|
+
require_paths:
|
150
|
+
- lib
|
151
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - '>='
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - '>='
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
requirements: []
|
162
|
+
rubyforge_project:
|
163
|
+
rubygems_version: 2.1.11
|
164
|
+
signing_key:
|
165
|
+
specification_version: 4
|
166
|
+
summary: Map the page DOM and get some stats on it compared to a known default map.
|
167
|
+
test_files:
|
168
|
+
- test/page_objects.rb
|
169
|
+
- test/page_objects/kracker/about_page.rb
|
170
|
+
- test/page_objects/kracker/artifacts_page.rb
|
171
|
+
- test/page_objects/kracker/config_page.rb
|
172
|
+
- test/page_objects/kracker/index_page.rb
|
173
|
+
- test/page_objects/kracker/local_index_page.rb
|
174
|
+
- test/page_objects/kracker/new_page.rb
|
175
|
+
- test/page_objects/kracker/show_page.rb
|
176
|
+
- test/page_objects/kracker/viewer_page.rb
|
177
|
+
- test/page_objects/navigation.rb
|
178
|
+
- test/selenium/mapping_test.rb
|
179
|
+
- test/selenium/viewer_test.rb
|
180
|
+
- test/selenium_test_helper.rb
|
181
|
+
- test/test_app/Gemfile
|
182
|
+
- test/test_app/app/assets/stylesheets/local_app.css
|
183
|
+
- test/test_app/app/controllers/application_controller.rb
|
184
|
+
- test/test_app/app/controllers/local_controller.rb
|
185
|
+
- test/test_app/app/views/layouts/local.html.erb
|
186
|
+
- test/test_app/app/views/local/index.html.erb
|
187
|
+
- test/test_app/config.ru
|
188
|
+
- test/test_app/config/database.yml
|
189
|
+
- test/test_app/config/initializers/kracker_initializer.rb
|
190
|
+
- test/test_app/config/routes.rb
|
191
|
+
- test/test_app/test_app.rb
|
192
|
+
- test/test_helper.rb
|
193
|
+
- test/test_helpers/kracker_class_for_stubbing.rb
|
194
|
+
- test/test_helpers/location_helpers.rb
|
195
|
+
- test/test_objects/test_objects.rb
|
196
|
+
- test/unit/analysis_test.rb
|
197
|
+
- test/unit/element_test.rb
|
198
|
+
- test/unit/kracker_test.rb
|
199
|
+
- test/unit/location_test.rb
|