method

puts

Importance_1
Ruby latest stable (v1_8_6_287) - 1 note - Class: Kernel
puts(...) public

Equivalent to

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

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