2013-02-12 07:43:18 -05:00
|
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
require 'oneboxer'
|
|
|
|
|
require 'oneboxer/amazon_onebox'
|
|
|
|
|
|
2013-02-13 05:32:18 -05:00
|
|
|
|
describe Oneboxer::AmazonOnebox do
|
|
|
|
|
before(:each) do
|
|
|
|
|
@o = Oneboxer::AmazonOnebox.new("http://www.amazon.com/Ruby-Programming-Language-David-Flanagan/dp/0596516177")
|
2013-03-23 11:02:59 -04:00
|
|
|
|
FakeWeb.register_uri(:get, @o.translate_url, response: fixture_file('oneboxer/amazon.response'))
|
2013-02-13 05:32:18 -05:00
|
|
|
|
end
|
2013-02-25 11:42:20 -05:00
|
|
|
|
|
2013-02-13 05:32:18 -05:00
|
|
|
|
it "translates the URL" do
|
|
|
|
|
@o.translate_url.should == "http://www.amazon.com/gp/aw/d/0596516177"
|
|
|
|
|
end
|
2013-02-25 11:42:20 -05:00
|
|
|
|
|
2013-02-12 07:43:18 -05:00
|
|
|
|
it "generates the expected onebox for Amazon" do
|
2013-06-13 05:09:11 -04:00
|
|
|
|
@o.onebox.should match_html expected_amazon_result
|
2013-02-12 07:43:18 -05:00
|
|
|
|
end
|
2013-02-25 11:42:20 -05:00
|
|
|
|
|
2013-02-12 07:43:18 -05:00
|
|
|
|
private
|
|
|
|
|
def expected_amazon_result
|
|
|
|
|
<<EXPECTED
|
|
|
|
|
<div class='onebox-result'>
|
|
|
|
|
<div class='source'>
|
|
|
|
|
<div class='info'>
|
2013-04-07 20:24:12 -04:00
|
|
|
|
<a href='http://www.amazon.com/Ruby-Programming-Language-David-Flanagan/dp/0596516177' class="track-link" target="_blank">
|
2013-02-12 07:43:18 -05:00
|
|
|
|
<img class='favicon' src="/assets/favicons/amazon.png"> amazon.com
|
|
|
|
|
</a>
|
|
|
|
|
</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>
|
2013-02-19 12:06:35 -05:00
|
|
|
|
|
2013-02-12 09:46:45 -05:00
|
|
|
|
The Ruby Programming Language is the authoritative guide to Ruby ...
|
2013-02-12 07:43:18 -05:00
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
<div class='clearfix'></div>
|
|
|
|
|
</div>
|
|
|
|
|
EXPECTED
|
|
|
|
|
end
|
2013-02-25 11:42:20 -05:00
|
|
|
|
end
|