FIX: Amazon spec

This commit is contained in:
Robin Ward 2013-10-04 12:49:39 -04:00
parent 2a97dbbb1f
commit c8487f6bc7
4 changed files with 13271 additions and 739 deletions

View file

@ -12,7 +12,6 @@ module Oneboxer
# Use the mobile version of the site
def translate_url
# If we're already mobile don't translate the url
return @url if @url =~ /https?:\/\/www\.amazon\.com\/gp\/aw\/d\//
@ -26,9 +25,9 @@ module Oneboxer
result = {}
result[:title] = html_doc.at("h1")
result[:title] = result[:title].inner_html if result[:title].present?
result[:title] = result[:title].inner_text.strip if result[:title].present?
image = html_doc.at(".a-image-wrapper img")
image = html_doc.at("#main-image")
result[:image] = image['src'] if image
result[:by_info] = html_doc.at("#by-line")

View file

@ -30,11 +30,9 @@ private
</div>
</div>
<div class='onebox-result-body'>
<img src="http://ecx.images-amazon.com/images/I/716dULgyHNL._SY180_.jpg" class="thumbnail">
<h3><a href="http://www.amazon.com/Ruby-Programming-Language-David-Flanagan/dp/0596516177" target="_blank">The Ruby Programming Language (Paperback)</a></h3>
<h4>David Flanagan, Yukihiro Matsumoto</h4>
The Ruby Programming Language is the authoritative guide to Ruby ...
<img src="http://ecx.images-amazon.com/images/I/512Cx%2BnJK8L._BO2,204,203,200_PIsitb-sticker-arrow-click,TopRight,35,-76_AA300_SH20_OU01_.jpg" class="thumbnail">
<h3><a href="http://www.amazon.com/Ruby-Programming-Language-David-Flanagan/dp/0596516177" target="_blank">The Ruby Programming Language [Paperback]</a></h3>
</div>
<div class='clearfix'></div>

File diff suppressed because one or more lines are too long

View file

@ -1,9 +1,9 @@
require 'nokogiri/xml/parse_options'
RSpec::Matchers.define :match_html do |expected|
match do |actual|
a = make_canonical_html(expected).to_html.gsub("\r\n", "\n")
b = make_canonical_html(actual).to_html.gsub("\r\n", "\n")
a == b
a = make_canonical_html(expected).to_html.gsub(/\s+/, " ").strip
b = make_canonical_html(actual).to_html.gsub(/\s+/, " ").strip
a.eql? b
end
failure_message_for_should do |actual|