require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb') describe "Pages Controller", "index action (with a Home Page)" do before(:each) do @page = Page.new(:title => "Home Page") @page.stub!(:to_html).and_return("This is a sample page.") Page.should_receive(:root).and_return(@page) get("/pages/index") end it "should look for a page with the title 'Home Page'" do @controller.instance_variable_get("@page").should == @page end it "should redirect" do @controller.status.should == 302 end end describe "Pages Controller", "index action (without a Home Page)" do before(:each) do Page.should_receive(:root).and_return(nil) @controller, @action = get("/pages/index") end it "should redirect" do @controller.status.should == 302 end end describe "Pages Controller", "show action (with a Page)" do before(:each) do @page = Page.new(:leaf_title => "My Page") @page.stub!(:to_html).and_return("This is a sample page.") Page.stub!(:by_long_title).with("My+Page").and_return(@page) @controller, @action = get("/pages/My+Page") end it "should find the page" do @controller.instance_variable_get("@page").should == @page end end describe "Pages Controller", "destroy action" do before(:each) do create_rows! @page = Page.new(:leaf_title => "My Page") Page.stub!(:by_long_title).with("My+Page").and_return(@page) end it "should deactivate the action" do @page.should_receive(:deactivate).and_return(true) delete("/pages/My+Page") end end