Sha256: 275e20eb6cbc9f567f692dde40e940374ca61b114e5925857bbe87959e5b17fa

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 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 set Rakismet::Base.rakismet_binding" do
    Rakismet::Base.should_receive(:rakismet_binding=).twice
    get :one
  end

  it "should return Rakismet::Base.rakismet_binding to nil after request" do
    get :one
    Rakismet::Base.rakismet_binding.should be_nil
  end

  it "should add around_filter" do
    StubController.filter_chain.map(&:class).should include(ActionController::Filters::AroundFilter)
  end
end

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

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

  it "should not add around filter to unspecified actions" do
    Rakismet::Base.should_not_receive(:rakismet_binding=)
    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(:rakismet_binding=)
    get :one
  end
  
  it "should add around filter to other actions" do
    Rakismet::Base.should_receive(:rakismet_binding=).twice
    get :two
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rakismet-0.4.0 spec/controllers/rakismet_controller_spec.rb