~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): Andrew Pollock
  • Date: 2009-04-13 17:12:47 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (3.1.3 squeeze) (1.2.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20090413171247-61zlnwi5esw1lhtv
ImportĀ upstreamĀ versionĀ 0.24.8

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