module AnsiColor describe "print" do it "print the original string with no options" do capture_stdout do |stdout| AnsiColor.print('james') stdout.string.should == 'james' end end it "print non string objects with no options" do capture_stdout do |stdout| AnsiColor.print(234) stdout.string.should == '234' end end it "red and bold on non string object" do capture_stdout do |stdout| AnsiColor.print(42, :color => :red, :effects => :bold) stdout.string.should == "#{E}31;1m42#{E}0m" end end it "print many args with no options" do capture_stdout do |stdout| AnsiColor.print(1, ' string ', 2) stdout.string.should == "1 string 2" end end it "print many args in red and bold" do capture_stdout do |stdout| AnsiColor.print(1, ' string ', 2, :color => :red, :effects => :bold) stdout.string.should == "#{E}31;1m1 string 2#{E}0m" end end it "red and bold" do capture_stdout do |stdout| AnsiColor.print('james', :color => :red, :effects => :bold) stdout.string.should == "#{E}31;1mjames#{E}0m" end end it "blue on white blinking" do capture_stdout do |stdout| AnsiColor.print('james', :color => :blue, :background => :white, :effects => :blink) stdout.string.should == "#{E}34;47;5mjames#{E}0m" end end end describe "puts" do it "print the original string with no options" do capture_stdout do |stdout| AnsiColor.puts('james') stdout.string.should == "james\n" end end it "print some number with no options" do capture_stdout do |stdout| AnsiColor.puts(243) stdout.string.should == "243\n" end end it "red and bold" do capture_stdout do |stdout| AnsiColor.puts('james', :color => :red, :effects => :bold) stdout.string.should == "#{E}31;1mjames#{E}0m\n" end end it "blue on white blinking" do capture_stdout do |stdout| AnsiColor.puts('james', :color => :blue, :background => :white, :effects => :blink) stdout.string.should == "#{E}34;47;5mjames#{E}0m\n" end end end end