January 10, 2008 @ 12:52 PM
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 #<Proc:0x0224e7d8@./spec/controllers/foo_controller_spec.rb:68>
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)"

by Michael Klishin on 21 Jan 13:39
Rick,
This is really interesting stuff with Ruby2Ruby, I have similar implementation for authetication and authorization some time ago but apparently changes in RSpec screwed my implementation up.
I remember your post on RSpec mailing list saying you’d like to propose some kind of pluggable system for RSpec. What’s going on with this, any update?
Michael novemberain.com