diff --git a/lib/vedeu/models/views/line.rb b/lib/vedeu/models/views/line.rb index 69f8daa34..d64c033b1 100644 --- a/lib/vedeu/models/views/line.rb +++ b/lib/vedeu/models/views/line.rb @@ -86,6 +86,11 @@ def eql?(other) end alias_method :==, :eql? + # @return [NilClass|String|Symbol] + def name + parent.name if parent + end + # Returns the size of the content in characters without # formatting. # diff --git a/lib/vedeu/models/views/stream.rb b/lib/vedeu/models/views/stream.rb index 3009feb4f..ce3b8e32f 100644 --- a/lib/vedeu/models/views/stream.rb +++ b/lib/vedeu/models/views/stream.rb @@ -71,6 +71,7 @@ def chars @chars ||= value.chars.map do |char| member.new(value: char, + name: name, parent: parent, colour: colour, style: style, @@ -101,6 +102,11 @@ def eql?(other) end alias_method :==, :eql? + # @return [NilClass|String|Symbol] + def name + parent.name if parent + end + # Returns the size of the content in characters without # formatting. # diff --git a/test/lib/vedeu/models/views/line_test.rb b/test/lib/vedeu/models/views/line_test.rb index 2960fa92e..28f320bb2 100644 --- a/test/lib/vedeu/models/views/line_test.rb +++ b/test/lib/vedeu/models/views/line_test.rb @@ -122,6 +122,20 @@ module Views end end + describe '#name' do + subject { instance.name } + + context 'when a parent is set' do + it { subject.must_equal('Vedeu::Line') } + end + + context 'when a parent is not set' do + let(:parent) {} + + it { subject.must_equal(nil) } + end + end + describe '#size' do subject { instance.size } diff --git a/test/lib/vedeu/models/views/stream_test.rb b/test/lib/vedeu/models/views/stream_test.rb index 9e4dfda51..5d0f53a13 100644 --- a/test/lib/vedeu/models/views/stream_test.rb +++ b/test/lib/vedeu/models/views/stream_test.rb @@ -115,6 +115,20 @@ module Views end end + describe '#name' do + subject { instance.name } + + context 'when a parent is set' do + it { subject.must_equal('Vedeu::Views::Stream') } + end + + context 'when a parent is not set' do + let(:parent) {} + + it { subject.must_equal(nil) } + end + end + describe '#size' do subject { instance.size }