Add specs for oneboxer components: amazon, android, apple, flickr and wikipedia

This commit is contained in:
Jaime Iniesta 2013-02-12 07:43:18 -05:00
parent 3c9cab54aa
commit 84a167725d
5 changed files with 155 additions and 0 deletions

View File

@ -0,0 +1,36 @@
# encoding: utf-8
require 'spec_helper'
require 'oneboxer'
require 'oneboxer/amazon_onebox'
describe Oneboxer::AmazonOnebox do
it "generates the expected onebox for Amazon" do
o = Oneboxer::AmazonOnebox.new("http://www.amazon.com/Ruby-Programming-Language-David-Flanagan/dp/0596516177")
o.onebox.should == expected_amazon_result
end
private
def expected_amazon_result
<<EXPECTED
<div class='onebox-result'>
<div class='source'>
<div class='info'>
<a href='http://www.amazon.com/Ruby-Programming-Language-David-Flanagan/dp/0596516177' target="_blank">
<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>
The Ruby Programming Language is the authoritative guide to Ruby&nbsp;...
</div>
<div class='clearfix'></div>
</div>
EXPECTED
end
end

View File

@ -0,0 +1,34 @@
# encoding: utf-8
require 'spec_helper'
require 'oneboxer'
require 'oneboxer/android_app_store_onebox'
describe Oneboxer::AndroidAppStoreOnebox do
it "generates the expected onebox for Android App Store" do
o = Oneboxer::AndroidAppStoreOnebox.new("https://play.google.com/store/apps/details?id=com.moosoft.parrot")
o.onebox.should == expected_android_app_store_result
end
private
def expected_android_app_store_result
<<EXPECTED
<div class='onebox-result'>
<div class='source'>
<div class='info'>
<a href='https://play.google.com/store/apps/details?id=com.moosoft.parrot' target="_blank">
<img class='favicon' src="/assets/favicons/google_play.png"> google.com
</a>
</div>
</div>
<div class='onebox-result-body'>
<img src="https://lh5.ggpht.com/wrYYVu74XNUu2WHk0aSZEqgdCDCNti9Fl0_dJnhgR6jY04ajQgVg5ABMatfcTDsB810=w124" class="thumbnail">
<h3><a href="https://play.google.com/store/apps/details?id=com.moosoft.parrot" target="_blank">Talking Parrot</a></h3>
Listen to the parrot repeat what you say. A Fun application for all ages. Upgrade to Talking Parrot Pro to save sounds, set them as your ringtone and control recording. Press the MENU button to access the settings where you can change the record time and repeat count. This app uses anonymous usage stats to understand and improve performance. Comments and feedback welcome.
</div>
<div class='clearfix'></div>
</div>
EXPECTED
end
end

View File

@ -0,0 +1,34 @@
# encoding: utf-8
require 'spec_helper'
require 'oneboxer'
require 'oneboxer/apple_app_onebox'
describe Oneboxer::AppleAppOnebox do
it "generates the expected onebox for Apple app" do
o = Oneboxer::AppleAppOnebox.new("https://itunes.apple.com/us/app/minecraft-pocket-edition-lite/id479651754")
o.onebox.should == expected_apple_app_result
end
private
def expected_apple_app_result
<<EXPECTED
<div class='onebox-result'>
<div class='source'>
<div class='info'>
<a href='https://itunes.apple.com/us/app/minecraft-pocket-edition-lite/id479651754' target="_blank">
<img class='favicon' src="/assets/favicons/apple.png"> apple.com
</a>
</div>
</div>
<div class='onebox-result-body'>
<img src="http://a5.mzstatic.com/us/r1000/087/Purple/99/2f/dd/mzl.erzwvjsi.175x175-75.jpg" class="thumbnail">
<h3><a href="https://itunes.apple.com/us/app/minecraft-pocket-edition-lite/id479651754" target="_blank">Minecraft Pocket Edition Lite</a></h3>
Imagine it, build it. Create worlds on the go with Minecraft - Pocket EditionThis is the Lite version of Minecraft - Pocket Edition. Minecraft - Pocket Edition allows you to build on the go. Use blocks to create masterpieces as you travel, hangout with friends, sit at the park, the possibilities are endless. Move beyond the limits of your computer and play Minecraft everywhere you go.Limitations of the Lite version* The world is not saved between sessions* Multiplayer worlds can not be copied to
</div>
<div class='clearfix'></div>
</div>
EXPECTED
end
end

View File

@ -0,0 +1,17 @@
# encoding: utf-8
require 'spec_helper'
require 'oneboxer'
require 'oneboxer/flickr_onebox'
describe Oneboxer::FlickrOnebox do
it "generates the expected onebox for Flickr" do
o = Oneboxer::FlickrOnebox.new("http://www.flickr.com/photos/jaimeiniesta/3303881265")
o.onebox.should == expected_flickr_result
end
private
def expected_flickr_result
"<a href='http://www.flickr.com/photos/jaimeiniesta/3303881265' target='_blank'><img src='http://farm4.staticflickr.com/3419/3303881265_c6924748e8_z.jpg' alt=''></a>"
end
end

View File

@ -0,0 +1,34 @@
# encoding: utf-8
require 'spec_helper'
require 'oneboxer'
require 'oneboxer/wikipedia_onebox'
describe Oneboxer::WikipediaOnebox do
it "generates the expected onebox for Wikipedia" do
o = Oneboxer::WikipediaOnebox.new("http://en.wikipedia.org/wiki/Ruby")
o.onebox.should == expected_wikipedia_result
end
private
def expected_wikipedia_result
<<EXPECTED
<div class='onebox-result'>
<div class='source'>
<div class='info'>
<a href='http://en.wikipedia.org/wiki/Ruby' target="_blank">
<img class='favicon' src="/assets/favicons/wikipedia.png"> wikipedia.org
</a>
</div>
</div>
<div class='onebox-result-body'>
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/8/80/Ruby_-_Winza%2C_Tanzania.jpg/220px-Ruby_-_Winza%2C_Tanzania.jpg" class="thumbnail">
<h3><a href="http://en.wikipedia.org/wiki/Ruby" target="_blank">Ruby</a></h3>
A ruby is a pink to blood-red colored gemstone, a variety of the mineral corundum (aluminium oxide). The red color is caused mainly by the presence of the element chromium. Its name comes from ruber, Latin for red. Other varieties of gem-quality corundum are called sapphires. The ruby is considered one of the four precious stones, together with the sapphire, the emerald, and the diamond. Prices of rubies are primarily determined by color. The brightest and most valuable "red" called pigeon blood-...
</div>
<div class='clearfix'></div>
</div>
EXPECTED
end
end