REST and functional tests

Just playing around with converting an apps to the new REST goodness in
edge rails, and I’m trying to work out how to convert/write the
functional tests.

Is the recommended way to explicitly use the actions (e.g. get :show,
:id => …; post :create,…, etc) and test the routes separately, or
duplicate the request, in which case how is that done get “/”, :id => 5
doesn’t work as I think the first parameter is expected to be an action?
Probably really obvious but I’m just not seeing it at the moment.

Chris,
For functional testing the same methods work fine for restful
routing. Check out simple example below.

class CustomersControllerTest < Test::Unit::TestCase
fixtures :customers

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

def test_index
get :index
assert_response :success
assert_template ‘customers/index’
end

def test_edit
get :edit, :id => customers(:customer1).id
assert_response :success
assert_template ‘customers/edit’
end

… etc.

end

Hope this helps,
Zack

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs