Sha256: 91100c1c9e419f4850cae6b2a7b4d90a9636c567fec5150b217700983b2ebfeb

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

require_relative './../spec_helper'
require_relative './../../examples/library_with_fines'

describe LibraryWithFines do

  let(:xml) { File.read(xml_for('library_with_fines')) }
  let(:library) { LibraryWithFines.from_xml(xml) }

  it "should read nested elements" do
    library.fines.should be_a(Hash)
    library.fines.size == 3
    library.fines.should have_key('talking')
    library.fines['talking'].should match(/Stop asking/)
  end

  class String
    def remove_whitespace
      self.gsub(/\s{2,}/, '').gsub("\n", '')
    end
  end

  it "should write deeply nested elements" do
    xml_out = library.to_xml.to_s
    xml_out.remove_whitespace.should == xml.remove_whitespace
  end

  it "should write two children of library: name and policy" do
    library.to_xml.children.map{|e| e.name }.should == ['name', 'policy']
  end

  it "should be re-parsable via .from_xml" do
    lib_reparsed = LibraryWithFines.from_xml(library.to_xml.to_s)
    lib_reparsed.name.should == library.name
    lib_reparsed.fines.should == library.fines
  end


end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
roxml-3.3.1 spec/examples/library_with_fines_spec.rb
roxml-3.3.0 spec/examples/library_with_fines_spec.rb
roxml-3.2.2 spec/examples/library_with_fines_spec.rb
roxml-3.2.1 spec/examples/library_with_fines_spec.rb
roxml-3.2.0 spec/examples/library_with_fines_spec.rb