-
-
Save gstark/2371940 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Having #process dependent on File.open | |
# *and* #read, separate the processing to allow a | |
# more general IO processing and another method | |
# that handles the opening to get the IO and delegate | |
# | |
describe "Processing XML file" do | |
it "Reads from a file and processes the contents" do | |
file_path = "/some/path/to.xml" | |
stub_io = stub | |
# still dependent on File#read | |
File.should_receive(:read).with(file_path).and_return(stub_io) | |
Parser.should_receive(:process).with(stub_io) | |
Parser.process_file_path(file_path) | |
end | |
it "Processes from an IO" do | |
xml = "<xml>bleh</xml>" | |
io = stub(:read => xml) | |
Parse.should_receive(:process_xml).with(xml) | |
Parser.process(io) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment