[rspec-devel] [ rspec-Bugs-6053 ] RSpec with Rails: skip_before_filter is ignored on edge rails

noreply at rubyforge.org noreply at rubyforge.org
Sat Oct 7 09:36:27 EDT 2006


Bugs item #6053, was opened at 2006-10-07 09:36
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=6053&group_id=797

Category: None
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Nobody (None)
Assigned to: Nobody (None)
Summary: RSpec with Rails: skip_before_filter is ignored on edge rails

Initial Comment:
RSpec on Rails ignores skip_before_filter declarations in controllers being tested with RSpec. 

Appears to be non-issue with Rails 1.1.6. Broken on edge rails.

Example code:

# application.rb:

class ApplicationController < ActionController::Base
  before_filter :raise_error
  
  def raise_error
    raise "This should never be called"
  end
  
end

# example_controller.rb

class ExampleController < ApplicationController
  skip_before_filter :raise_error

  def tester
    render :text => 'hello world'
  end
  
end

# example_controller_spec.rb => raises error

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

context "The ExampleController" do

  controller_name :example

  specify "Should skip before_filter :raise_error" do
    get :tester
    response.should_be_success
  end
end


# example_controller_spec.rb => reports success

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

# Re-raise errors caught by the controller.
class ExampleController; def rescue_action(e) raise e end; end

class ExampleControllerTest < Test::Unit::TestCase
  def setup
    @controller = ExampleController.new
    @request    = ActionController::TestRequest.new
    @response   = ActionController::TestResponse.new
  end

  # Replace this with your real tests.
  def test_no_error_without_rspec
    get :tester
    assert_response :success
  end
end


----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=6053&group_id=797


More information about the rspec-devel mailing list