Skip to content

Commit

Permalink
Merging pull request #57
Browse files Browse the repository at this point in the history
  • Loading branch information
tjarratt committed Nov 10, 2016
1 parent a459e53 commit 954d002
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/gyoku/array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def self.iterate_with_xml(array, key, attributes, options, &block)
unwrap = unwrap?(options.fetch(:unwrap, false), key)

if unwrap
xml.tag!(key) { iterate_array(xml, array, attributes, &block) }
xml.tag!(key, attributes) { iterate_array(xml, array, attributes, &block) }
else
iterate_array(xml, array, attributes, &block)
end
Expand Down
11 changes: 11 additions & 0 deletions spec/gyoku/array_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@
expect(to_xml(array, "value", :escape_xml, :active => true)).to eq(result)
end

it "adds attributes to tags when :unwrap is true" do
array = [{:item=>"abc"}]
key = "items"
escape_xml = :escape_xml
attributes = { "amount"=>"1" }
options = { :unwrap => true }
result = "<items amount=\"1\"><item>abc</item></items>"

expect(to_xml(array, key, escape_xml, attributes, options)).to eq result
end

it "adds attributes to duplicate tags" do
array = ["adam", "eve"]
result = '<value id="1">adam</value><value id="2">eve</value>'
Expand Down

0 comments on commit 954d002

Please sign in to comment.