Sha256: 1cebb3ddc1f614221ee3a371f52081a1532446089b47f84bc394970b22cea171

Contents?: true

Size: 1.46 KB

Versions: 5

Compression:

Stored size: 1.46 KB

Contents

# coding: utf-8

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

context "ONIX::AudienceRange" do

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

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

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

    aud.audience_range_qualifier.should eql(11)
    aud.audience_range_precisions.size.should eql(2)
    aud.audience_range_precisions[0].should eql(3)
    aud.audience_range_precisions[1].should eql(4)
    aud.audience_range_values.size.should eql(2)
    aud.audience_range_values[0].should eql(3)
    aud.audience_range_values[1].should eql(5)
  end

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

    aud.audience_range_qualifier = 12
    aud.to_xml.to_s.include?("<AudienceRangeQualifier>12</AudienceRangeQualifier>").should be_true

    aud.audience_range_precisions[0] = 888
    aud.to_xml.to_s.include?("<AudienceRangePrecision>888</AudienceRangePrecision>").should be_true

    aud.audience_range_values[0] = 999
    aud.to_xml.to_s.include?("<AudienceRangeValue>999</AudienceRangeValue>").should be_true
  end

end

Version data entries

5 entries across 5 versions & 2 rubygems

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