search for: file_reader_spec

Displaying 1 result from an estimated 1 matches for "file_reader_spec".

2007 Dec 07
0
weird behavior of mocking ruby class methods
...played with Rspec for three months, I realized a weird behavior of mocking ruby classes (e.g. File). Please let me post a sample code before I point out the problems: #file_reader.rb (to be tested) class FileReader def do_read File.read(''asd.txt'') end end #file_reader_spec.rb describe FileReader, "do_read" do it "should throw File Not Found on non-existent file" do reader = FileReader.new() lambda { reader.do_read }.should raise_error(Errno::ENOENT) end end describe FileReader, "do_read" do it...