Sha256: 554978b43a4dbc4ac6e0f5ec7f1361b2132a0802ccb23037a0e64b81747327e7

Contents?: true

Size: 1.11 KB

Versions: 5

Compression:

Stored size: 1.11 KB

Contents

# coding: utf-8

require File.dirname(__FILE__) + '/spec_helper.rb'

context "ONIX::Measure" do

  before(:each) do
    data_path = File.join(File.dirname(__FILE__),"..","data")
    file1    = File.join(data_path, "measure.xml")
    @doc     = Nokogiri::XML::Document.parse(File.read(file1))
    @root = @doc.root
  end

  specify "should correctly convert to a string" do
    m = ONIX::Measure.from_xml(@root.to_s)
    m.to_xml.to_s[0,9].should eql("<Measure>")
  end

  specify "should provide read access to first level attibutes" do
    m = ONIX::Measure.from_xml(@root.to_s)

    m.measure_type_code.should eql(1)
    m.measurement.should eql(210)
    m.measure_unit_code.should eql("mm")
  end

  specify "should provide write access to first level attibutes" do
    m = ONIX::Measure.new

    m.measure_type_code = 1
    m.to_xml.to_s.include?("<MeasureTypeCode>01</MeasureTypeCode>").should be_true

    m.measurement = 300
    m.to_xml.to_s.include?("<Measurement>300</Measurement>").should be_true

    m.measure_unit_code = "mm"
    m.to_xml.to_s.include?("<MeasureUnitCode>mm</MeasureUnitCode>").should be_true
  end

end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
onix-0.8.3 spec/measure_spec.rb
milkfarm-onix-0.8.3 spec/measure_spec.rb
onix-0.8.2 spec/measure_spec.rb
onix-0.8.1 spec/measure_spec.rb
onix-0.8.0 spec/measure_spec.rb