require File.dirname(__FILE__) + '/../spec_helper' describe Orthor::Templates do before(:all) do FakeWeb.register_uri(:get, "http://content.orthor.com/orthor/content_items/homepage.json", :body => File.join(SPEC_DIR, 'resources', 'homepage.json')) FakeWeb.register_uri(:get, "http://content.orthor.com/orthor/queries/latest-news-items.json", :body => File.join(SPEC_DIR, 'resources', 'latest-news-items.json')) FakeWeb.register_uri(:get, "http://content.orthor.com/orthor/categories/news.json", :body => File.join(SPEC_DIR, 'resources', 'news.json')) FakeWeb.register_uri(:get, "http://content.orthor.com/orthor/content_items/missing.json", :body => "") Orthorings.setup do account_id "orthor" end end describe "with no content returned" do it "should return an empty string" do Orthorings.content("missing").should be_empty end end describe "should use custom {{}} replacement for rendering" do before(:all) do Orthor::Templates.define do template :basic, %!

{{title}}

{{Content}}
! template :brief, %!

{{title}}

! template :blurb, %!
{{Content.blurb}}
! end end describe "a content item" do it "should display content using the named template" do Orthorings.content("homepage", :basic).should == %!

What is Orthor

So what is Orthor really??

! end it "should respect given template name" do Orthorings.content("homepage", :brief).should == %!

What is Orthor

! end describe "blurb" do it "should truncate some of the text, strip html and add ..." do Orthorings.content("homepage", :blurb).should == "
So what is Orthor really??...
" end end end describe "a content query" do it "should render the template for each item" do Orthorings.query("latest-news-items", :brief).should == %!

User Manual updated

Account event tracking

Tutorials have been updated

! end end describe "a category" do it "should render the template for each item" do Orthorings.category("news", :brief).should == %!

User Manual updated

Account event tracking

Tutorials have been updated

Content Queries have landed in Orthor

! end end end end