Sha256: e4c2531d3d539bf99d6517a622354ec1eeea88244efe6985fc14825cb1e325a2

Contents?: true

Size: 1.43 KB

Versions: 6

Compression:

Stored size: 1.43 KB

Contents

describe DMark::ElementNode do
  let(:element_node) { described_class.new(name, attributes, children) }

  let(:name) { 'para' }
  let(:attributes) { {} }
  let(:children) { ['Hello!'] }

  describe '#inspect' do
    subject { element_node.inspect }

    context 'no attributes' do
      let(:attributes) { {} }

      it { is_expected.to eql('Element(para, ["Hello!"])') }
    end

    context 'attributes' do
      let(:attributes) { { 'only' => 'web' } }

      it { is_expected.to eql('Element(para, {"only"=>"web"}, ["Hello!"])') }
    end
  end

  describe '#==' do
    subject { element_node == other }

    context 'other is not an element node' do
      let(:other) { 'donkey' }
      it { is_expected.to be false }
    end

    context 'other is an element node' do
      context 'other does not differ' do
        let(:other) { described_class.new(name, attributes, children) }
        it { is_expected.to be true }
      end

      context 'other differs in name' do
        let(:other) { described_class.new('giraffe', attributes, children) }
        it { is_expected.to be false }
      end

      context 'other differs in attributes' do
        let(:other) { described_class.new(name, { 'friend' => 'donkey' }, children) }
        it { is_expected.to be false }
      end

      context 'other differs in children' do
        let(:other) { described_class.new(name, attributes, []) }
        it { is_expected.to be false }
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
d-mark-1.0.0b2 spec/d-mark/element_node_spec.rb
d-mark-1.0.0b1 spec/d-mark/element_node_spec.rb
d-mark-1.0.0a4 spec/d-mark/element_node_spec.rb
d-mark-1.0.0a3 spec/d-mark/element_node_spec.rb
d-mark-1.0.0a2 spec/d-mark/element_node_spec.rb
d-mark-1.0.0a1 spec/d-mark/element_node_spec.rb