Tests for various inspect methods.

This commit is contained in:
Yorick Peterse 2014-04-07 09:58:31 +02:00
parent 54ef125637
commit e9412c9c4e
7 changed files with 111 additions and 0 deletions

View File

@ -23,4 +23,14 @@ describe Oga::XML::Cdata do
@instance.to_xml.should == '<![CDATA[foo]]>'
end
end
context '#inspect' do
before do
@instance = described_class.new(:text => 'foo')
end
example 'pretty-print the node' do
@instance.inspect.should == 'Cdata(text: "foo")'
end
end
end

View File

@ -23,4 +23,14 @@ describe Oga::XML::Comment do
@instance.to_xml.should == '<!--foo-->'
end
end
context '#inspect' do
before do
@instance = described_class.new(:text => 'foo')
end
example 'pretty-print the node' do
@instance.inspect.should == 'Comment(text: "foo")'
end
end
end

View File

@ -46,4 +46,21 @@ describe Oga::XML::Doctype do
instance.to_xml.should == '<!DOCTYPE html PUBLIC "foo" "bar">'
end
end
context '#inspect' do
before do
@instance = described_class.new(:name => 'html', :type => 'PUBLIC')
end
example 'pretty-print the node' do
@instance.inspect.should == <<-EOF.strip
Doctype(
name: "html"
type: "PUBLIC"
public_id: nil
system_id: nil
)
EOF
end
end
end

View File

@ -81,4 +81,29 @@ describe Oga::XML::Document do
"\n<!DOCTYPE html PUBLIC>\n<!--foo-->"
end
end
context '#inspect' do
before do
@instance = described_class.new(
:doctype => Oga::XML::Doctype.new(:name => 'html'),
:children => [Oga::XML::Comment.new(:text => 'foo')]
)
end
example 'pretty-print the node' do
@instance.inspect.should == <<-EOF.strip
Document(
doctype: Doctype(
name: "html"
type: nil
public_id: nil
system_id: nil
)
xml_declaration: nil
children: [
Comment(text: "foo")
])
EOF
end
end
end

View File

@ -57,4 +57,27 @@ describe Oga::XML::Element do
instance.to_xml.should == '<p><!--foo--></p>'
end
end
context '#inspect' do
before do
children = [Oga::XML::Comment.new(:text => 'foo')]
@instance = described_class.new(
:name => 'p',
:children => children,
:attributes => {'class' => 'foo'}
)
end
example 'pretty-print the node' do
@instance.inspect.should == <<-EOF.strip
Element(
name: "p"
namespace: nil
attributes: {"class"=>"foo"}
children: [
Comment(text: "foo")
])
EOF
end
end
end

View File

@ -23,4 +23,14 @@ describe Oga::XML::Text do
@instance.to_xml.should == 'foo'
end
end
context '#inspect' do
before do
@instance = described_class.new(:text => 'foo')
end
example 'pretty-print the node' do
@instance.inspect.should == 'Text(text: "foo")'
end
end
end

View File

@ -42,4 +42,20 @@ describe Oga::XML::XmlDeclaration do
.should == '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>'
end
end
context '#inspect' do
before do
@instance = described_class.new(:version => '1.0')
end
example 'pretty-print the node' do
@instance.inspect.should == <<-EOF.strip
XmlDeclaration(
version: "1.0"
encoding: "UTF-8"
standalone: nil
)
EOF
end
end
end