require File.dirname(__FILE__) + '/../spec_helper' describe "Reader Tags" do dataset :readers let(:person){ readers(:normal) } let(:another){ readers(:another) } let(:page){ pages(:first) } describe "r:readers tags" do subject { page } it { should render(%{}).as(Reader.all.map(&:name).join('')) } end describe "r:reader tags" do describe "on a ReaderPage" do before do @page = pages(:people) @page.stub!(:reader).and_return(person) end subject { @page } it { should render(%{}).as(person.name) } it { should render(%{hello}).as('hello') } it { should render(%{hello}).as('') } [:name, :nickname, :forename, :surname, :preferred_name, :email, :description].each { |field| it { should render(%{}).as(person.send(field)) } } end describe "on an uncached page" do before do @uncached_page = pages(:another) @uncached_page.stub!(:cache?).and_return(false) Reader.stub!(:current).and_return(readers(:another)) end subject { @uncached_page } it { should render(%{}).as(another.name) } it { should_not render(%{}).as('') } end describe "on a cached page" do subject { page } it { should render(%{}).as('') } it { should render(%{}).as('') } it { should render(%{}).as(%{
}) } [:name, :nickname, :forename, :surname, :preferred_name, :email, :description].each { |field| it { should render(%{}).as(another.send(field)) } } end end describe "utility tags" do subject { page } it { should render(%{All happy families are alike; each unhappy family is unhappy in its own way.}).as('All happy families are alike; each unhappy…') } it { should render(%{All happy families are alike; each unhappy family is unhappy in its own way.}).as('All happy families are alike;') } it { should render(%{All happy families are alike; each unhappy family is unhappy in its own way.}).as('All happy families are alike; (tbc)') } end end