Sha256: ea6158d44365149ad70a06961101f8ef6b9553a6e7c11d41d9194ddd3b4d077c

Contents?: true

Size: 1.09 KB

Versions: 7

Compression:

Stored size: 1.09 KB

Contents

require File.dirname(__FILE__) + '/spec_helper'

describe "responders'", :type => :controller do
  setup = lambda {
    class PiratesController < ActionController::Base
      expose_many(:pirates)
      private
        def custom_response
          redirect_to({:action => "test"})
        end
    end
    
    ActionController::Routing::Routes.draw do |map| 
      map.resources :pirates, :collection => {:test => :any}
    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    
    Pirate.stub(:find, Factory.stub(:pirate))
  end
  
  after(:each) do
    Object.remove_class(PiratesController)
  end
  
  it "can respond to multiple actions with the same method, proc, or block" do
    PiratesController.response_for :show, :new, :is => :custom_response
    get(:show, {:id => 1})
    should respond_with(:redirect).to(:test)
    get(:new)
    should respond_with(:redirect).to(:test)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
exposure-0.2.1 spec/responder_spec.rb
exposure-0.2.0 spec/responder_spec.rb
exposure-0.1.3 spec/responder_spec.rb
exposure-0.1.2 spec/responder_spec.rb
exposure-0.1.1 spec/responder_spec.rb
exposure-0.1.0 spec/responder_spec.rb
exposure-0.0.7 spec/responder_spec.rb