diff --git a/lib/oga.rb b/lib/oga.rb index 4bd80ec..bbaf0f0 100644 --- a/lib/oga.rb +++ b/lib/oga.rb @@ -25,6 +25,7 @@ require_relative 'oga/xml/cdata' require_relative 'oga/xml/xml_declaration' require_relative 'oga/xml/doctype' require_relative 'oga/xml/attribute' +require_relative 'oga/xml/namespace' require_relative 'oga/xml/node_set' require_relative 'oga/html/parser' diff --git a/lib/oga/xml/namespace.rb b/lib/oga/xml/namespace.rb index c23abd4..0309c72 100644 --- a/lib/oga/xml/namespace.rb +++ b/lib/oga/xml/namespace.rb @@ -24,6 +24,13 @@ module Oga def to_s return name.to_s end + + ## + # @return [String] + # + def inspect + return "Namespace(name: #{name.inspect})" + end end # Namespace end # XML end # Oga diff --git a/spec/oga/xml/namespace_spec.rb b/spec/oga/xml/namespace_spec.rb new file mode 100644 index 0000000..26f5f3c --- /dev/null +++ b/spec/oga/xml/namespace_spec.rb @@ -0,0 +1,23 @@ +require 'spec_helper' + +describe Oga::XML::Namespace do + context '#initialize' do + example 'set the name' do + described_class.new(:name => 'a').name.should == 'a' + end + end + + context '#to_s' do + example 'convert the Namespace to a String' do + described_class.new(:name => 'x').to_s.should == 'x' + end + end + + context '#inspect' do + example 'return the inspect value' do + ns = described_class.new(:name => 'x') + + ns.inspect.should == 'Namespace(name: "x")' + end + end +end