Skip to content

Commit

Permalink
Updated Amazon model to pull images from #imageBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
dhulihan committed Nov 28, 2013
1 parent fc5d460 commit f3f525d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/fletcher/models/amazon.rb
Expand Up @@ -30,6 +30,7 @@ def parse(data)

# Get Images
self.images = doc.xpath("//*[@data-action='main-image-click']//img").attribute_array
self.images = doc.xpath("//*[@id='imageBlock']//img").attribute_array unless self.images
self.image = images.first
end
end
Expand Down
5 changes: 5 additions & 0 deletions spec/factories/models.rb
Expand Up @@ -30,6 +30,11 @@
url "http://www.amazon.com/gp/product/B0093162RM/"
end

# Create multiple amazon models, since markup varies greatly between products
factory :amazon2, :parent => :base do
url "http://www.amazon.com/gp/product/B000P4W3LU/"
end

# This may need to be updated if the item is expired/deleted
factory :ebay, :parent => :base do
url "http://www.ebay.com/itm/Unicycle-20-Silver-Chrome-Unicycles-Wheel-Cycling-Outdoor-Sports-Fitness-New-/310729787186?pt=LH_DefaultDomain_0&hash=item4858f04732"
Expand Down
6 changes: 4 additions & 2 deletions spec/lib/fletcher/models/amazon_spec.rb
Expand Up @@ -23,8 +23,10 @@ def amazon_check(url)
describe Fletcher::Model::Amazon do
describe "parse", :vcr do
context "with valid data" do
it "should return correct model info for a product" do
amazon_check(FactoryGirl.build(:amazon).url)
%w{amazon amazon2}.each do |name|
it "should fetch valid info for #{name}" do
amazon_check(FactoryGirl.build(name.to_sym).url)
end
end
end
end
Expand Down

0 comments on commit f3f525d

Please sign in to comment.