Asserting files are not different in Test::Unit?

D

David Brady

I am writing some document generation classes now, and testing them with
Test::Unit. The documents are 20-50k in size, and as a good initial
test I'd like to simply generate a document and compare it against the
output of the existing document generator.

What are some good Rubyish ways of doing this?

Is there a Ruby Way to diff text files?

Is there a Ruby Way to assert that two text files are the same?

I suppose I could just write a wrapper to a system call to diff.

Alternately, I could wrapper a method in Test::Unit to read a file into
a gigantic string, and assert_equal that against the contents of another
string. The fail message from this, however, would not only be useless
(100k of text to the console!), but would blind the system to other fail
messages useless as well.

Thoughts?

-dB
 
J

Jeff Wood

Hows about

assert( FileUtils.compare_file('somefile', 'somefile') )

j.

I am writing some document generation classes now, and testing them with
Test::Unit. The documents are 20-50k in size, and as a good initial
test I'd like to simply generate a document and compare it against the
output of the existing document generator.
=20
What are some good Rubyish ways of doing this?
=20
Is there a Ruby Way to diff text files?
=20
Is there a Ruby Way to assert that two text files are the same?
=20
I suppose I could just write a wrapper to a system call to diff.
=20
Alternately, I could wrapper a method in Test::Unit to read a file into
a gigantic string, and assert_equal that against the contents of another
string. The fail message from this, however, would not only be useless
(100k of text to the console!), but would blind the system to other fail
messages useless as well.
=20
Thoughts?
=20
-dB
=20
--
David Brady
(e-mail address removed)
I'm feeling really surreal today... OR AM I?
=20
=20
=20


--=20
"So long, and thanks for all the fish"

Jeff Wood
 
A

Austin Ziegler

What are some good Rubyish ways of doing this?
Is there a Ruby Way to diff text files?
Is there a Ruby Way to assert that two text files are the same?
I suppose I could just write a wrapper to a system call to diff.

You could use Diff::LCS, available on RubyForge.

-austin
--=20
Austin Ziegler * (e-mail address removed)
* Alternate: (e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top