Permalink
Browse files

Whitespace

  • Loading branch information...
Empact committed Feb 5, 2012
1 parent 23bdd45 commit 5b2ba896282ca6fdb75e7c997430637842855ef3
Showing with 34 additions and 35 deletions.
  1. +7 −8 lib/roxml/xml/references.rb
  2. +27 −27 spec/examples/person_spec.rb
@@ -90,26 +90,25 @@ def several?
def wrap(xml, opts = {:always_create => false})
wrap_with = @auto_vals ? auto_wrapper : wrapper
-
+
return xml if !wrap_with || xml.name == wrap_with
wraps = wrap_with.to_s.split('/')
- wraps.inject(xml) do |node,wrap|
- if !opts[:always_create] && (child = node.children.find {|c| c.name == wrap })
+ wraps.inject(xml) do |node,wrap|
+ if !opts[:always_create] && (child = node.children.find {|c| c.name == wrap })
child
else
- XML.add_node(node, wrap)
+ XML.add_node(node, wrap)
end
- end
-
+ end
end
def nodes_in(xml)
@default_namespace = XML.default_namespace(xml)
- vals = xml.roxml_search(xpath, @instance.class.roxml_namespaces)
+ vals = XML.search(xml, xpath, @instance.class.roxml_namespaces)
if several? && vals.empty? && !wrapper && auto_xpath
- vals = xml.roxml_search(auto_xpath, @instance.class.roxml_namespaces)
+ vals = XML.search(xml, auto_xpath, @instance.class.roxml_namespaces)
@auto_vals = !vals.empty?
end
@@ -2,36 +2,36 @@
require_relative './../../examples/person'
describe Person do
-
- before do
- @person = Person.new
- @person.name = 'John Doe'
- @person.lat = '40.715224'
- @person.long = '-74.005966'
- @person.street = 'Evergreen Terrace'
- @person.city = 'Springfield'
- @person.zip = '2342'
- end
- it 'should only contain one location element' do
- @person.to_xml.roxml_search('location').count.should == 1
- end
+ before do
+ @person = Person.new
+ @person.name = 'John Doe'
+ @person.lat = '40.715224'
+ @person.long = '-74.005966'
+ @person.street = 'Evergreen Terrace'
+ @person.city = 'Springfield'
+ @person.zip = '2342'
+ end
- describe '#to_xml' do
- before do
- @xml_generated = @person.to_xml.to_s.gsub("\n",'').squeeze(' ')
- end
+ it 'should only contain one location element' do
+ @person.to_xml.roxml_search('location').count.should == 1
+ end
- it 'should generate the expected xml' do
- xml_file = File.read(xml_for('person')).gsub("\n",'').squeeze(' ')
- xml_file.should == @xml_generated
- end
+ describe '#to_xml' do
+ before do
+ @xml_generated = @person.to_xml.to_s.gsub("\n",'').squeeze(' ')
+ end
- it 'should generate identical xml after a full roundtrip' do
- p = Person.from_xml(@xml_generated)
- xml_roundtrip = p.to_xml.to_s.gsub("\n",'').squeeze(' ')
- xml_roundtrip.should == @xml_generated
- end
- end
+ it 'should generate the expected xml' do
+ xml_file = File.read(xml_for('person')).gsub("\n",'').squeeze(' ')
+ xml_file.should == @xml_generated
+ end
+
+ it 'should generate identical xml after a full roundtrip' do
+ p = Person.from_xml(@xml_generated)
+ xml_roundtrip = p.to_xml.to_s.gsub("\n",'').squeeze(' ')
+ xml_roundtrip.should == @xml_generated
+ end
+ end
end

0 comments on commit 5b2ba89

Please sign in to comment.