Sha256: 24409f8d655e2da83653a2a07b0e12ce0c6eb766f363ff406c0c69d7b9c522c9

Contents?: true

Size: 768 Bytes

Versions: 3

Compression:

Stored size: 768 Bytes

Contents

require 'spec_helper'

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

  module AttributeMethodConversion
    class Document
      include HappyMapper

      has_many :link, String, attributes: { 'data-src': String, type: String, href: String }
    end
  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

3 entries across 3 versions & 1 rubygems

Version Path
blockscore-happymapper-0.6.2 spec/attributes_spec.rb
blockscore-happymapper-0.6.1 spec/attributes_spec.rb
blockscore-happymapper-0.6.0 spec/attributes_spec.rb