[rspec-users] Comparing files

Josh Chisholm joshuachisholm at gmail.com
Fri Dec 10 13:07:44 EST 2010


On Fri, Dec 10, 2010 at 4:30 PM, George Dinwiddie
<lists at idiacomputing.com> wrote:
> Matt,
>
> On 12/10/10 9:56 AM, Matt Wynne wrote:
>>
>> Hello folks,
>>
>> I'm writing some tests for file upload code. The files are binary,
>> images mostly. I'm futzing around a bit, trying to figure out how to
>> assert that the uploaded file is the same as some golden master. If I
>> do this:
>>
>> File.read(uploaded_file_path).should ==
>> File.read(path_to_expected_file)
>>
>> Then when it fails, I get an ugly diff of the difference between the
>> binary files. So I'm about to invent something of my own. Has anyone
>> got a good pattern for doing this already?
>
> I don't already have it, but I've long wanted to implement a visual image
> diff based on an exclusive-or of the two images.  This would give a quick
> visual demonstration of the differences.
>
> I once saw (but now cannot find) and image compare library that did a "fuzzy
> compare" that wasn't fooled by pixel differences.  I've looked for this
> several times, but haven't been able to turn it up again.  It's out there,
> though, in the scientific community (IIRC) rather than the software testing
> community.

I think some teams at the BBC have used this tool for that kind of
fuzzy image comparison: http://pdiff.sourceforge.net/

Josh

>
>  - George
>
> --
>  Dec. 14 - Agile Richmond in Glen Allen, VA
>  http://georgedinwiddie.eventbrite.com/
>  ----------------------------------------------------------------------
>  * George Dinwiddie *                      http://blog.gdinwiddie.com
>  Software Development                    http://www.idiacomputing.com
>  Consultant and Coach                    http://www.agilemaryland.org
>  ----------------------------------------------------------------------
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list