[rspec-users] Comparing files

Joseph Wilk joe at josephwilk.net
Fri Dec 10 11:41:19 EST 2010


On 10/12/2010 15:56, 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?
>

In the past I've generated a checksum for each file and compare that.

-- 
Joseph Wilk http://blog.josephwilk.net http://www.songkick.com +44
(0)7812 816431



> cheers,
> Matt
>
> matt at mattwynne.net
> 07974 430184
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


-- 
Joseph Wilk
http://blog.josephwilk.net
http://www.songkick.com
+44 (0)7812 816431 



More information about the rspec-users mailing list