Skip to content
Browse files

Test Failure: has many relationship with primitive

  + Added the multi-street address xml to the models

  + Created a test that currently fails to test if it has parsed correctly
  • Loading branch information...
1 parent 5007845 commit 9e6f8f891aa35c31489606aa042502b2c3a252e8 @burtlo burtlo committed Jan 18, 2011
Showing with 18 additions and 0 deletions.
  1. +7 −0 spec/happymapper_spec.rb
  2. +11 −0 spec/support/models.rb
View
7 spec/happymapper_spec.rb
@@ -172,6 +172,13 @@ module Bar; class Baz; include HappyMapper; end; end
address.city.should == 'Oldenburg'
address.country.should == 'Germany'
end
+
+ it "should parse xml containing a has many relationship with primitive types" do
+ address = MultiStreetAddress.parse(fixture_file('multi_street_address.xml'), :single => true)
+ address.should_not be_nil
+ address.street_address.first.should == "123 Smith Dr"
+ address.street_address.last.should == "Apt 31"
+ end
it "should parse xml with default namespace (amazon)" do
file_contents = fixture_file('pita.xml')
View
11 spec/support/models.rb
@@ -239,6 +239,17 @@ class Address
element :country, String
end
+class MultiStreetAddress
+ include HappyMapper
+
+ # allow primitive type to be collection
+ has_many :street_address, String, :tag => "streetaddress"
+ element :city, String
+ element :state_or_providence, String, :tag => "stateOfProvidence"
+ element :zip, String
+ element :country, String
+end
+
# for type coercion
class ProductGroup < String; end

0 comments on commit 9e6f8f8

Please sign in to comment.
Something went wrong with that request. Please try again.