require File.dirname(__FILE__) + '/spec_helper' require 'moneta/memory' describe Orthorings, "fetching content" do before(:all) do FakeWeb.register_uri(:get, "http://content.orthor.com/orthor/content_items/homepage.html", :body => File.join(SPEC_DIR, 'resources', 'homepage.html')) FakeWeb.register_uri(:get, "http://content.orthor.com/orthor/queries/latest-news-items.html", :body => File.join(SPEC_DIR, 'resources', 'latest-news-items.html')) FakeWeb.register_uri(:get, "http://content.orthor.com/orthor/categories/news.html", :body => File.join(SPEC_DIR, 'resources', 'news.html')) Orthorings.setup do account_id "orthor" end end it 'should be able to fetch content items' do Orthorings.content("homepage").include?("

So what is Orthor anyway?

").should be_true end it 'should be able to fetch queries' do Orthorings.query("latest-news-items").include?("Comparisons to traditional Content Management").should be_true end it 'should be able to fetch categories' do Orthorings.category("news").include?("

Orthor's Features

").should be_true end it 'should not cache content if no config is given' do Orthorings.cache.should == false end end describe Orthorings, "caching content" do before(:all) do FakeWeb.register_uri(:get, "http://content.orthor.com/orthor/content_items/homepage.html", :body => File.join(SPEC_DIR, 'resources', 'homepage.html')) FakeWeb.register_uri(:get, "http://content.orthor.com/orthor/queries/latest-news-items.html", :body => File.join(SPEC_DIR, 'resources', 'latest-news-items.html')) FakeWeb.register_uri(:get, "http://content.orthor.com/orthor/categories/news.html", :body => File.join(SPEC_DIR, 'resources', 'news.html')) Orthorings.setup do account_id "orthor" caching :memory end end it 'expiry should default to 300 seconds if none is given' do Orthorings.cache_expiry.should == 300 end it 'should add content to the cache after requests' do Orthorings.cache["homepage"].should be_empty Orthorings.content("homepage") Orthorings.cache["homepage"].should_not be_empty Orthorings.should_not_receive(:cache_content) Orthorings.content("homepage") end end