2014-12-31 15:59:32 -05:00
|
|
|
require 'spec_helper'
|
2010-04-03 00:43:46 -04:00
|
|
|
|
2016-11-08 00:07:03 -05:00
|
|
|
RSpec.describe 'String extensions' do
|
2016-11-08 21:39:25 -05:00
|
|
|
[:gray, :red, :green, :yellow, :blue, :purple, :cyan, :white].each_with_index do |color, i|
|
2010-04-03 00:43:46 -04:00
|
|
|
it "should have #{color} color" do
|
2016-11-08 21:39:25 -05:00
|
|
|
expect(color.to_s.send(color)).to eq("\e[1;#{30 + i}m#{color}\e[0m")
|
2010-04-03 00:43:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should have #{color}ish color" do
|
2016-11-08 21:39:25 -05:00
|
|
|
expect(color.to_s.send(:"#{color}ish")).to eq("\e[0;#{30 + i}m#{color}\e[0m")
|
2010-04-03 00:43:46 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-11-08 00:07:03 -05:00
|
|
|
it 'should have black and pale colors' do
|
|
|
|
expect('black'.send(:black)).to eq('black'.send(:grayish))
|
2016-11-08 21:39:25 -05:00
|
|
|
expect('pale'.send(:pale)).to eq('pale'.send(:whiteish))
|
2016-11-08 00:07:03 -05:00
|
|
|
expect('pale'.send(:pale)).to eq("\e[0;37mpale\e[0m")
|
|
|
|
expect('whiteish'.send(:whiteish)).to eq("\e[0;37mwhiteish\e[0m")
|
2010-04-03 00:43:46 -04:00
|
|
|
end
|
|
|
|
end
|