Sha256: bae55c659d2613c070b1bc98ccf3fdb08f876412b80b014359b3daa7c7970df0

Contents?: true

Size: 799 Bytes

Versions: 1

Compression:

Stored size: 799 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

describe 'Attribute Method Conversion' do
  module AttributeMethodConversion
    class Document
      include HappyMapper

      has_many :link, String, attributes: { 'data-src': String, type: String, href: String }
    end
  end

  let(:xml_document) do
    %(<document>
        <link data-src='http://cooking.com/roastbeef' type='recipe'>Roast Beef</link>
      </document>)
  end

  let(:document) do
    AttributeMethodConversion::Document.parse(xml_document, single: true)
  end

  it 'link' do
    expect(document.link).to eq ['Roast Beef']
  end

  it 'link.data_src' do
    expect(document.link.first.data_src).to eq 'http://cooking.com/roastbeef'
  end

  it 'link.type' do
    expect(document.link.first.type).to eq 'recipe'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nokogiri-happymapper-0.8.0 spec/features/attributes_spec.rb