Sha256: e9b3305c277deb3802547881afe365b9375b4d9356f4ad213c93f60ce3d743d6

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require example('active_record')

describe ROXML, "under ActiveRecord" do
  before do
    @route = Route.from_xml(xml_for('active_record'))
  end

  after(:all) do
    db = File.dirname(__FILE__) + "/../../examples/active_record/active_record.sqlite3"
    if File.exists?(db)
      FileUtils.rm(db)
    end
  end

  it "should be parsed" do
    @route.should_not == nil
    @route.should be_an_instance_of(Route)
  end

  describe "xml attributes" do
    it "should extract xml attributes" do
      @route.totalHg.should == "640"
      @route.lonlatx.should == "357865"
      @route.lonlaty.should == "271635"
      @route.grcenter.should == "SH 71635 57865"
      @route.totalMins.should == "235.75000000000003"
      @route.totalDist.should == "11185.321521477119"
    end
  end

  describe "xml sub-objects" do
    it "should extract xml sub-objects" do
      @route.should have(6).waypoints
      @route.waypoints.each {|waypoint| waypoint.should be_an_instance_of(Waypoint)}
    end
    it "should be usable as a ActiveRecord object" do
      Waypoint.count.should == 0
      @route.save!
      Waypoint.count.should == 6
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
roxml-2.5.0 spec/examples/active_record_spec.rb