Skip to content

Commit

Permalink
Update name
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Apr 30, 2024
1 parent 604b907 commit 940b8ae
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions spec/parser_shared_example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@

context "with CDATA" do
before do
@xml = "<user><![CDATA[Erik Michaels-Ober]]></user>"
@xml = "<user><![CDATA[Erik Berlin]]></user>"
end

it "returns the correct CDATA" do
expect(MultiXml.parse(@xml)["user"]).to eq("Erik Michaels-Ober")
expect(MultiXml.parse(@xml)["user"]).to eq("Erik Berlin")
end
end

Expand All @@ -81,31 +81,31 @@

context "with content" do
before do
@xml = "<user>Erik Michaels-Ober</user>"
@xml = "<user>Erik Berlin</user>"
end

it "returns the correct content" do
expect(MultiXml.parse(@xml)["user"]).to eq("Erik Michaels-Ober")
expect(MultiXml.parse(@xml)["user"]).to eq("Erik Berlin")
end
end

context "with an attribute" do
before do
@xml = '<user name="Erik Michaels-Ober"/>'
@xml = '<user name="Erik Berlin"/>'
end

it "returns the correct attribute" do
expect(MultiXml.parse(@xml)["user"]["name"]).to eq("Erik Michaels-Ober")
expect(MultiXml.parse(@xml)["user"]["name"]).to eq("Erik Berlin")
end
end

context "with multiple attributes" do
before do
@xml = '<user name="Erik Michaels-Ober" screen_name="sferik"/>'
@xml = '<user name="Erik Berlin" screen_name="sferik"/>'
end

it "returns the correct attributes" do
expect(MultiXml.parse(@xml)["user"]["name"]).to eq("Erik Michaels-Ober")
expect(MultiXml.parse(@xml)["user"]["name"]).to eq("Erik Berlin")
expect(MultiXml.parse(@xml)["user"]["screen_name"]).to eq("sferik")
end
end
Expand Down Expand Up @@ -143,12 +143,12 @@

context "with :symbolize_keys => true" do
before do
@xml = '<users><user name="Erik Michaels-Ober"/><user><name>Wynn Netherland</name></user></users>'
@xml = '<users><user name="Erik Berlin"/><user><name>Wynn Netherland</name></user></users>'
end

it "symbolizes keys" do
expect(MultiXml.parse(@xml,
symbolize_keys: true)).to eq(users: {user: [{name: "Erik Michaels-Ober"},
symbolize_keys: true)).to eq(users: {user: [{name: "Erik Berlin"},
{name: "Wynn Netherland"}]})
end
end
Expand Down Expand Up @@ -396,43 +396,43 @@

context 'with an attribute type="array"' do
before do
@xml = '<users type="array"><user>Erik Michaels-Ober</user><user>Wynn Netherland</user></users>'
@xml = '<users type="array"><user>Erik Berlin</user><user>Wynn Netherland</user></users>'
end

it "returns an Array" do
expect(MultiXml.parse(@xml)["users"]).to be_a(Array)
end

it "returns the correct array" do
expect(MultiXml.parse(@xml)["users"]).to eq(["Erik Michaels-Ober", "Wynn Netherland"])
expect(MultiXml.parse(@xml)["users"]).to eq(["Erik Berlin", "Wynn Netherland"])
end
end

context 'with an attribute type="array" in addition to other attributes' do
before do
@xml = '<users type="array" foo="bar"><user>Erik Michaels-Ober</user><user>Wynn Netherland</user></users>'
@xml = '<users type="array" foo="bar"><user>Erik Berlin</user><user>Wynn Netherland</user></users>'
end

it "returns an Array" do
expect(MultiXml.parse(@xml)["users"]).to be_a(Array)
end

it "returns the correct array" do
expect(MultiXml.parse(@xml)["users"]).to eq(["Erik Michaels-Ober", "Wynn Netherland"])
expect(MultiXml.parse(@xml)["users"]).to eq(["Erik Berlin", "Wynn Netherland"])
end
end

context 'with an attribute type="array" containing only one item' do
before do
@xml = '<users type="array"><user>Erik Michaels-Ober</user></users>'
@xml = '<users type="array"><user>Erik Berlin</user></users>'
end

it "returns an Array" do
expect(MultiXml.parse(@xml)["users"]).to be_a(Array)
end

it "returns the correct array" do
expect(MultiXml.parse(@xml)["users"]).to eq(["Erik Michaels-Ober"])
expect(MultiXml.parse(@xml)["users"]).to eq(["Erik Berlin"])
end
end

Expand Down Expand Up @@ -537,27 +537,27 @@
context "with children" do
context "with attributes" do
before do
@xml = '<users><user name="Erik Michaels-Ober"/></users>'
@xml = '<users><user name="Erik Berlin"/></users>'
end

it "returns the correct attributes" do
expect(MultiXml.parse(@xml)["users"]["user"]["name"]).to eq("Erik Michaels-Ober")
expect(MultiXml.parse(@xml)["users"]["user"]["name"]).to eq("Erik Berlin")
end
end

context "with text" do
before do
@xml = "<user><name>Erik Michaels-Ober</name></user>"
@xml = "<user><name>Erik Berlin</name></user>"
end

it "returns the correct text" do
expect(MultiXml.parse(@xml)["user"]["name"]).to eq("Erik Michaels-Ober")
expect(MultiXml.parse(@xml)["user"]["name"]).to eq("Erik Berlin")
end
end

context "with an unrecognized attribute type" do
before do
@xml = '<user type="admin"><name>Erik Michaels-Ober</name></user>'
@xml = '<user type="admin"><name>Erik Berlin</name></user>'
end

it "passes through the type" do
Expand Down Expand Up @@ -666,40 +666,40 @@
before do
@xml = <<-XML
<user>
<name>Erik Michaels-Ober</name>
<name>Erik Berlin</name>
</user>
XML
end

it "parses correctly" do
expect(MultiXml.parse(@xml)).to eq("user" => {"name" => "Erik Michaels-Ober"})
expect(MultiXml.parse(@xml)).to eq("user" => {"name" => "Erik Berlin"})
end
end

# Babies having babies
context "with children" do
before do
@xml = '<users><user name="Erik Michaels-Ober"><status text="Hello"/></user></users>'
@xml = '<users><user name="Erik Berlin"><status text="Hello"/></user></users>'
end

it "parses correctly" do
expect(MultiXml.parse(@xml)).to eq("users" => {"user" => {"name" => "Erik Michaels-Ober",
expect(MultiXml.parse(@xml)).to eq("users" => {"user" => {"name" => "Erik Berlin",
"status" => {"text" => "Hello"}}})
end
end
end

context "with sibling children" do
before do
@xml = "<users><user>Erik Michaels-Ober</user><user>Wynn Netherland</user></users>"
@xml = "<users><user>Erik Berlin</user><user>Wynn Netherland</user></users>"
end

it "returns an Array" do
expect(MultiXml.parse(@xml)["users"]["user"]).to be_a(Array)
end

it "parses correctly" do
expect(MultiXml.parse(@xml)).to eq("users" => {"user" => ["Erik Michaels-Ober", "Wynn Netherland"]})
expect(MultiXml.parse(@xml)).to eq("users" => {"user" => ["Erik Berlin", "Wynn Netherland"]})
end
end
end
Expand Down

0 comments on commit 940b8ae

Please sign in to comment.