Sha256: 844fa327a8902c059e7b228de56f4e20abdb146317a3e9e955253b9a70f52476

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

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

ActionController::Base.extend Responders::ControllerMethod

module FooResponder
  def to_html
    @resource << "foo"
    super
  end
end

module BarResponder
  def to_html
    @resource << "bar"
    super
  end
end

module BazResponder
  def to_html
    @resource << "baz"
    super
  end
end

class PeopleController < ApplicationController
  responders :foo, BarResponder
  
  def index
    @array = []
    respond_with(@array) do |format|
      format.html { render :text => "Success!" }
    end
  end
end

class SpecialPeopleController < PeopleController
  responders :baz
end

class ControllerMethodTest < ActionController::TestCase
  tests PeopleController

  def setup
    @controller.stubs(:polymorphic_url).returns("/")
  end

  def test_foo_responder_gets_added
    get :index
    assert assigns(:array).include? "foo"
  end
  
  def test_bar_responder_gets_added
    get :index
    assert assigns(:array).include? "bar"
  end
end

class ControllerMethodInheritanceTest < ActionController::TestCase
  tests SpecialPeopleController
  
  def setup
    @controller.stubs(:polymorphic_url).returns("/") 
  end
  
  def test_responder_is_inherited
    get :index
    assert assigns(:array).include? "foo"
    assert assigns(:array).include? "bar"
    assert assigns(:array).include? "baz"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
responders-0.6.0 test/controller_method_test.rb