Sha256: 0ff3bdb9b3baa5fd03712a4c688cf4e9bce48461a9d83a4f7ddfdf1683c425d0

Contents?: true

Size: 781 Bytes

Versions: 5

Compression:

Stored size: 781 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

5 entries across 5 versions & 3 rubygems

Version Path
nokogiri-happymapper-0.6.0 spec/attributes_spec.rb
xmlmapper-0.5.9 spec/attributes_spec.rb
instructure-happymapper-0.5.10 spec/attributes_spec.rb
nokogiri-happymapper-0.5.9 spec/attributes_spec.rb
nokogiri-happymapper-0.5.8 spec/attributes_spec.rb