Sha256: b04388b3dec0f9d82df315322f862c373379308fd6ad91451bfe376632c55850

Contents?: true

Size: 1.63 KB

Versions: 117

Compression:

Stored size: 1.63 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

117 entries across 117 versions & 14 rubygems

Version Path
dchelimsky-rspec-1.1.10 examples/pure/file_accessor_spec.rb
dchelimsky-rspec-1.1.11.1 examples/passing/file_accessor_spec.rb
dchelimsky-rspec-1.1.11.2 examples/passing/file_accessor_spec.rb
dchelimsky-rspec-1.1.11.3 examples/passing/file_accessor_spec.rb
dchelimsky-rspec-1.1.11.4 examples/passing/file_accessor_spec.rb
dchelimsky-rspec-1.1.11.5 examples/passing/file_accessor_spec.rb
dchelimsky-rspec-1.1.11.6 examples/passing/file_accessor_spec.rb
dchelimsky-rspec-1.1.11.7 examples/passing/file_accessor_spec.rb
dchelimsky-rspec-1.1.11 examples/passing/file_accessor_spec.rb
dchelimsky-rspec-1.1.12 examples/passing/file_accessor_spec.rb
dchelimsky-rspec-1.1.99.1 examples/passing/file_accessor_spec.rb
dchelimsky-rspec-1.1.99.13 examples/passing/file_accessor_spec.rb
dchelimsky-rspec-1.1.99.2 examples/passing/file_accessor_spec.rb
dchelimsky-rspec-1.1.99.3 examples/passing/file_accessor_spec.rb
dchelimsky-rspec-1.1.99.4 examples/passing/file_accessor_spec.rb
dchelimsky-rspec-1.1.99.5 examples/passing/file_accessor_spec.rb
dchelimsky-rspec-1.1.99.6 examples/passing/file_accessor_spec.rb
dchelimsky-rspec-1.1.99.7 examples/passing/file_accessor_spec.rb
dchelimsky-rspec-1.1.99.8 examples/passing/file_accessor_spec.rb
dchelimsky-rspec-1.1.99.9 examples/passing/file_accessor_spec.rb