puts(...) public

Equivalent to

    $stdout.puts(obj, ...)
Show source
Register or log in to add new notes.
October 23, 2008
1 thank

Mocking puts from RSpec

If you want to mock calls to puts from RSpec, do it from the class/module you are in:

module Foo
  def self.foo
    puts "hello"
  end
end

describe Foo do
  it "should write 'hello' when foo() is called" do
    Foo.should_receive(:puts).with("hello")  # Kernel and Object don't work in this case...
    Foo.foo
  end
end