Topic: newbee wants to design routes first - please offer suggestions

Been doing rails for several months. My learning project has half a dozen files with has_many through (join). I have been using scaffold_resource. As the code keeps getting more complex (often refactored), I realize that my top level specification is very weak.

What I would like to do is "test before writing code" regarding route design.

I need some guidance on this. Thanks in advance.

Re: newbee wants to design routes first - please offer suggestions

You'll need to use integration testing for testing the routes because both functional tests and unit tests are performed at a lower level. Is that what you were looking for?

Railscasts - Free Ruby on Rails Screencasts

Re: newbee wants to design routes first - please offer suggestions

Thank you. Nice reference. I will dig in.

Re: newbee wants to design routes first - please offer suggestions

So I dug in by trying to build an integration test for code generated by scaffold_resource. Here is a bit.

        def goes_to_update  table
            put ("/" + table + "/1"), :dev_note => "update test"            #eg. put "/people"
            assert_response :redirect
            follow_redirect!
            assert_response :success
            assert_template table + "/show"

            eval "put " + table.singularize + "_path" + '(:dev_note => "update test")'            #eg. put people_path
            assert_response :redirect
            follow_redirect!
            assert_response :success
            assert_template table + "/show"
        end


I figured out all but delete. Rails constructs a dialog box

<td><%= link_to 'Destroy', person_path(person), :confirm => 'Are you sure?', :method => :delete %></td>

I don't yet know enough about assertions and the rest of the interface to handle this. Where do I look?

Thanks

Re: newbee wants to design routes first - please offer suggestions

I just discovered the test log. That may help a lot to do the reverse engineering required for this