Sha256: af346f213c5bb6fc1f56d8ef1edeea3582400c6a4a34fbc063fd9c0b44685375

Contents?: true

Size: 780 Bytes

Versions: 12

Compression:

Stored size: 780 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 XmlMapper

      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

12 entries across 12 versions & 1 rubygems

Version Path
xmlmapper-0.8.1 spec/attributes_spec.rb
xmlmapper-0.8.0 spec/attributes_spec.rb
xmlmapper-0.7.3 spec/attributes_spec.rb
xmlmapper-0.7.2 spec/attributes_spec.rb
xmlmapper-0.7.1 spec/attributes_spec.rb
xmlmapper-0.7.0 spec/attributes_spec.rb
xmlmapper-0.6.5 spec/attributes_spec.rb
xmlmapper-0.6.4 spec/attributes_spec.rb
xmlmapper-0.6.3 spec/attributes_spec.rb
xmlmapper-0.6.2 spec/attributes_spec.rb
xmlmapper-0.6.1 spec/attributes_spec.rb
xmlmapper-0.6.0 spec/attributes_spec.rb