Sha256: bcbc85d5c3bfd1f35b73ebba038c8138a0a0c953e7bfb5572f37a0675ed30886

Contents?: true

Size: 1.66 KB

Versions: 10

Compression:

Stored size: 1.66 KB

Contents

require File.dirname(__FILE__) + '/spec_helper'
require File.dirname(__FILE__) + '/file_accessor'
require 'stringio'

describe "A FileAccessor" do
  # This sequence diagram illustrates what this spec specifies.
  #
  #                  +--------------+     +----------+     +-------------+
  #                  | FileAccessor |     | Pathname |     | IoProcessor |
  #                  +--------------+     +----------+     +-------------+
  #                         |                  |                  |
  #   open_and_handle_with  |                  |                  |
  #   -------------------->| |           open  |                  |
  #                        | |--------------->| |                 |
  #                        | | io             | |                 |
  #                        | |<...............| |                 |
  #                        | |                 |     process(io)  |
  #                        | |---------------------------------->| |
  #                        | |                 |                 | |
  #                        | |<..................................| |
  #                         |                  |                  |
  #
  it "should open a file and pass it to the processor's process method" do
    # This is the primary actor
    accessor = FileAccessor.new

    # These are the primary actor's neighbours, which we mock.
    file = mock "Pathname"
    io_processor = mock "IoProcessor"
    
    io = StringIO.new "whatever"
    file.should_receive(:open).and_yield io
    io_processor.should_receive(:process).with(io)
    
    accessor.open_and_handle_with(file, io_processor)
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rspec-0.9.2 examples/file_accessor_spec.rb
rspec-0.9.0 examples/file_accessor_spec.rb
rspec-0.9.1 examples/file_accessor_spec.rb
rspec-0.9.3 examples/file_accessor_spec.rb
rspec-0.9.4 examples/file_accessor_spec.rb
rspec-1.0.0 examples/file_accessor_spec.rb
rspec-1.0.1 examples/file_accessor_spec.rb
rspec-1.0.2 examples/file_accessor_spec.rb
rspec-1.0.3 examples/file_accessor_spec.rb
rspec-1.0.4 examples/file_accessor_spec.rb