Regression testing: cairo mock object stores graphics calls

So the idea behind this is maintain an "expected value" for the sample runs. We store the graphics calls and their arguments as a readable text file. Any change in the samples will break this, but the idea is to make sure this doesn't get broken unexpectedly.

Rearranged the data files in specs
This commit is contained in:
Andy Meneely
2014-11-18 01:53:00 -05:00
parent 3c3d63e1ae
commit 99ac612b8a
35 changed files with 3080 additions and 36 deletions
+44
View File
@@ -0,0 +1,44 @@
require 'spec_helper'
require 'squib'
require 'pp'
require 'method_log_proxy'
describe Squib do
context 'samples' do
it 'should execute with no errors' do
allow(ProgressBar).to receive(:create).and_return(Squib::DoNothing.new)
samples = File.expand_path('../../samples', File.dirname(__FILE__))
Dir["#{samples}/**/*.rb"].each do |sample|
Dir.chdir(samples) do #to save to _output
load sample
end
end
end
it 'did not change against regression logs' do
samples = File.expand_path('../../samples', File.dirname(__FILE__))
Dir["#{samples}/**/*.rb"].each do |sample|
sample_name = File.basename(sample)
header = "=== #{sample_name} ===\n"
Dir.chdir(samples) do #to save to _output
strio = StringIO.new
strio << header
mock_cairo(strio)
load sample
test_file_str = ""
# Use this to overwrite the regression with current state
# Use ONLY temporarily after you are happy with the new sample log
# File.open(sample_regression_file(sample_name), 'w+') do |f|
# f.write(strio.string) # write back out to expected file
# end
test_file_str << File.open(sample_regression_file(sample_name)).read
expect(strio.string).to eq(test_file_str)
end
end
end
end
end