Sha256: c8e6b12afef32f48b35e4ec0334ffa8f4fe737871b89accd1a3530a08f1fd1a1

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 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
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
exposure-0.1.2 spec/callbacks_spec.rb
exposure-0.1.1 spec/callbacks_spec.rb
exposure-0.1.0 spec/callbacks_spec.rb
exposure-0.0.7 spec/callbacks_spec.rb