More on Controller Specs, or Fun with Ruby2Ruby
One of the problems with the rspec_on_rails_on_crack (git://activereload.net/rspec_on_rails_on_crack.git) was that the redirection examples had horrible descriptions.
describe FooController, "GET /index" do
it_redirects_to { foo_path }
end
The route goes in a ruby proc because routes aren't available from the context of the example group. They're only available from inside a running example. But this is what the description looks like when running rake spec:doc:
FooController GET #index - redirects to #
Solution? Install the ParseTree and ruby2ruby gems and add this to #it_redirects_to:
route.to_ruby.gsub(/(^proc \{)|(\}$)/, '').strip
FooController GET #edit - redirects to "foo_path(1)"
related
- 2010 Jul 13 In-Process Node.js Queues
- 2010 Jul 07 Geek Talk Interview
- 2010 Jun 28 Tee and Child Processes
- 2010 Jun 23 You can let go now
- 2010 May 17 Railsconf: Building APIs
- 2010 May 10 Nori: Node.js Riak wrapper
- 2010 May 10 No, I did not create a mobile phone framework too
- 2010 May 04 Escaping your test suite with your life
- 2010 Apr 05 Will the iPad kill comic books?
- 2010 Apr 05 First day at GitHub

