Sha256: 3471dc3124795b23928a573c4a78d5b05ed545600e8f83908085e4171b2e8ea4

Contents?: true

Size: 750 Bytes

Versions: 76

Compression:

Stored size: 750 Bytes

Contents

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

class MessageAppender
  
  def initialize(appendage)
    @appendage = appendage
  end
  
  def append_to(message)
    if_told_to_yield do
      message << @appendage
    end
  end
    
end

describe "a message expectation yielding to a block" do
  it "should yield if told to" do
    appender = MessageAppender.new("appended to")
    appender.should_receive(:if_told_to_yield).and_yield
    message = ""
    appender.append_to(message)
    message.should == "appended to"
  end

  it "should not yield if not told to" do
    appender = MessageAppender.new("appended to")
    appender.should_receive(:if_told_to_yield)
    message = ""
    appender.append_to(message)
    message.should == ""
  end
end

Version data entries

76 entries across 76 versions & 10 rubygems

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