~ubuntu-branches/ubuntu/oneiric/puppet/oneiric-security

« back to all changes in this revision

Viewing changes to vendor/gems/rspec/examples/pure/file_accessor_spec.rb

  • Committer: Bazaar Package Importer
  • Author(s): Micah Anderson
  • Date: 2008-07-26 15:43:45 UTC
  • mto: (3.1.1 lenny) (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20080726154345-1fmgo76b4l72ulvc
ImportĀ upstreamĀ versionĀ 0.24.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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