From acef42f4b9cb598e5d0fa488fff79bdb190b01f3 Mon Sep 17 00:00:00 2001 From: Kyle Carlson Date: Wed, 8 Jan 2014 14:36:00 -0600 Subject: [PATCH 1/2] added .rspec file --- .rspec | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .rspec diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..47eeb24 --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--color +--fail-fast \ No newline at end of file From 61c7e1cada4bc8166bbed766a66d33072cbdc0a8 Mon Sep 17 00:00:00 2001 From: Kyle Carlson Date: Wed, 8 Jan 2014 16:54:46 -0600 Subject: [PATCH 2/2] added methods & tests for most nodes --- lib/asin/simple_item.rb | 134 +++++++++++++++++- ...lookup_and_search_should_have_metadata.yml | 2 +- spec/lib/search_spec.rb | 35 +++++ 3 files changed, 169 insertions(+), 2 deletions(-) diff --git a/lib/asin/simple_item.rb b/lib/asin/simple_item.rb index ee20729..8be54f0 100644 --- a/lib/asin/simple_item.rb +++ b/lib/asin/simple_item.rb @@ -32,6 +32,10 @@ def details_url @raw.DetailPageURL end + def sales_rank + @raw.SalesRank + end + def review @raw.EditorialReviews!.EditorialReview!.Content end @@ -39,6 +43,134 @@ def review def image_url @raw.LargeImage!.URL end - end + # + def author + @raw.ItemAttributes!.Author + end + + def binding + @raw.ItemAttributes!.Binding + end + + def brand + @raw.ItemAttributes!.Brand + end + + def ean + @raw.ItemAttributes!.EAN + end + + def edition + @raw.ItemAttributes!.Edition + end + + def isbn + @raw.ItemAttributes!.isbn + end + + def item_dimensions + @raw.ItemAttributes!.ItemDimensions + end + + # hundredths of an inch + def item_height + @raw.ItemAttributes!.ItemDimensions.Height + end + + # hundredths of an inch + def item_length + @raw.ItemAttributes!.ItemDimensions.Length + end + + # hundredths of an inch + def item_width + @raw.ItemAttributes!.ItemDimensions.Width + end + + # hundredths of a pound + def item_weight + @raw.ItemAttributes!.ItemDimensions.Weight + end + + def package_dimensions + @raw.ItemAttributes!.PackageDimensions + end + + # hundredths of an inch + def package_height + @raw.ItemAttributes!.PackageDimensions.Height + end + + # hundredths of an inch + def package_length + @raw.ItemAttributes!.PackageDimensions.Length + end + + # hundredths of an inch + def package_width + @raw.ItemAttributes!.PackageDimensions.Width + end + + # hundredths of a pound + def package_weight + @raw.ItemAttributes!.PackageDimensions.Weight + end + + def label + @raw.ItemAttributes!.Label + end + + def language + @raw.ItemAttributes!.Languages.Language.first.Name + end + + def formatted_price + @raw.ItemAttributes!.ListPrice.FormattedPrice + end + + def manufacturer + @raw.ItemAttributes!.Manufacturer + end + + def mpn + @raw.ItemAttributes!.MPN + end + + def page_count + @raw.ItemAttributes!.NumberOfPages + end + + def part_number + @raw.ItemAttributes!.PartNumber + end + + def product_group + @raw.ItemAttributes!.ProductGroup + end + + def publication_date + @raw.ItemAttributes!.PublicationDate + end + + def publisher + @raw.ItemAttributes!.Publisher + end + + def sku + @raw.ItemAttributes!.SKU + end + + def studio + @raw.ItemAttributes!.Studio + end + + def total_new + @raw.OfferSummary!.TotalNew + end + + def total_used + @raw.OfferSummary!.TotalUsed + end + end end diff --git a/spec/cassettes/asin/lookup_and_search_should_have_metadata.yml b/spec/cassettes/asin/lookup_and_search_should_have_metadata.yml index c06fdfa..4b9b3f5 100644 --- a/spec/cassettes/asin/lookup_and_search_should_have_metadata.yml +++ b/spec/cassettes/asin/lookup_and_search_should_have_metadata.yml @@ -94,4 +94,4 @@ http_interactions: new to programming. </p>0 http_version: recorded_at: Tue, 25 Sep 2012 20:04:40 GMT -recorded_with: VCR 2.2.5 +recorded_with: VCR 2.2.5 \ No newline at end of file diff --git a/spec/lib/search_spec.rb b/spec/lib/search_spec.rb index 0b4aa7f..b722f82 100644 --- a/spec/lib/search_spec.rb +++ b/spec/lib/search_spec.rb @@ -18,10 +18,45 @@ module ASIN item = items.first item.asin.should eql(ANY_ASIN) item.title.should =~ /Learn Objective/ + item.sales_rank.should == '209840' item.amount.should eql(3999) item.details_url.should eql("http://www.amazon.com/Learn-Objective-C-Mac-Series/dp/1430218150%3FSubscriptionId%3DAKIAIBNLWSCV5OXMPD6A%26tag%3Dphoet-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D1430218150") item.image_url.should eql("http://ecx.images-amazon.com/images/I/41kq5bDvnUL.jpg") item.review.should =~ /Take your coding skills to the next level/ + + # + item.item_height.should == "925" + item.item_length.should == "752" + item.item_width.should == "71" + item.item_weight.should == "137" + item.package_height.should == "102" + item.package_length.should == "921" + item.package_width.should == "701" + item.package_weight.should == "123" + + item.author.count.should == 2 + item.author.first.should == "Scott Knaster" + item.binding.should == "Paperback" + item.brand.should == "Apress" + item.ean.should == "9781430218159" + item.edition == "1" + item.isbn == "1430218150" + item.label.should == "Apress" + item.language.should == "English" + item.formatted_price.should == "$39.99" + item.manufacturer.should == "Apress" + item.mpn.should == "978-1-4302-1815-9" + item.page_count.should == "360" + item.part_number.should == "978-1-4302-1815-9" + item.product_group.should == "Book" + item.publication_date.should == "2009-01-07" + item.publisher.should == "Apress" + item.sku.should == "mon0001920250" + item.studio.should == "Apress" + + # + item.total_new.should == "56" + item.total_used.should == "62" end it "should lookup multiple response groups", :vcr do