0
@@ -2,6 +2,14 @@ require File.dirname(__FILE__) + '/../../spec_helper'
0
require File.dirname(__FILE__) + '/fixtures/classes'
0
+ @rs_f, @rs_b, @rs_c = $/, $\, $,
0
+ $/, $\, $, = @rs_f, @rs_b, @rs_c
0
it "is a private method" do
0
Kernel.private_instance_methods.should include("p")
0
@@ -27,6 +35,38 @@ describe "Kernel#p" do
0
+ it "prints obj.inspect followed by system record separator (usually \\n) for each argument given" do
0
+ o = mock("Inspector Gadget")
0
+ o.should_receive(:inspect).any_number_of_times.and_return "Next time, Gadget, NEXT TIME!"
0
+ lambda { p(o) }.should output("Next time, Gadget, NEXT TIME!\n")
0
+ lambda { p(*[o]) }.should output("Next time, Gadget, NEXT TIME!\n")
0
+ lambda { p(*[o, o]) }.should output("Next time, Gadget, NEXT TIME!\nNext time, Gadget, NEXT TIME!\n")
0
+ lambda { p([o])}.should output("[#{o.inspect}]\n")
0
+ it "is not affected by setting $\\, $/ or $," do
0
+ o = mock("Inspector Gadget")
0
+ o.should_receive(:inspect).any_number_of_times.and_return "Next time, Gadget, NEXT TIME!"
0
+ $, = " *helicopter sound*\n"
0
+ lambda { p(o) }.should output_to_fd("Next time, Gadget, NEXT TIME!\n")
0
+ $\ = " *helicopter sound*\n"
0
+ lambda { p(o) }.should output_to_fd("Next time, Gadget, NEXT TIME!\n")
0
+ $/ = " *helicopter sound*\n"
0
+ lambda { p(o) }.should output_to_fd("Next time, Gadget, NEXT TIME!\n")
0
+ it "prints nothing if no argument is given" do
0
+ lambda { p }.should output("")
0
+ it "prints nothing if called splatting an empty Array" do
0
+ lambda { p(*[]) }.should output("")
0
=begin Not sure how to spec this, but wanted to note the behavior here
0
it "does not flush if receiver is not a TTY or a File" do
Comments
No one has commented yet.