Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
describe DesignsController, "#index project sort" do before(:each) do login_with(:view_own_designs) end describe "with project sort parameter" do before(:each) do @cookies = {} controller.stub!(:cookies).and_return(@cookies) end def get_index get :index, :project_sort => "name" end it "sets a cookie with the value and new expiration date" do get_index @cookies[:project_sort][:value].should == "name" @cookies[:project_sort][:expires].beginning_of_day.should == 1.year.from_now.beginning_of_day end it "captures the value for the view" do get_index assigns[:project_sort].should == "name" end end describe "without project sort parameter" do def get_index get :index end describe "without existing cookie" do before(:each) do @cookies = {} controller.stub!(:cookies).and_return(@cookies) end it "sets a cookie with the default value and new expiration date" do get_index @cookies[:project_sort][:value].should == "created_at" @cookies[:project_sort][:expires].beginning_of_day.should == 1.year.from_now.beginning_of_day end it "captures the value for the view" do get_index assigns[:project_sort].should == "created_at" end end describe "with existing cookie" do before(:each) do @cookies = { :project_sort => "name" } controller.stub!(:cookies).and_return(@cookies) end it "resets the cookie with the value and new expiration date" do get_index @cookies[:project_sort][:value].should == "name" @cookies[:project_sort][:expires].beginning_of_day.should == 1.year.from_now.beginning_of_day end it "captures the value for the view" do get_index assigns[:project_sort].should == "name" end end end end
This paste will be private.
From the Design Piracy series on my blog: