Sha256: ef54a200d73eb46798e70dfaf63301888073b74977d5276bbe88e7711141061a

Contents?: true

Size: 701 Bytes

Versions: 27

Compression:

Stored size: 701 Bytes

Contents

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

27 entries across 27 versions & 10 rubygems

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