changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec/examples/pure/file_accessor_spec.rb

changeset 15: 64acf98d15f4
author: moriq@moriq.com
date: Mon Mar 10 10:12:58 2008 +0900 (16 years ago)
permissions: -rw-r--r--
description: add plugins rspec
1require File.dirname(__FILE__) + '/spec_helper'
2require File.dirname(__FILE__) + '/file_accessor'
3require 'stringio'
4
5describe "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
38end