Topic: testing url parameters

I am very new to rails and am having a hard time writing unit tests.
How do I write rspec tests for accepting url parameters?
Basically I get a url like the following:
localhost:3000/groups/?group_id=2

In my controller I asssign it to a variable.
@group_id = params[:group_id]

In my view I am just comparing the group id with the id retrieved from the database

    .accordion-body{id: "collapse-#{index}", class: ( @group_id.to_i == group.id || ) ? '' : 'collapse' }

I am not sure how I would go about writing tests for this.

Last edited by ruby_begins (2013-03-05 15:39:08)

Re: testing url parameters

I think you're overcomplicating this. Ideally, you should be getting localhost:3000/groups/2 and then your controller would only need @group = Group.find(params[:id]). If you're still having this issue, show us your routes.rb and the controller/view for one of these links. Get that working right, and your testing will be correspondingly simpler.