Sha256: 16df81ddf44c7b2a5c93a04ce5b56867d03c8f26a71970883df21107c3cb4938

Contents?: true

Size: 1.46 KB

Versions: 3

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 attributes" 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 attributes" 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

3 entries across 3 versions & 2 rubygems

Version Path
onix-0.8.4 spec/audience_range_spec.rb
milkfarm-onix-0.8.6 spec/audience_range_spec.rb
milkfarm-onix-0.8.5 spec/audience_range_spec.rb