Sha256: c3bc8b16d347928cb91be1b0b1e50d1ac02dcc764e9e64b97c99a378b23a6360

Contents?: true

Size: 838 Bytes

Versions: 1

Compression:

Stored size: 838 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'parsing the same tag differently in different contexts', type: :feature do
  module SameTagSpec
    class Bar
      include HappyMapper
      has_one :baz, String
    end

    class Baz
      include HappyMapper
      has_one :qux, String
    end

    class Foo
      include HappyMapper
      has_one :bar, Bar
      has_one :baz, Baz, xpath: '.'
    end
  end

  let(:xml) do
    <<~XML
      <foo>
        <bar>
          <baz>Hello</baz>
        </bar>
        <baz>
          <qux>Hi</qux>
        </baz>
      </foo>
    XML
  end

  it 'parses both uses correctly if xpath limits recursion' do
    result = SameTagSpec::Foo.parse xml
    aggregate_failures do
      expect(result.bar.baz).to eq 'Hello'
      expect(result.baz.qux).to eq 'Hi'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nokogiri-happymapper-0.8.1 spec/features/same_tag_different_meaning_spec.rb