File: spec_helper.rb

package info (click to toggle)
ruby-roxml 3.3.1-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 772 kB
  • ctags: 532
  • sloc: ruby: 4,066; xml: 1,013; makefile: 6
file content (25 lines) | stat: -rw-r--r-- 589 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
require 'ostruct'
require 'pathname'
require 'ostruct'
require 'roxml'
require 'rspec'

require_relative './../test/support/fixtures'
require_relative './shared_specs'

def xml_for(name)
  Pathname.new(File.dirname(__FILE__)).expand_path.dirname.join("examples/xml/#{name}.xml")
end

class RoxmlObject
  include ROXML
end

# returns an array representing the path  through first child of each element in the doc
def xml_path(xml, path = [])
  path << xml.name if xml.is_a?(Nokogiri::XML::Element)
  unless xml.children.empty?
    xml_path(xml.children.first, path)
  end
  return path
end