require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe "Shellac" do it "should add purge as a class method to ActionController::Base" do ActionController::Base.methods.include?(:purge).should be_true end it "should add purge as an instance method to ActionController::Base" do ActionController::Base.instance_methods.include?(:purge).should be_true end context "(rails performs caching)" do before(:each) do ActionController::Base.perform_caching = true end it "should raise error if varnish is not available" do lambda {ActionController::Base.purge("/")}.should raise_error(Errno::ECONNREFUSED) end end context "(rails doesn't perform caching)" do before(:each) do ActionController::Base.perform_caching = false end it "should return nil" do ActionController::Base.purge("/").should be nil end end end