# 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("") 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?("12").should be_true aud.audience_range_precisions[0] = 888 aud.to_xml.to_s.include?("888").should be_true aud.audience_range_values[0] = 999 aud.to_xml.to_s.include?("999").should be_true end end