diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/general_controller_spec.rb | 11 | ||||
-rw-r--r-- | spec/fixtures/files/blog_feed.atom | 39 |
2 files changed, 49 insertions, 1 deletions
diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb index 9a88dbc3a..4a1c8b134 100644 --- a/spec/controllers/general_controller_spec.rb +++ b/spec/controllers/general_controller_spec.rb @@ -19,8 +19,11 @@ end describe GeneralController, 'when getting the blog feed' do - it 'should add a lang param correctly to a url with no querystring' do + before do AlaveteliConfiguration.stub!(:blog_feed).and_return("http://blog.example.com") + end + + it 'should add a lang param correctly to a url with no querystring' do get :blog assigns[:feed_url].should == "http://blog.example.com?lang=en" end @@ -31,6 +34,12 @@ describe GeneralController, 'when getting the blog feed' do assigns[:feed_url].should == "http://blog.example.com?alt=rss&lang=en" end + it 'should parse an item from an example feed' do + controller.stub!(:quietly_try_to_open).and_return(load_file_fixture("blog_feed.atom")) + get :blog + assigns[:blog_items].count.should == 1 + end + end describe GeneralController, "when showing the frontpage" do diff --git a/spec/fixtures/files/blog_feed.atom b/spec/fixtures/files/blog_feed.atom new file mode 100644 index 000000000..f49693938 --- /dev/null +++ b/spec/fixtures/files/blog_feed.atom @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<rss version="2.0" + xmlns:content="http://purl.org/rss/1.0/modules/content/" + xmlns:wfw="http://wellformedweb.org/CommentAPI/" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:atom="http://www.w3.org/2005/Atom" + xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" + xmlns:slash="http://purl.org/rss/1.0/modules/slash/" + > + +<channel> + <title>A Blog Feed</title> + <atom:link href="http://example.com/feed/" rel="self" type="application/rss+xml" /> + <link>http://www.example.com</link> + <description>Stuff</description> + <lastBuildDate>Tue, 30 Apr 2013 14:34:15 +0000</lastBuildDate> + <language>en</language> + <sy:updatePeriod>hourly</sy:updatePeriod> + <sy:updateFrequency>1</sy:updateFrequency> + <generator>http://wordpress.org/?v=3.3.2</generator> + <item> + <title>Example Post</title> + <link>http://www.example.com/example-post</link> + <comments>http://www.example.com/example-post#comments</comments> + <pubDate>Mon, 01 Apr 2013 19:26:08 +0000</pubDate> + <dc:creator>Example Blogger</dc:creator> + <category><![CDATA[FOI]]></category> + + <guid isPermaLink="false">http://www.example.com/?id=333</guid> + <description><![CDATA[An example post [...]]]></description> + <content:encoded><![CDATA[<h3>A blog post</h3> +<p>Example post</p> +]]></content:encoded> + <wfw:commentRss>http://www.example.com/feed/</wfw:commentRss> + <slash:comments>2</slash:comments> + </item> + + </channel> +</rss> |