]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/rspec-1.1.2/examples/pure/file_accessor_spec.rb
fix node relations bug (thanks Dave!)
[rails.git] / vendor / gems / rspec-1.1.2 / examples / pure / file_accessor_spec.rb
1 require File.dirname(__FILE__) + '/spec_helper'
2 require File.dirname(__FILE__) + '/file_accessor'
3 require 'stringio'
4
5 describe "A FileAccessor" do
6   # This sequence diagram illustrates what this spec specifies.
7   #
8   #                  +--------------+     +----------+     +-------------+
9   #                  | FileAccessor |     | Pathname |     | IoProcessor |
10   #                  +--------------+     +----------+     +-------------+
11   #                         |                  |                  |
12   #   open_and_handle_with  |                  |                  |
13   #   -------------------->| |           open  |                  |
14   #                        | |--------------->| |                 |
15   #                        | | io             | |                 |
16   #                        | |<...............| |                 |
17   #                        | |                 |     process(io)  |
18   #                        | |---------------------------------->| |
19   #                        | |                 |                 | |
20   #                        | |<..................................| |
21   #                         |                  |                  |
22   #
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
26
27     # These are the primary actor's neighbours, which we mock.
28     file = mock "Pathname"
29     io_processor = mock "IoProcessor"
30     
31     io = StringIO.new "whatever"
32     file.should_receive(:open).and_yield io
33     io_processor.should_receive(:process).with(io)
34     
35     accessor.open_and_handle_with(file, io_processor)
36   end
37
38 end