Sha256: 17bb92772f10edf6c5e01d5ac2f194e196b11b0305d257397da56f0ae32fdd42
Contents?: true
Size: 1.71 KB
Versions: 3
Compression:
Stored size: 1.71 KB
Contents
require File.dirname(__FILE__) + '/spec_helper.rb' describe "callbacks'", :type => :controller do setup = lambda { class PiratesController < ActionController::Base expose_many(:pirates) private def first_callback_called @callback_called = 1 end def second_callback_called @callback_called += 1 end def third_callback_called @callback_called += 1 end end } setup.call ActionController::Routing::Routes.draw do |map| map.resources :pirates end controller_name :pirates Object.remove_class(PiratesController) before(:each) do setup.call @controller = PiratesController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new end after(:each) do Object.remove_class(PiratesController) end it "can call multiple callbacks" do PiratesController.after :assign, :first_callback_called, :second_callback_called, :third_callback_called get(:new) should assign_to(:callback_called).with(3) end it "can call callbacks for specific formats as an array" do PiratesController.after :assign, :first_callback_called, :second_callback_called, :only => [:create, :new] PiratesController.after :assign, :third_callback_called, :except => [:new] get(:new) should assign_to(:callback_called).with(2) end it "can call callbacks for a specific format as symbol" do PiratesController.after :assign, :first_callback_called, :second_callback_called, :only => :new PiratesController.after :assign, :third_callback_called, :except => :new get(:new) should assign_to(:callback_called).with(2) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
exposure-0.2.1 | spec/callbacks_spec.rb |
exposure-0.2.0 | spec/callbacks_spec.rb |
exposure-0.1.3 | spec/callbacks_spec.rb |