require 'rspec' require 'nokogiri' $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) require 'ncs_navigator/mdes' RSpec.configure do |config| def logger @logger ||= NcsNavigator::Mdes::Spec::AccumulatingLogger.new end ## # Returns a parsed XML element whose root ancestor is an appropriate # schema root. # # @param [String] xml_fragment def schema_element(xml_fragment) Nokogiri::XML(<<-XSD).root.elements.first #{xml_fragment} XSD end end module NcsNavigator::Mdes module Spec ## # A logger that holds on to everything that is logged for later examination. class AccumulatingLogger def messages @messages ||= {} end def [](name) messages[name] ||= [] end def method_missing(name, *args) self[name] << (args.size == 1 ? args.first : args) true # what Logger does end end end end