On Sat, Jul 4, 2009 at 4:40 PM, Ed Ruder<[email protected]> wrote: > I have a helper that calls a Rails route _url method. In the context > of a helper spec file, the route helper method ends up calling url_for > in rails/actionpack/lib/action_controller/base.rb. In the context of > rendering a page, the route helper method calls url_for in rails/ > actionpack/lib/action_view/helpers/url_helper.rb. Though very similar, > they can return different results, as I found out. > > Specifically, ActionController::Base#url_for doesn't do html escaping-- > ActionView::Helpers::UrlHelper#url_for does, and has an additional > parameter, :escape => true|false, to controller whether or not the > escaping is done. > > This took some frustrating time to track down. > > Since the code path executed by helper examples is not the same as > production, tests can produce invalid results. Also, some behavior > cannot be tested, since the code generating the results is not being > executed. > > Is this a bug in RSpec, or is there a "correct" way to test helpers > that I'm missing?
Not sure if this is directly related, but you may be interested in this ticket: https://rspec.lighthouseapp.com/projects/5645/tickets/843 _______________________________________________ rspec-users mailing list [email protected] http://rubyforge.org/mailman/listinfo/rspec-users
