[Rspec-devel] Rails controller testing questions
David Chelimsky
dchelimsky at gmail.com
Fri Sep 8 12:18:39 EDT 2006
On 9/8/06, Jonathan del Strother <maillist at steelskies.com> wrote:
> I'm fine with model specs, but for some reason I'm struggling a bit
> making controller specs feel right. I'd love to see some more
> examples if anyone has any they're willing to share.
>
> Also, I have a few questions...
>
> --
>
> Is there any difference between
>
> should_have_tag 'input', :attributes => {:id => 'asset_name'}
>
> and
>
> response.body.should_have_tag 'input', :attributes => {:id =>
> 'asset_name'}
Ironically, the first one didn't work - it only failed to fail (don't
know why). However, I've just gotten it to work and committed it. So
you should use this:
should_have_tag 'input', :attributes => {:id => 'asset_name'}
Though the other won't break, it will be deprectated.
>
> ?
>
> Both styles are used on http://rspec.rubyforge.org/tools/rails.html
>
> --
>
> Is it possible to get route recognition testing to work in rspec? eg -
> assert_recognizes({:controller => 'assets', :action => 'new'},
> {:path => "/assets/new", :method => :get})
>
>
> --
>
> How about named urls? Being able to use
> get assets_url
> would be fairly handy
>
>
> --
>
> Finally, is it just me, or is rspec controller testing missing a
> bunch of useful functionality? For example, in rails functional
> tests there's
> assert_redirect_to :action => 'index'
> and I'm struggling to find an equivalent in rspec. The closest thing
> I can find is
> response.redirect_url.should_be 'http://test.host/assets'
> which is liable to break if, say, your default controller in
> routes.rb is AssetsController.
>
>
> I really want to like rspec for controller testing, but I keep on
> running into little annoyances like the above. Am I the only one?
Hi Jon. No, you are definitely not the only one. rspec_on_rails is a
work in progress. That said, would you please check the existing RFEs
and add any that you feel are missing from both rspec and the existing
backlog?
http://rubyforge.org/tracker/?atid=3152&group_id=797&func=browse
Thanks,
David
>
>
> Jon
> _______________________________________________
> Rspec-devel mailing list
> Rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel
>
More information about the Rspec-devel
mailing list