Test should fail!

Hello, a very strange thing is happening : the test below pass but it
should fail
I had a syntax error which produced an exception in the browser and http
500 in the script/console (using app.get ‘/’)

But with rake test:functionals it passes - How is it possible ? Of
course this file is really executed by the test suite, I can see it in
the screen output of rake

Which mistery is this ?


require File.dirname(FILE) + ‘/…/test_helper’
require ‘alerts_controller’

Re-raise errors caught by the controller.

class AlertsController; def rescue_action(e) raise e end; end

class AlertsControllerTest < Test::Unit::TestCase
fixtures :clients

def setup
@controller = AlertsController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new

def test_get_index
get :index
assert_response :success


On 10/12/06, nuno [email protected] wrote:

Which mistery is this ?
fixtures :clients


A couple of suggestions.

  • Does the test fail if you run it alone from the command line (outside
    of rake)
    $ cd my_app
    $ ruby test/functional/alerts_controller_test

  • Output the http response in the body of the test and see what is
    actually getting returned.
    def test_get_index
    get :index
    puts @response.body # (maybe this is response.body?)
    assert_response :success

  • Are you rendering any partials within the index template? There is
    (or at least was) a nasty bug in the compiling of partials which can
    lead to them working only in a certain order.


Also, be VERY aware that the integration testing ( app.get’/’ ) goes
through the whole routing system, whereas the functional test get :index

It could be a routing problem.

get :index just instantiates a controller object and invokes the get
action, no routing or, url mapping involved.

  • What does your routes.rb look like ?

  • if you use app.get ‘/alerts/index’ does it work ?