Sha256: b10906b0da58cb0252c42f6f3689b2c736f591b72745f49173601e731abba394

Contents?: true

Size: 1.57 KB

Versions: 27

Compression:

Stored size: 1.57 KB

Contents

require 'examples/passing/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

27 entries across 27 versions & 10 rubygems

Version Path
rspec-instructure-1.3.3 examples/passing/file_accessor_spec.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/rspec-1.3.2/examples/passing/file_accessor_spec.rb
rspec-1.3.2 examples/passing/file_accessor_spec.rb
rspec-1.3.1 examples/passing/file_accessor_spec.rb
rspec-1.3.1.rc examples/passing/file_accessor_spec.rb
rspec-1.3.0 examples/passing/file_accessor_spec.rb
simple-templater-0.0.1.4 gems/gems/rspec-1.2.9/examples/passing/file_accessor_spec.rb
media-path-0.1.2 vendor/rspec/examples/passing/file_accessor_spec.rb
simple-templater-0.0.1.3 vendor/rspec/examples/passing/file_accessor_spec.rb
pupu-0.0.2.pre vendor/rspec/examples/passing/file_accessor_spec.rb
media-path-0.1.1.pre vendor/rspec/examples/passing/file_accessor_spec.rb
simple-templater-0.0.1.2 vendor/rspec/examples/passing/file_accessor_spec.rb
media-path-0.1.1 vendor/rspec/examples/passing/file_accessor_spec.rb
simple-templater-0.0.1.1 vendor/rspec/examples/passing/file_accessor_spec.rb
pupu-0.0.2 vendor/rspec/examples/passing/file_accessor_spec.rb
rango-0.0.6 vendor/rspec/examples/passing/file_accessor_spec.rb
rango-0.1.pre vendor/rspec/examples/passing/file_accessor_spec.rb
pupu-0.0.1 vendor/rspec/examples/passing/file_accessor_spec.rb
media-path-0.1 vendor/rspec/examples/passing/file_accessor_spec.rb
simple-templater-0.0.1 vendor/rspec/examples/passing/file_accessor_spec.rb