Sha256: 9aafa625231fada5018c13e16bb6251422b2a74f7ae41a933d7dddbd88c8970f

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

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

ActionController::Routing::Routes.draw do |map|
  map.connect ':controller/:action/:id'
end

class StubController < ActionController::Base
  include Rakismet::Controller
  def one ; render :nothing => true; end
  def two ; render :nothing => true; end
end

describe StubController do
  it "should add around_filter" do
    StubController.filter_chain.map(&:method).should include(Rakismet::Filter)
  end
end

describe StubController.subclass('OnlyActions') { rakismet_filter(:only => :one) } do

  it "should add around filter to specified actions" do
    Rakismet::Base.should_receive(:current_request=).twice
    get :one
  end

  it "should not add around filter to unspecified actions" do
    Rakismet::Base.should_not_receive(:current_request=)
    get :two
  end
end

describe StubController.subclass('ExceptActions') { rakismet_filter(:except => :one) } do

  it "should not add around filter to specified actions" do
    Rakismet::Base.should_not_receive(:current_request=)
    get :one
  end
  
  it "should add around filter to other actions" do
    Rakismet::Base.should_receive(:current_request=).twice
    get :two
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rakismet-0.4.2 spec/controllers/rakismet_controller_spec.rb
rakismet-0.4.1 spec/controllers/rakismet_controller_spec.rb