test/lib/vedeu/colours/colour_test.rb in vedeu-0.7.4 vs test/lib/vedeu/colours/colour_test.rb in vedeu-0.8.0
- old
+ new
@@ -17,12 +17,44 @@
let(:background) {}
let(:foreground) {}
describe '#initialize' do
it { instance.must_be_instance_of(described) }
- it { instance.instance_variable_get('@background').must_equal(background)}
- it { instance.instance_variable_get('@foreground').must_equal(foreground)}
+
+ context 'when a background is given' do
+ let(:background) { '#ff0000' }
+
+ it do
+ instance.instance_variable_get('@background').must_equal(background)
+ end
+ end
+
+ context 'when a background is not given' do
+ let(:background) {}
+ let(:expected) { Vedeu::Colours::Background.new }
+
+ it do
+ instance.instance_variable_get('@background').must_equal(expected)
+ end
+ end
+
+ context 'when a foreground is given' do
+ let(:foreground) { '#ff00ff' }
+
+ it do
+ instance.instance_variable_get('@foreground').must_equal(foreground)
+ end
+ end
+
+ context 'when a foreground is not given' do
+ let(:foreground) {}
+ let(:expected) { Vedeu::Colours::Foreground.new }
+
+ it do
+ instance.instance_variable_get('@foreground').must_equal(expected)
+ end
+ end
end
describe '.coerce' do
let(:attributes) {
{
@@ -171,13 +203,31 @@
it { subject.must_be_instance_of(Hash) }
it { subject.must_equal(expected) }
end
describe '#background' do
+ subject { instance.background }
+
+ it { subject.must_be_instance_of(Vedeu::Colours::Background) }
+
# @todo Add more tests.
end
+ describe '#background?' do
+ subject { instance.background? }
+
+ context 'when the background is set' do
+ let(:background) { '#ff0000' }
+
+ it { subject.must_equal(true) }
+ end
+
+ context 'when the background is not set' do
+ it { subject.must_equal(false) }
+ end
+ end
+
describe '#background=' do
let(:_value) { '#000000' }
subject { instance.public_send(:background=, _value) }
@@ -196,11 +246,33 @@
it { subject.must_equal(false) }
end
end
+ describe '#==' do
+ it { instance.must_respond_to(:==) }
+ end
+
describe '#foreground' do
+ subject { instance.foreground }
+
+ it { subject.must_be_instance_of(Vedeu::Colours::Foreground) }
+
# @todo Add more tests.
+ end
+
+ describe '#foreground?' do
+ subject { instance.foreground? }
+
+ context 'when the foreground is set' do
+ let(:foreground) { '#ff00ff' }
+
+ it { subject.must_equal(true) }
+ end
+
+ context 'when the foreground is not set' do
+ it { subject.must_equal(false) }
+ end
end
describe '#foreground=' do
let(:_value) { '#ff0000' }