dom_glancy 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +15 -0
  5. data/Gemfile +16 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +35 -0
  8. data/Rakefile +23 -0
  9. data/app/assets/javascripts/application.js +1 -0
  10. data/app/assets/stylesheets/1236_grid.css +21 -0
  11. data/app/assets/stylesheets/720_grid.css +33 -0
  12. data/app/assets/stylesheets/986_grid.css +24 -0
  13. data/app/assets/stylesheets/dom_glancy.css +134 -0
  14. data/app/assets/stylesheets/normalize.css +425 -0
  15. data/app/controllers/dom_glancy_application_controller.rb +8 -0
  16. data/app/controllers/dom_glancy_controller.rb +114 -0
  17. data/app/views/dom_glancy/about.html.erb +3 -0
  18. data/app/views/dom_glancy/artifacts.html.erb +16 -0
  19. data/app/views/dom_glancy/index.html.erb +12 -0
  20. data/app/views/dom_glancy/new.html.erb +15 -0
  21. data/app/views/dom_glancy/path_config.html.erb +8 -0
  22. data/app/views/dom_glancy/show.html.erb +42 -0
  23. data/app/views/layouts/dom_glancy.html.erb +32 -0
  24. data/app/views/shared/_dom_glancy_nav.html.erb +8 -0
  25. data/app/views/shared/_dom_set.html.erb +35 -0
  26. data/config/routes.rb +17 -0
  27. data/dom_glancy.gemspec +26 -0
  28. data/lib/dom_glancy/analysis.rb +141 -0
  29. data/lib/dom_glancy/dom_glancy.rb +121 -0
  30. data/lib/dom_glancy/element.rb +92 -0
  31. data/lib/dom_glancy/locations.rb +49 -0
  32. data/lib/dom_glancy/rails/engine.rb +7 -0
  33. data/lib/dom_glancy/svg.rb +71 -0
  34. data/lib/dom_glancy/version.rb +3 -0
  35. data/lib/dom_glancy.rb +7 -0
  36. data/test/page_objects/dom_glancy/about_page.rb +7 -0
  37. data/test/page_objects/dom_glancy/artifacts_page.rb +7 -0
  38. data/test/page_objects/dom_glancy/config_page.rb +19 -0
  39. data/test/page_objects/dom_glancy/index_page.rb +9 -0
  40. data/test/page_objects/dom_glancy/local_index_page.rb +7 -0
  41. data/test/page_objects/dom_glancy/new_page.rb +7 -0
  42. data/test/page_objects/dom_glancy/show_page.rb +15 -0
  43. data/test/page_objects/dom_glancy/viewer_page.rb +15 -0
  44. data/test/page_objects/navigation.rb +34 -0
  45. data/test/page_objects.rb +13 -0
  46. data/test/selenium/mapping_test.rb +118 -0
  47. data/test/selenium/viewer_test.rb +26 -0
  48. data/test/selenium_test_helper.rb +147 -0
  49. data/test/test_app/Gemfile +10 -0
  50. data/test/test_app/app/assets/stylesheets/local_app.css +25 -0
  51. data/test/test_app/app/controllers/application_controller.rb +2 -0
  52. data/test/test_app/app/controllers/local_controller.rb +8 -0
  53. data/test/test_app/app/views/layouts/local.html.erb +14 -0
  54. data/test/test_app/app/views/local/index.html.erb +45 -0
  55. data/test/test_app/config/database.yml +13 -0
  56. data/test/test_app/config/initializers/dom_glancy_initializer.rb +5 -0
  57. data/test/test_app/config/routes.rb +4 -0
  58. data/test/test_app/config.ru +31 -0
  59. data/test/test_app/test_app.rb +30 -0
  60. data/test/test_helper.rb +43 -0
  61. data/test/test_helpers/kracker_class_for_stubbing.rb +3 -0
  62. data/test/test_helpers/location_helpers.rb +28 -0
  63. data/test/test_objects/test_objects.rb +2031 -0
  64. data/test/unit/analysis_test.rb +111 -0
  65. data/test/unit/element_test.rb +47 -0
  66. data/test/unit/kracker_test.rb +79 -0
  67. data/test/unit/location_test.rb +23 -0
  68. data/watchr_script.rb +3 -0
  69. metadata +199 -0
@@ -0,0 +1,34 @@
1
+ module PageObjects
2
+ class Navigation < ::AePageObjects::Element
3
+
4
+ def home!
5
+ node.find_link('home').click
6
+ PageObjects::DomGlancy::IndexPage.new
7
+ end
8
+
9
+ def config!
10
+ node.find_link('config').click
11
+ PageObjects::DomGlancy::ConfigPage.new
12
+ end
13
+
14
+ def new_page!
15
+ node.find_link('new').click
16
+ PageObjects::DomGlancy::NewPage.new
17
+ end
18
+
19
+ def artifacts!
20
+ node.find_link('artifacts').click
21
+ PageObjects::DomGlancy::ArtifactsPage.new
22
+ end
23
+
24
+ def clear_results!
25
+ node.find_link('clear').click
26
+ PageObjects::DomGlancy::IndexPage.new
27
+ end
28
+
29
+ def about!
30
+ node.find_link('about').click
31
+ PageObjects::DomGlancy::AboutPage.new
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,13 @@
1
+ require 'ae_page_objects'
2
+
3
+ ActiveSupport::Dependencies.autoload_paths << 'test'
4
+
5
+ module PageObjects
6
+ module DomGlancy
7
+ class Site < ::AePageObjects::Site
8
+
9
+ end
10
+ end
11
+ end
12
+
13
+ PageObjects::DomGlancy::Site.initialize!
@@ -0,0 +1,118 @@
1
+ require 'selenium_test_helper'
2
+
3
+ class MappingTest < DomGlancy::SeleniumTestCase
4
+
5
+ def test_full_mapping__same
6
+ visit_index
7
+
8
+ map_current_page_and_save_as_master('dom_glancy_index')
9
+
10
+ same, msg = page_map_same?('dom_glancy_index')
11
+
12
+ assert same, msg
13
+ assert_artifacts_on_same('dom_glancy_index')
14
+ end
15
+
16
+ def test_mapping__no_master
17
+ visit_index
18
+ same, msg = page_map_same?('poop')
19
+ refute same, msg
20
+ assert_match 'Master file does not exist', msg, 'the missing master error message'
21
+ end
22
+
23
+ def test_full_mapping__one_added__clear
24
+ visit_index
25
+
26
+ map_current_page_and_save_as_master('dom_glancy_index')
27
+
28
+ add_centered_element('Back In Black')
29
+
30
+ same, msg = page_map_same?('dom_glancy_index')
31
+
32
+ refute same, msg
33
+
34
+ index_page = visit_index
35
+
36
+ assert_equal 1, index_page.files.count, 'number of difference files'
37
+ assert_match 'dom_glancy_index_diff.html', index_page.files.first.text, 'file name displayed'
38
+
39
+ index_page.files.first.find('a').click
40
+ show_page = PageObjects::DomGlancy::ShowPage.new
41
+
42
+ assert_equal 1, show_page.not_master.count, 'elements listed as not in master'
43
+ assert_equal 0, show_page.not_current.count, 'elements listed as not in current'
44
+ assert_equal 0, show_page.changed.count, 'elements listed as changed'
45
+
46
+ assert_artifacts_on_difference('dom_glancy_index')
47
+
48
+ index_page = show_page.navigation.clear_results!
49
+ assert_equal 0, index_page.files.count, 'should be no difference files now'
50
+ end
51
+
52
+ def test_full_mapping__one_missing__bless
53
+ visit_index
54
+
55
+ map_current_page_and_save_as_master('dom_glancy_index')
56
+
57
+ remove_about_element
58
+
59
+ same, msg = page_map_same?('dom_glancy_index')
60
+
61
+ refute same, msg
62
+
63
+ index_page = visit_index
64
+
65
+ assert_equal 1, index_page.files.count, 'number of difference files'
66
+ assert_match 'dom_glancy_index_diff.html', index_page.files.first.text, 'file name displayed'
67
+
68
+ index_page.files.first.find('a').click
69
+ show_page = PageObjects::DomGlancy::ShowPage.new
70
+
71
+ assert_equal 0, show_page.not_master.count, 'elements listed as not in master'
72
+ assert_equal 7, show_page.not_current.count, 'elements listed as not in current'
73
+ assert_equal 5, show_page.changed.count, 'elements listed as changed'
74
+
75
+ assert_artifacts_on_difference('dom_glancy_index')
76
+
77
+ index_page = show_page.bless!
78
+ assert_equal 0, index_page.files.count, 'number of difference files'
79
+ end
80
+
81
+ def test_non_dom_glancy_page__pass
82
+ local_page = PageObjects::DomGlancy::LocalIndexPage.visit
83
+
84
+ map_current_page_and_save_as_master('test_page')
85
+
86
+ same, msg = page_map_same?('test_page')
87
+
88
+ assert same, msg
89
+
90
+ assert_artifacts_on_same 'test_page'
91
+ end
92
+
93
+ def test_non_dom_glancy_page__fail__size_change
94
+ local_page = PageObjects::DomGlancy::LocalIndexPage.visit
95
+
96
+ map_current_page_and_save_as_master('test_page')
97
+
98
+ starting_dimensions = get_current_browser_dimensions
99
+ w = starting_dimensions.width + 100
100
+ h = starting_dimensions.height
101
+
102
+ resize_browser(w, h)
103
+
104
+ same, msg = page_map_same?('test_page')
105
+
106
+ refute same, msg
107
+
108
+ assert_artifacts_on_difference 'test_page'
109
+ end
110
+
111
+ private
112
+
113
+ def map_current_page_and_save_as_master(test_root)
114
+ map_data = perform_mapping_operation
115
+ File.open(DomGlancy.master_filename(test_root), 'w') { |file| file.write(map_data.to_yaml) }
116
+ end
117
+
118
+ end
@@ -0,0 +1,26 @@
1
+ require 'selenium_test_helper'
2
+
3
+ class ViewerTest < DomGlancy::SeleniumTestCase
4
+
5
+ def test_navigation
6
+ index_page = visit_index
7
+ config_page = index_page.navigation.config!
8
+
9
+ assert_equal DomGlancy.master_file_location.to_s, config_page.master, 'master file location'
10
+ assert_equal DomGlancy.current_file_location.to_s, config_page.current, 'current file location'
11
+ assert_equal DomGlancy.diff_file_location.to_s, config_page.diffs, 'difference file location'
12
+
13
+ new_page = config_page.navigation.new_page!
14
+ assert page.has_content?('do not have a corresponding master file in the expected file location'), 'new masters page content.'
15
+
16
+ # Don't have TeamCity integration right now.
17
+ # artifacts_page = new_page.navigation.artifacts!
18
+ # assert page.has_content?('TeamCity Artifacts'), 'artifacts page needs some content.'
19
+
20
+ about_page = new_page.navigation.about!
21
+ assert page.has_content?('Add this line to your'), 'about page line from README.md'
22
+
23
+ index_page = about_page.navigation.home!
24
+ end
25
+
26
+ end
@@ -0,0 +1,147 @@
1
+ ENV['RAILS_ENV'] = 'test'
2
+
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '.'))
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..'))
6
+
7
+ require 'rubygems'
8
+ require 'bundler'
9
+
10
+ begin
11
+ Bundler.setup(:default, :development)
12
+ rescue Bundler::BundlerError => e
13
+ $stderr.puts e.message
14
+ $stderr.puts "Run `bundle install` to install missing gems"
15
+ exit e.status_code
16
+ end
17
+
18
+ require 'rails/all'
19
+ require 'dom_glancy'
20
+ require 'test_app/test_app'
21
+
22
+ require 'minitest/autorun'
23
+
24
+ require 'awesome_print'
25
+
26
+ require 'capybara'
27
+ require 'capybara/dsl'
28
+ require 'capybara/rails'
29
+ require 'selenium-webdriver'
30
+
31
+ require 'page_objects'
32
+
33
+ test_objects_location = File.expand_path('../test_objects/*', __FILE__)
34
+ Dir[test_objects_location].each { |f| require f }
35
+
36
+ test_helper_location = File.expand_path('../test_helpers/**/*.rb', __FILE__)
37
+ Dir[test_helper_location].each { |f| require f }
38
+
39
+ Capybara.default_driver = :selenium
40
+
41
+ module DomGlancy
42
+ class SeleniumTestCase < Minitest::Test
43
+ include DomGlancy
44
+ include DomGlancy::TestObjects
45
+ include DomGlancy::TestHelpers::Location
46
+
47
+ include Capybara::DSL
48
+
49
+ def setup
50
+ delete_contents_from_dom_glancy_locations
51
+ initialize_browser_size_for_test
52
+ end
53
+
54
+ def teardown
55
+ delete_contents_from_dom_glancy_locations
56
+ end
57
+
58
+ def initialize_browser_size_for_test
59
+ @browser_dimensions = ENV['BROWSER_SIZE'] || '960x1000'
60
+ if @browser_dimensions
61
+ @starting_dimensions = get_current_browser_dimensions
62
+ w = @browser_dimensions.split('x')[0]
63
+ h = @browser_dimensions.split('x')[1]
64
+ resize_browser(w, h)
65
+ end
66
+ end
67
+
68
+ def visit_index
69
+ PageObjects::DomGlancy::IndexPage.visit
70
+ end
71
+
72
+ def remove_about_element
73
+ js = <<-JS
74
+ var element = document.getElementById('js-kr--nav');
75
+ element.parentNode.removeChild(element);
76
+ JS
77
+
78
+ page.driver.browser.execute_script(js)
79
+ end
80
+
81
+ def add_centered_element(text_content)
82
+ js = <<-JS
83
+ var centeredElement = document.createElement('div');
84
+ centeredElement.style.textAlign = 'center';
85
+ centeredElement.style.fontSize = '2em';
86
+ centeredElement.style.width = '400px';
87
+ centeredElement.style.marginLeft = 'auto';
88
+ centeredElement.style.marginRight = 'auto';
89
+ centeredElement.id = 'hack-element';
90
+ centeredElement.textContent = '#{text_content}';
91
+ centeredElement.style.backgroundColor = '#ff0000'
92
+ document.getElementsByTagName('body')[0].appendChild(centeredElement);
93
+ JS
94
+
95
+ page.driver.browser.execute_script(js)
96
+ end
97
+
98
+ def resize_browser(width, height)
99
+ page.driver.browser.manage.window.resize_to(width.to_i, height.to_i)
100
+ end
101
+
102
+ def get_current_browser_dimensions
103
+ page.driver.browser.manage.window.size
104
+ end
105
+
106
+ def assert_artifacts_on_difference(test_root)
107
+ filename = DomGlancy.diff_filename(test_root)
108
+ assert File.exists?(filename), "Diff file should exist: #{filename}"
109
+
110
+ filename = File.join(DomGlancy.diff_file_location, "#{test_root}__changed_master__diff.yaml")
111
+ assert File.exists?(filename), "Changed master file should exist: #{filename}"
112
+
113
+ filename = File.join(DomGlancy.diff_file_location, "#{test_root}__current_not_master__diff.yaml")
114
+ assert File.exists?(filename), "Current, not master, file should exist: #{filename}"
115
+
116
+ filename = File.join(DomGlancy.diff_file_location, "#{test_root}__master_not_current__diff.yaml")
117
+ assert File.exists?(filename), "Master, not current, file should exist: #{filename}"
118
+
119
+ filename = DomGlancy.master_filename(test_root)
120
+ assert File.exists?(filename), "Master file should exist: #{filename}"
121
+
122
+ filename = DomGlancy.current_filename(test_root)
123
+ assert File.exists?(filename), "Current file should exist: #{filename}"
124
+ end
125
+
126
+ def assert_artifacts_on_same(test_root)
127
+ filename = DomGlancy.diff_filename(test_root)
128
+ refute File.exists?(filename), "No diff file should exist: #{filename}"
129
+
130
+ filename = File.join(DomGlancy.diff_file_location, "#{test_root}__changed_master__diff.yaml")
131
+ refute File.exists?(filename), "No changed master file should exist: #{filename}"
132
+
133
+ filename = File.join(DomGlancy.diff_file_location, "#{test_root}__current_not_master__diff.yaml")
134
+ refute File.exists?(filename), "No current, not master, file should exist: #{filename}"
135
+
136
+ filename = File.join(DomGlancy.diff_file_location, "#{test_root}__master_not_current__diff.yaml")
137
+ refute File.exists?(filename), "No master, not current, file should exist: #{filename}"
138
+
139
+ filename = DomGlancy.master_filename(test_root)
140
+ assert File.exists?(filename), "Master file should exist: #{filename}"
141
+
142
+ filename = DomGlancy.current_filename(test_root)
143
+ refute File.exists?(filename), "No current file should exist: #{filename}"
144
+ end
145
+
146
+ end
147
+ end
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rails', '3.2.16'
4
+ gem 'json'
5
+ gem 'sqlite3'
6
+
7
+ group :test, :development do
8
+ gem 'dom_glancy', :path => '../..'
9
+ end
10
+
@@ -0,0 +1,25 @@
1
+ body {
2
+ background-color: #c0c0c0;
3
+ color: #ffff00;
4
+ }
5
+
6
+ table {
7
+ margin: auto;
8
+ padding: 20px;
9
+ color: #ff9933;
10
+ font-family: Verdana, Arial, Helvetica, sans-serif;
11
+ border: 1px #ff0000 solid;
12
+ }
13
+
14
+ td {
15
+ padding: 0 10px 0 20px;
16
+ text-align: center;
17
+ }
18
+
19
+ .big_text {
20
+ width: 100%;
21
+ max-width: 600px;
22
+ float: right;
23
+ font-size: 1.5em;
24
+ font-family: monospace, arial, helvetica, sans-serif;
25
+ }
@@ -0,0 +1,2 @@
1
+ class ApplicationController < ActionController::Base
2
+ end
@@ -0,0 +1,8 @@
1
+ class LocalController < ApplicationController
2
+ #layout 'local'
3
+
4
+ def index
5
+ @data = "A whole lot of stuff from the local#index route"
6
+ end
7
+
8
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Local</title>
5
+ <%= stylesheet_link_tag "local_app" %>
6
+
7
+ </head>
8
+ <body>
9
+ <h1>local layout</h1>
10
+ <hr/>
11
+ <%= yield %>
12
+ <hr/>
13
+ </body>
14
+ </html>
@@ -0,0 +1,45 @@
1
+ <table>
2
+ <thead>
3
+ <tr>
4
+ <th>name</th>
5
+ <th>phone</th>
6
+ <th>address</th>
7
+ <th>member?</th>
8
+ </tr>
9
+ </thead>
10
+ <tbody>
11
+ <% 5.times do |i| %>
12
+ <tr>
13
+ <td><%= "Person #{i}" %></td>
14
+ <td><%= "555-1#{i}1#{i}" %></td>
15
+ <td><%= "#{i}#{i}#{i}#{i} Main St." %></td>
16
+ <td><%= i % 2 == 0 ? 'yes' : 'no' %></td>
17
+ </tr>
18
+ <% end %>
19
+ </tbody>
20
+ </table>
21
+ <h1><%= @data %></h1>
22
+ <%= form_for '#' do |f| %>
23
+ <%= f.label :first_name %>:
24
+ <%= f.text_field :first_name %>
25
+ <br/>
26
+ <%= f.label :last_name %>:
27
+ <%= f.text_field :last_name %>
28
+ <br/>
29
+ <%= f.label :comments %>:
30
+ <%= f.text_area :comments %>
31
+ <br/>
32
+ <%= f.label :comment_type %>:
33
+ <br/>
34
+ <%= f.label :car %><%= f.radio_button :comment_type, 'car', :checked => true %>
35
+ <%= f.label :truck %><%= f.radio_button :comment_type, 'truck' %>
36
+ <%= f.label :bike %><%= f.radio_button :comment_type, 'bike' %>
37
+ <br/>
38
+ <%= f.submit%>
39
+ <% end %>
40
+
41
+ <div class="big_text">
42
+ <p>Hashtag art party trust fund, twee Terry Richardson direct trade mlkshk cornhole pickled Bushwick cardigan kale chips butcher. Polaroid chillwave direct trade, squid American Apparel literally semiotics 90's High Life twee ethical vinyl Odd Future Bushwick. Chillwave scenester authentic, try-hard Neutra pug wayfarers cornhole. Chambray next level wayfarers, ethical mixtape chillwave Etsy pour-over Cosby sweater. Ennui bespoke Echo Park umami banjo, Pinterest gastropub retro paleo next level. Tonx Schlitz stumptown Intelligentsia small batch, pickled roof party literally synth bitters irony. Wayfarers tousled chambray farm-to-table fanny pack, street art Thundercats cornhole fap pickled.</p>
43
+ <p>Do you need some dummy text? *sigh* Of course you do.</p>
44
+ <p>I bet you still use Helvetica too…</p>
45
+ </div>
@@ -0,0 +1,13 @@
1
+ test:
2
+ adapter: mysql2
3
+ encoding: utf8
4
+ reconnect: false
5
+ database: dom_glancy_test
6
+ pool: 5
7
+ username: root
8
+ password:
9
+ development:
10
+ adapter: sqlite3
11
+ database: dom_glancy_development
12
+ pool: 5
13
+ timeout: 5000
@@ -0,0 +1,5 @@
1
+ DomGlancy.master_file_location = Rails.root.join('tmp', 'data', 'map', 'masters')
2
+ DomGlancy.current_file_location = Rails.root.join('tmp', 'data', 'map', 'current')
3
+ DomGlancy.diff_file_location = Rails.root.join('tmp', 'data', 'map', 'diff')
4
+
5
+ DomGlancy.create_comparison_directories
@@ -0,0 +1,4 @@
1
+ Rails.application.routes.draw do
2
+ resources :local
3
+ root :to => 'local#index'
4
+ end
@@ -0,0 +1,31 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+ ENV['RAILS_ENV'] = 'development'
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..'))
5
+
6
+ require 'rubygems'
7
+ require 'bundler'
8
+
9
+ # Set up gems listed in the Gemfile.
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __FILE__)
11
+
12
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
13
+
14
+ begin
15
+ Bundler.setup(:default, :development)
16
+ rescue Bundler::BundlerError => e
17
+ $stderr.puts e.message
18
+ $stderr.puts "Run `bundle install` to install missing gems"
19
+ exit e.status_code
20
+ end
21
+
22
+ require "action_controller/railtie"
23
+ require "sprockets/railtie"
24
+ require 'rails'
25
+
26
+ require 'dom_glancy'
27
+
28
+ Rails.backtrace_cleaner.remove_silencers!
29
+
30
+ require 'test_app'
31
+ run DomGlancyApp::Application
@@ -0,0 +1,30 @@
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!
@@ -0,0 +1,43 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ begin
5
+ Bundler.setup(:default, :development)
6
+ rescue Bundler::BundlerError => e
7
+ $stderr.puts e.message
8
+ $stderr.puts "Run `bundle install` to install missing gems"
9
+ exit e.status_code
10
+ end
11
+
12
+ ENV['RAILS_ENV'] = 'test'
13
+
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '.'))
16
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..'))
17
+
18
+ require 'awesome_print'
19
+
20
+ require 'minitest/autorun'
21
+ require 'minitest/reporters'
22
+ Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
23
+
24
+ require 'mocha/setup'
25
+
26
+ require File.expand_path('../../lib/dom_glancy', __FILE__)
27
+
28
+ test_objects_location = File.expand_path('../test_objects/*', __FILE__)
29
+ Dir[test_objects_location].each { |f| require f }
30
+
31
+ test_helper_location = File.expand_path('../test_helpers/**/*.rb', __FILE__)
32
+ Dir[test_helper_location].each { |f| require f }
33
+
34
+
35
+ module DomGlancy
36
+ class DomGlancyTestCase < Minitest::Test
37
+
38
+ include DomGlancy
39
+ include DomGlancy::TestObjects
40
+ include DomGlancy::TestHelpers::Location
41
+
42
+ end
43
+ end
@@ -0,0 +1,3 @@
1
+ class DomGlancyClassForStubbing
2
+ include DomGlancy
3
+ end
@@ -0,0 +1,28 @@
1
+ module DomGlancy
2
+ module TestHelpers
3
+ module Location
4
+ def prep_locations_for_test
5
+ @locations_root = File.expand_path('../../tmp', __FILE__)
6
+
7
+ DomGlancy.master_file_location = File.join(@locations_root, 'masters')
8
+ DomGlancy.current_file_location = File.join(@locations_root, 'current')
9
+ DomGlancy.diff_file_location = File.join(@locations_root, 'diff')
10
+
11
+ DomGlancy.create_comparison_directories
12
+ end
13
+
14
+ def delete_test_locations
15
+ FileUtils.rm_rf DomGlancy.master_file_location
16
+ FileUtils.rm_rf DomGlancy.current_file_location
17
+ FileUtils.rm_rf DomGlancy.diff_file_location
18
+ end
19
+
20
+ def delete_contents_from_dom_glancy_locations
21
+ Dir[File.join(DomGlancy.master_file_location, "*.yaml")].each { |file| FileUtils.rm_rf file }
22
+ Dir[File.join(DomGlancy.current_file_location, "*.yaml")].each { |file| FileUtils.rm_rf file }
23
+ Dir[File.join(DomGlancy.diff_file_location, "*.html")].each { |file| FileUtils.rm_rf file }
24
+ Dir[File.join(DomGlancy.diff_file_location, "*.yaml")].each { |file| FileUtils.rm_rf file }
25
+ end
26
+ end
27
+ end
28
+ end