Search code examples
ruby-on-railsunit-testinggetfunctional-testingruby-on-rails-2

Ruby Unit Testing Get Method


I am pulling my hair out trying to expand the testing coverage for an existing Rails 2.3 app.

They are using a unit:test framework. I am really having trouble wrapping my head around how to debug the get method that appears a lot. Here is an example:

   get(:results,
        { # params
          :s => "college",
          :alt_iframes => iframes_param,
          :site_version => ApplicationController::VERSION_GOOGLE.to_i
        },
        { # session
          :arrival_id => 3,
          :arrival_quality => test_quality,
          :tid => test_tid,

        })

When it works, it is pretty self-evident what is going on. However, when it doesn't work, I have a lot of trouble debugging what is going wrong.

Is there anyway to understand what exact URL a call like this equates to? Or is it possible to make a call of this form instaed get("localhost:3000").

I am having even finding documentation when I do a google search.


Solution

  • If you are talking about a controller test, then get doesn't call a URL at all. It just directly calls the action in the controller you are testing. It works differently if you are talking about an integration test... and nobody should be calling get in a unit test.