forked from gingerhendrix/echonest
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
46d1362
commit 24f2662
Showing
8 changed files
with
141 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
module EchoNest | ||
class BlogDoc | ||
include HappyMapper | ||
|
||
tag :doc | ||
|
||
element :name, String | ||
element :url, String | ||
element :summary, String | ||
element :date_found, String | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
module EchoNest | ||
class BlogResult | ||
include HappyMapper | ||
|
||
tag :response | ||
|
||
has_one :artist, Artist | ||
has_one :results, BlogResults | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
module EchoNest | ||
class BlogResults | ||
include HappyMapper | ||
|
||
tag :results | ||
|
||
attribute :found, String | ||
attribute :shown, String | ||
attribute :start, String | ||
|
||
has_many :docs, BlogDoc | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require File.dirname(__FILE__) + '/../spec_helper' | ||
|
||
describe "BlogResult" do | ||
|
||
describe "#parse" do | ||
|
||
before(:each) do | ||
@xml = File.read(File.dirname(__FILE__) + "/../fixtures/blog/radiohead.xml") | ||
end | ||
|
||
it "should parse xml" do | ||
EchoNest::BlogResult.parse(@xml) | ||
end | ||
|
||
it "should have artist" do | ||
blog = EchoNest::BlogResult.parse(@xml) | ||
blog.artist.should be_kind_of(EchoNest::Artist) | ||
blog.artist.name.should == "Radiohead" | ||
blog.artist.id.should == "music://id.echonest.com/~/AR/ARH6W4X1187B99274F" | ||
end | ||
|
||
it "should have results" do | ||
blog = EchoNest::BlogResult.parse(@xml) | ||
blog.results.should be_kind_of(EchoNest::BlogResults) | ||
#TODO: Fill in these values as found in fixture | ||
blog.results.found.should == "131" | ||
blog.results.shown.should == "2" | ||
blog.results.start.should == "0" | ||
blog.results.docs.should be_kind_of(Array) | ||
blog.results.docs.length.should == 2 | ||
end | ||
|
||
describe "result" do | ||
it "should be an BlogDoc" do | ||
blog = EchoNest::BlogResult.parse(@xml) | ||
doc = blog.results.docs[0] | ||
doc.should be_kind_of(EchoNest::BlogDoc) | ||
#TODO: Create tests based on attributes in resource | ||
doc.name.should == "Radiohead live at Santa Barbara 28.8.08 « Misspeak Music" | ||
doc.url.should == "http://misspeakmusic.wordpress.com/2008/09/01/radiohead-live-at-santa-barbara-28808/" | ||
doc.summary.should == "[blog text removed]" | ||
doc.date_found.should == "2008-10-14 16:38:15.582000" | ||
end | ||
end | ||
end | ||
|
||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<response version="3"> | ||
<status> | ||
<code>0</code> | ||
<message>Success</message> | ||
</status> | ||
<query> | ||
<parameter name="api_key">5ZAOMB3BUR8QUN4PE</parameter> | ||
<parameter name="id">music://id.echonest.com/~/AR/ARH6W4X1187B99274F</parameter> | ||
<parameter name="start">0</parameter> | ||
<parameter name="rows">2</parameter> | ||
</query> | ||
<artist> | ||
<name>Radiohead</name> | ||
<id>music://id.echonest.com/~/AR/ARH6W4X1187B99274F</id> | ||
<foreign_id>music://id.echonest.com/5ZAOMB3BUR8QUN4PE/AR/1</foreign_id> | ||
</artist> | ||
<results found="131" shown="2" start="0"> | ||
<doc id="808bd8998c36ca73ee35c77453461b05" type="web"> | ||
<name>Radiohead live at Santa Barbara 28.8.08 « Misspeak Music</name> | ||
<url>http://misspeakmusic.wordpress.com/2008/09/01/radiohead-live-at-santa-barbara-28808/</url> | ||
<summary>[blog text removed]</summary> | ||
<date_found>2008-10-14 16:38:15.582000</date_found> | ||
</doc> | ||
<doc id="20fc2d49343546ba647ddcae5c0e70e0" type="web"> | ||
<name>Apartment 41: Radiohead's Santa Barbara Webcast</name> | ||
<url>http://coldbrains41.blogspot.com/2008/08/radioheads-santa-barbara-webcast-video.html</url> | ||
<summary>[blog text removed]</summary> | ||
<date_found>2008-10-14 16:38:15.582000</date_found> | ||
</doc> | ||
</results> | ||
</response> |