require 'test_helper' module Vedeu describe HTMLChar do let(:described) { Vedeu::HTMLChar } let(:instance) { described.new(char) } let(:char) { Vedeu::Char.new(attributes) } let(:attributes) { { border: border, colour: colour, parent: parent, value: _value } } let(:border) {} let(:colour) {} let(:parent) { Vedeu::Line.new(colour: parent_colour) } let(:parent_colour) {} let(:_value) {} describe '#initialize' do it { instance.must_be_instance_of(Vedeu::HTMLChar) } it { instance.instance_variable_get('@char').must_equal(char) } end describe '.render' do subject { described.render(char) } it { subject.must_be_instance_of(String) } context 'when there is a border' do let(:border) { :top_left } context 'when there is a colour' do let(:colour) { Vedeu::Colour.new(background: '#220022', foreground: '#aadd00') } it { subject.must_equal( " " ) } end context 'when there is no colour' do context 'when there is a parent colour' do let(:parent_colour) { Vedeu::Colour.new(background: '#002222', foreground: '#dd2200') } it { subject.must_equal( " " ) } end context 'when there is no parent colour' do it { subject.must_equal( "" \ " " ) } end end end grey = '1px #222 solid' { top_horizontal: "border-top:#{grey};", left_vertical: "border-left:#{grey};", right_vertical: "border-right:#{grey};", bottom_horizontal: "border-bottom:#{grey};", top_left: "border-top:#{grey};border-left:#{grey};", top_right: "border-top:#{grey};border-right:#{grey};", bottom_left: "border-bottom:#{grey};border-left:#{grey};", bottom_right: "border-bottom:#{grey};border-right:#{grey};", horizontal: '', vertical: '' }.each do |border_style, result| context "when there is a border (#{border_style.inspect})" do let(:border) { border_style } it { subject.must_equal( " " ) } end end context 'when there is no border' do context 'when there is no value' do it { subject.must_equal(' ') } end context 'when the value is empty' do let(:_value) { '' } it { subject.must_equal(' ') } end context 'when there is a value' do let(:_value) { 'a' } it { subject.must_equal( "a" ) } end end end end # HTMLChar end # Vedeu