diff --git a/Rakefile b/Rakefile
index e6624d7..20cf8d1 100644
--- a/Rakefile
+++ b/Rakefile
@@ -40,8 +40,8 @@ end
desc 'Run sanity tests without a full rebuild'
task :sanity_only do
- require_relative 'spec/samples/sanity.rb'
- Sanity.new.run
+ require_relative 'spec/sanity/sanity_test.rb'
+ SanityTest.new.run
end
desc 'Run full rebuild with sanity tests'
diff --git a/spec/sanity/.gitignore b/spec/sanity/.gitignore
new file mode 100644
index 0000000..9fc7f3b
--- /dev/null
+++ b/spec/sanity/.gitignore
@@ -0,0 +1 @@
+sanity.html
diff --git a/spec/sanity/sanity.html.erb b/spec/sanity/sanity.html.erb
new file mode 100644
index 0000000..19ade1e
--- /dev/null
+++ b/spec/sanity/sanity.html.erb
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+ Diff with CSS Example
+
+
+
+
+<% images.each_with_index do |(expected, actual), i| %>
+
+
+
+
+
+
+<% end %>
+
+
+
diff --git a/spec/sanity/sanity_test.rb b/spec/sanity/sanity_test.rb
new file mode 100644
index 0000000..58cbe9c
--- /dev/null
+++ b/spec/sanity/sanity_test.rb
@@ -0,0 +1,42 @@
+require 'launchy'
+require 'erb'
+require 'yaml'
+
+# An pixel-by-pixel comparison of sample images for visual regression testing
+class SanityTest
+
+ @@ERB = "#{File.expand_path(File.dirname(__FILE__))}/sanity.html.erb"
+ @@HTML = "#{File.expand_path(File.dirname(__FILE__))}/sanity.html"
+ @@COMPARES = "#{File.expand_path(File.dirname(__FILE__))}/tests.yml"
+ @@SAMPLES = "file:///#{File.expand_path("samples/")}"
+
+ def images
+ require 'pp'
+ comps = YAML.load_file(@@COMPARES)
+ pp comps
+ comps.each do | test, data |
+ pp data
+ end
+ [
+ ["#{@@SAMPLES}/images/_images_00_expected.png", "#{@@SAMPLES}/images/_images_00.png"]
+ ]
+ end
+
+ def run
+ puts @@SAMPLES
+ puts 'Building sanity test...'
+ process_erb(File.read(@@ERB))
+ Launchy.open('file:///' + @@HTML)
+ puts 'Done.'
+ end
+
+ private
+
+ def process_erb(sanity_template)
+ renderer = ERB.new(sanity_template)
+ File.open(@@HTML, 'w+') do |html|
+ html.write(renderer.result(binding))
+ end
+ end
+
+end
diff --git a/spec/sanity/tests.yml b/spec/sanity/tests.yml
new file mode 100644
index 0000000..8235348
--- /dev/null
+++ b/spec/sanity/tests.yml
@@ -0,0 +1,12 @@
+images:
+ dir: images
+ expected: _images_00_expected.png
+ actual: _images_00.png
+text:
+ dir: text
+ expected: _text_00_expected.png
+ actual: _text_00.png
+autoscale_font:
+ dir: autoscale_font
+ expected: card_00_expected.png
+ actual: card_00.png