1
0
Fork 0
mirror of https://github.com/awesome-print/awesome_print synced 2023-03-27 23:22:34 -04:00
awesome_print/spec/core_ext/string_spec.rb
2011-11-23 21:27:47 -08:00

20 lines
735 B
Ruby

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "String extensions" do
[ :gray, :red, :green, :yellow, :blue, :purple, :cyan, :white ].each_with_index do |color, i|
it "should have #{color} color" do
color.to_s.send(color).should == "\e[1;#{30+i}m#{color}\e[0m"
end
it "should have #{color}ish color" do
color.to_s.send(:"#{color}ish").should == "\e[0;#{30+i}m#{color}\e[0m"
end
end
it "should have black and pale colors" do
"black".send(:black).should == "black".send(:grayish)
"pale".send(:pale).should == "pale".send(:whiteish)
"pale".send(:pale).should == "\e[0;37mpale\e[0m"
"whiteish".send(:whiteish).should == "\e[0;37mwhiteish\e[0m"
end
end