You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
1.8 KiB
Ruby
82 lines
1.8 KiB
Ruby
11 years ago
|
describe BrushDecorator do
|
||
|
let(:decorator) { described_class.new(brush) }
|
||
11 years ago
|
let(:brush) { double('brush', :fg => nil, :bg => nil, :bold? => false,
|
||
11 years ago
|
:underline? => false) }
|
||
11 years ago
|
|
||
11 years ago
|
describe '#css_class' do
|
||
|
subject { decorator.css_class }
|
||
11 years ago
|
|
||
|
context "when brush is a default one" do
|
||
|
before do
|
||
|
allow(brush).to receive(:default?) { true }
|
||
|
end
|
||
|
|
||
|
it { should be(nil) }
|
||
|
end
|
||
|
|
||
|
context "when brush is not a default one" do
|
||
|
before do
|
||
|
allow(brush).to receive(:default?) { false }
|
||
|
end
|
||
|
|
||
|
context "when fg is default" do
|
||
|
before do
|
||
|
allow(brush).to receive(:fg) { nil }
|
||
|
end
|
||
|
|
||
|
it { should_not match(/\bfg/) }
|
||
|
end
|
||
|
|
||
|
context "when fg is non-default" do
|
||
|
before do
|
||
|
allow(brush).to receive(:fg) { 1 }
|
||
|
end
|
||
|
|
||
|
it { should match(/\bfg1\b/) }
|
||
|
end
|
||
|
|
||
|
context "when bg is default" do
|
||
|
before do
|
||
|
allow(brush).to receive(:bg) { nil }
|
||
|
end
|
||
|
|
||
|
it { should_not match(/\bbg/) }
|
||
|
end
|
||
|
|
||
|
context "when bg is non-default" do
|
||
|
before do
|
||
|
allow(brush).to receive(:bg) { 2 }
|
||
|
end
|
||
|
|
||
|
it { should match(/\bbg2\b/) }
|
||
|
end
|
||
|
|
||
|
context "when both fg and bg are non-default" do
|
||
|
before do
|
||
|
allow(brush).to receive(:fg) { 1 }
|
||
|
allow(brush).to receive(:bg) { 2 }
|
||
|
end
|
||
|
|
||
|
it { should match(/\bfg1\b/) }
|
||
|
it { should match(/\bbg2\b/) }
|
||
|
end
|
||
|
|
||
|
context "when it's bold" do
|
||
|
before do
|
||
|
allow(brush).to receive(:bold?) { true }
|
||
|
end
|
||
|
|
||
11 years ago
|
it { should match(/\bbright\b/) }
|
||
11 years ago
|
end
|
||
|
|
||
|
context "when it's underline" do
|
||
|
before do
|
||
|
allow(brush).to receive(:underline?) { true }
|
||
|
end
|
||
|
|
||
|
it { should match(/\bunderline\b/) }
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|