spec/finders/finder_spec.rb in exposure-0.0.6 vs spec/finders/finder_spec.rb in exposure-0.0.7

- old
+ new

@@ -1,31 +1,37 @@ require File.dirname(__FILE__) + '/../spec_helper' -describe "finders", :type => :controller do - class PiratesController < ActionController::Base - expose_many(:pirates) - private - def find_pirate - Pirate.find_by_title(params[:id]) - end - end +describe "finders", :type => :controller do + setup = lambda { + class PiratesController < ActionController::Base + expose_many(:pirates) + private + def find_pirate + Pirate.find_by_title(params[:id]) + end + end + + ActionController::Routing::Routes.draw do |map| + map.resources :pirates + end + } + setup.call controller_name :pirates + Object.remove_class(PiratesController) before(:each) do + setup.call @controller = PiratesController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new - ActionController::Routing::Routes.draw do |map| - map.resources :pirates - end @pirate = Factory.stub(:pirate) Pirate.stub(:find_by_title => @pirate) end after(:each) do - PiratesController::Finders.clear + Object.remove_class(PiratesController) end it "finds with a method name as symbol" do PiratesController.find :pirate, :with => Proc.new { Pirate.find_by_title(params[:id]) } get(:show, {:id => 'Captain'}) \ No newline at end of file