1
require File.dirname(__FILE__) + '/spec_helper'
2
require File.dirname(__FILE__) + '/file_accessor'
5
describe "A FileAccessor" do
6
# This sequence diagram illustrates what this spec specifies.
8
# +--------------+ +----------+ +-------------+
9
# | FileAccessor | | Pathname | | IoProcessor |
10
# +--------------+ +----------+ +-------------+
12
# open_and_handle_with | | |
13
# -------------------->| | open | |
14
# | |--------------->| | |
16
# | |<...............| | |
18
# | |---------------------------------->| |
20
# | |<..................................| |
23
it "should open a file and pass it to the processor's process method" do
24
# This is the primary actor
25
accessor = FileAccessor.new
27
# These are the primary actor's neighbours, which we mock.
28
file = mock "Pathname"
29
io_processor = mock "IoProcessor"
31
io = StringIO.new "whatever"
32
file.should_receive(:open).and_yield io
33
io_processor.should_receive(:process).with(io)
35
accessor.open_and_handle_with(file, io_processor)