<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <id>tag:www.refactormycode.com,2007:users1127</id>
  <link type="application/atom+xml" href="http://www.refactormycode.com/users/1127" rel="self"/>
  <title>hellekin</title>
  <updated>Mon Sep 14 23:27:56 -0700 2009</updated>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor307624</id>
    <published>2009-09-14T23:27:56-07:00</published>
    <title>[Ruby] On ATOM feed to identi.ca status updates</title>
    <content type="html">&lt;p&gt;There are a number of problems in this code:&lt;/p&gt;

&lt;p&gt;* first, it's really _shy_: it's afraid of breaking everywhere, rescuing a whole lot of situation that might happen, but there are too many rescues.
&lt;br /&gt;* then, the two feeds are too much coupled. They should be taken care of in different classes, so that:
&lt;br /&gt;  * one identi.ca watcher can share its info with multiple sources (e.g. wiki, blog, you name it)
&lt;br /&gt;  * the find_last_update method would use a cached version on first call, and not ask everytime (although it should between batches)&lt;/p&gt;

&lt;p&gt;Here are my late night thoughts. Hopefully someone can propose some change, or a suggestion, before I have the opportunity to work on it again (I'm very busy(tm) ATM)&lt;/p&gt;

&lt;pre&gt;&lt;/pre&gt;</content>
    <author>
      <name>hellekin</name>
      <email>hellekin@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/1033-atom-feed-to-identi-ca-status-updates/refactors/307624" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor305485</id>
    <published>2009-09-12T02:04:22-07:00</published>
    <title>[Ruby] On Determine layout</title>
    <content type="html">&lt;p&gt;You don't even need to assign action&lt;/p&gt;

&lt;pre&gt;  def determine_layout
    %w(index show edit update).include?(params[:action]) ? &amp;quot;application&amp;quot; : &amp;quot;sessions&amp;quot;
  end&lt;/pre&gt;</content>
    <author>
      <name>hellekin</name>
      <email>hellekin@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/1032-determine-layout/refactors/305485" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Code1033</id>
    <published>2009-09-12T02:00:11-07:00</published>
    <updated>2010-05-04T09:30:31-07:00</updated>
    <title>[Ruby] ATOM feed to identi.ca status updates</title>
    <content type="html">&lt;p&gt;I want to refactor this code in order to allow multiple incoming feeds without having to launch it multiple times.
&lt;br /&gt;The idea would be to split the polling of identi.ca feed and share that information with has many source feeds as necessary.
&lt;br /&gt;I didn't think about it too much yet... Info &amp;amp; updates about this code will be available at &lt;a href="http://hackerspaces.org/wiki/P0wn1e" target="_blank"&gt;http://hackerspaces.org/wiki/P0wn1e&lt;/a&gt;
&lt;br /&gt;Thanks, 
&lt;br /&gt;==
&lt;br /&gt;hk&lt;/p&gt;

&lt;pre&gt;#!/usr/bin/env ruby1.8
#
# p0wn1e is the hackerspaces.org notifier.
# It reads an ATOM feed and send updates to identi.ca
#
################################################################################
### BEGIN CONFIGURATION
 
$options = {}
# Identi.ca credentials
$options[:username] = 'p0wn1e'
$options[:password] = 'I_can_haz_sekrit?'
# URI of the ATOM feed for the wiki pages
$options[:feed_uri] = 'http://hackerspaces.org/w/index.php?title=Special:NewPages&amp;amp;feed=atom'
# Uncomment the following line to turn on debugging output
$DEBUG = true
 
### END CONFIGURATION
################################################################################
    
%w(rubygems atom net/https yaml).each { |lib| require(lib) }

 
class P0wn1e
  # sleep time in seconds
  @@delay = 42*2
  # dent message prototype
  @@dent = &amp;quot;!hs %s created '%s' at %s&amp;quot;
  # and corresponding regex prototype
  @@dentr = &amp;quot;!hs.*created\s.(.+).\sat.*&amp;quot;
 
  # P0wn1e haz atomz
  DENT_URI = &amp;quot;http://identi.ca/api/statuses/user_timeline/__USER__.atom&amp;quot;
  # P0wn1e posts updates to identi.ca
  POST_URI = URI.parse('https://identi.ca/api/statuses/update.xml')
  
  def initialize(options = {})
    @user = options[:username]
    @pass = options[:password]
    @feed_uri = options[:feed_uri]
    @all_dents = []
    @all_pages = []
    @new_pages = []
    debug(&amp;quot;initialization complete&amp;quot;)
  end
  
  # Run p0wn1e! Run!
  def run!
    @http = http_post_connect
    loop do
      refresh_all_feeds
      update if pending_updates?
      debug(&amp;quot;haz no pending updates... Sleeping 10 minutes&amp;quot;)
      sleep 600 # sleep 10 minutes between batches
    end
  rescue Exception =&amp;gt; e
    debug(&amp;quot;failed to start! [#{e.class}] #{e.message}&amp;quot;)
    raise e
  end
  
  # We only send to identi.ca as the account will forward to twitter
  def dent(message)
    debug(&amp;quot;denting #{message}&amp;quot;)
    req = Net::HTTP::Post.new(POST_URI.path)
    req.form_data=({ 'status' =&amp;gt; message })
    req.basic_auth(@user, @pass)
    debug(&amp;quot;authenticated&amp;quot;)
    res = @http.request(req)
    debug(&amp;quot;sent request&amp;quot;)
    if res.body =~ %r{&amp;lt;text&amp;gt;#{@@dentr}&amp;lt;/text&amp;gt;.*&amp;lt;id&amp;gt;(\d+)&amp;lt;/id&amp;gt;}
      @last_update = [$1, $2.to_i]
      debug(&amp;quot;sent new message: #{@last_update.inspect} #{message}&amp;quot;)
    end
    res
  rescue Exception =&amp;gt; e
    error = &amp;quot;dent failed for message: #{message}\nwith error [#{e.class}] #{e.message}&amp;quot;
    debug(error)
    sleep @@delay
    retry
  end
  
  def last_update
    debug(&amp;quot;last_update: #{@last_update.inspect}&amp;quot;)
    @last_update ||= find_last_update
  end
  
  def new_pages
    candidates = @all_pages.last.map { |p| [p.title, p.authors.first.name, p.links.first.href] }.reverse
    start_idx = 0
    last_dent_page_name = last_update.first
    candidates.each_with_index do |c, i|
      if c.first == last_dent_page_name
start_idx = [i+1, candidates.length].min
break
      end
    end
    debug(&amp;quot;new_pages start at #{start_idx} / #{candidates.size}&amp;quot;)
    candidates[start_idx..candidates.length]
  end
  
  def pending_updates?
    !@all_dents.map(&amp;amp;:first).include?(@all_pages.first)
  end
  
  private
  
  # Return an &amp;lt;tt&amp;gt;Atom::Feed&amp;lt;/tt&amp;gt; object from a given +url+
  def atom_read(url)
    Atom::Feed.new(Net::HTTP.get(URI.parse(url)))
  end
  
  # Print a debugging message to +STDERR+
  def debug(message = &amp;quot;debug&amp;quot;)
    $stderr.puts(&amp;quot;p0wn1e &amp;quot; &amp;lt;&amp;lt; message) if $DEBUG
  end
  
  # Return [ page_name, notice_id ] from upstream
  def find_last_update
    read_identica_feed.first
  end
  
  # Open HTTP connection to identi.ca API for posting updates
  def http_post_connect
    debug(&amp;quot;preparing HTTPS connection to POST&amp;quot;)
    http = Net::HTTP.new(POST_URI.host, POST_URI.port)
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
    http.use_ssl = true
    http
  end
 
  # Return an Array of [ page_name, notice_id ]
  # for all entries corresponding to wiki new pages dents
  def read_identica_feed
    feed = atom_read(DENT_URI.sub(/__USER__/,@user))
    debug(&amp;quot;got feed #{feed.title} with #{feed.entries.size} entries&amp;quot;)
    feed.entries.map do |entry|
      if entry.title =~ %r{^#{@@dentr}$}
[ $1, entry.id.sub(/.*\//,'').to_i ]
      end
    end.compact || []
  rescue Exception =&amp;gt; e
    debug(&amp;quot;P0wn1e can't haz atoms: [#{e.class}] #{e.message}&amp;quot;)
    sleep(@@delay)
    retry
  end
  
  # Return an Array of [ last_updated_page_name, all_entries ]
  def read_new_pages_feed
    feed = atom_read(@feed_uri)
    debug(&amp;quot;got feed #{feed.title} with #{feed.entries.size} entries&amp;quot;)
    [feed.entries.first.title, feed.entries]
  rescue Exception =&amp;gt; e
    error = &amp;quot;P0wn1e can't haz atoms: [#{e.class}] #{e.message}&amp;quot;
    sleep(@@delay)
    retry
  end
  
  # Fetch identi.ca and wiki atom feeds from upstream
  def refresh_all_feeds
    debug(&amp;quot;refreshing identi.ca feed&amp;quot;)
    @all_dents = read_identica_feed
    @last_update = @all_dents.first || ['',0]
    debug(&amp;quot;refreshing new pages feed&amp;quot;)
    @all_pages = read_new_pages_feed
    debug(&amp;quot;computing new pages&amp;quot;)
    @new_pages = new_pages
    debug(&amp;quot;refresh_all_feeds done&amp;quot;)
  end
  
  # Send updates about all newly created pages since last check
  def update
    debug(&amp;quot;starting update&amp;quot;)
    while (page = @new_pages.shift) != nil
      page_name, author, link = page
      dent(@@dent % [author, page_name, link])
# debug(@@dent % [author, page_name, link])
      sleep(@@delay) # Don't post too often, but post all!
    end
    debug(&amp;quot;done updating&amp;quot;)
  end
end
 
# Run P0wn1e! Run!
P0wn1e.new($options).run!
&lt;/pre&gt;</content>
    <author>
      <name>hellekin</name>
      <email>hellekin@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/1033-atom-feed-to-identi-ca-status-updates" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor56403</id>
    <published>2008-10-28T14:52:13-07:00</published>
    <title>[Ruby] On route spec'ing</title>
    <content type="html">&lt;p&gt;This version is more solid&lt;/p&gt;

&lt;pre&gt;# Add this to spec/spec_helper.rb
# Use as:
#   check_route_for(:route_name =&amp;gt; 'foo', :route_path =&amp;gt; '/foo/:bar/baz/:quuq', :controller =&amp;gt; 'foo', :action =&amp;gt; 'foos', :bar =&amp;gt; 'BAR', :quux =&amp;gt; 'Moo')

Spec::Runner.configure do |config|

# [snip]

  def interpreted_route_path(path, params)
    params ||= {}
    path.gsub(/:([^\/]+)/) { |b| params[$1.to_sym] }
  end
  
  def check_routing_for(options)
    route_name = options.delete(:route_name) # map.#{route_name}
    route_path = options.delete(:route_path) # /some/action/:param
    controller = options.delete(:controller) # some_controller
    action     = options.delete(:action)     # some_action
    
    %w(route_name route_path controller action).each do |required_key|
      next unless instance_eval(required_key).nil?
      raise ArgumentError, &amp;quot;check_routing_for: missing required key #{required_key} (:route_name, :route_path, :controller, :action)&amp;quot;
    end
    
    class_eval do
      describe &amp;quot;map.#{route_name}&amp;quot; do
        before do
          @route_hash = (options || {}).merge({ :controller =&amp;gt; controller, :action =&amp;gt; action })
        end
        it &amp;quot;routes to #{route_path}&amp;quot; do
          route_for(@route_hash).should == interpreted_route_path(route_path, options)
        end
        it &amp;quot;recognizes #{(options || {}).merge({ :controller =&amp;gt; controller, :action =&amp;gt; action }).inspect}&amp;quot; do
          params_from(:get, interpreted_route_path(route_path, options)).should == @route_hash
        end
      end
    end
  end    

end # Spec::Runner.configure block
&lt;/pre&gt;</content>
    <author>
      <name>hellekin</name>
      <email>hellekin@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/565-route-spec-ing/refactors/56403" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor56367</id>
    <published>2008-10-27T23:00:39-07:00</published>
    <title>[Ruby] On route spec'ing</title>
    <content type="html">&lt;p&gt;Here is the final final version ;o)&lt;/p&gt;

&lt;pre&gt;## Put that into spec/spec_helper.rb

  def interpreted_route_path(path, params)
    path.gsub(/:([^\/]+)/) { |b| params[$1.to_sym] }
  end

  def check_routing_for(options)
    route_name = options.delete(:route_name)
    route_path = options.delete(:route_path)
    controller, action = options.delete(:controller), options.delete(:action)

    class_eval do
      describe &amp;quot;map.#{route_name}&amp;quot; do
        before do
          @route_hash = { :controller =&amp;gt; controller, :action =&amp;gt; action }.merge(options)
        end
        it &amp;quot;Routes to #{route_path}&amp;quot; do
          route_for(@route_hash).should == interpreted_route_path(route_path, options)
        end
        it &amp;quot;Recognizes #{@route_hash.inspect}&amp;quot; do
          params_from(:get, interpreted_route_path(route_path, options)).should == @route_hash
        end
      end
    end
  end
&lt;/pre&gt;</content>
    <author>
      <name>hellekin</name>
      <email>hellekin@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/565-route-spec-ing/refactors/56367" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor56365</id>
    <published>2008-10-27T22:37:32-07:00</published>
    <title>[Ruby] On route spec'ing</title>
    <content type="html">&lt;p&gt;Hmmm line 13 is wrong!&lt;/p&gt;

&lt;pre&gt;@route_hash = { :controller =&amp;gt; controller, :action =&amp;gt; action }.merge(options)
&lt;/pre&gt;</content>
    <author>
      <name>hellekin</name>
      <email>hellekin@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/565-route-spec-ing/refactors/56365" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor56364</id>
    <published>2008-10-27T22:31:42-07:00</published>
    <title>[Ruby] On route spec'ing</title>
    <content type="html">&lt;p&gt;So, here's the final version, thanks to Kyle and underflow&lt;/p&gt;

&lt;pre&gt;  def interpreted_route_path(path, params)
    path.gsub(/:([^\/]+)/) { |b| params[$1.to_sym] }
  end

  def check_routing_for(options)
    route_name = options.delete(:route_name)
    route_path = options.delete(:route_path)
    controller, action = options.delete(:controller), options.delete(:action)

    class_eval do
      describe &amp;quot;map.#{route_name}&amp;quot; do
        before do
          @route_hash = { :controller =&amp;gt; controller, :action =&amp;gt; action.gsub(/(:\w+)/, &amp;quot;#{options[&amp;quot; + '\1' + &amp;quot;]}&amp;quot;) }.merge(options)
        end
        it &amp;quot;Routes to #{route_path}&amp;quot; do
          route_for(@route_hash).should == interpreted_route_path(route_path, options)
        end
        it &amp;quot;Recognizes #{@route_hash.inspect}&amp;quot; do
          params_from(:get, interpreted_route_path(route_path, options)).should == @route_hash
        end
      end
    end
  end
&lt;/pre&gt;</content>
    <author>
      <name>hellekin</name>
      <email>hellekin@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/565-route-spec-ing/refactors/56364" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor56363</id>
    <published>2008-10-27T22:17:07-07:00</published>
    <title>[Ruby] On route spec'ing</title>
    <content type="html">&lt;p&gt;Ok, here's one solution, but... ahem... I don't understand it :)&lt;/p&gt;

&lt;pre&gt;## So, we replace our interpreted_route_path

  def interpreted_route_path(path, params)
    path.gsub(/:([^\/]+)/) { |b| params[b[1..-1].to_sym] }
  end


&amp;gt;&amp;gt; path =&amp;quot;/:foo/bar/:baz&amp;quot;
=&amp;gt; &amp;quot;/:foo/bar/:baz&amp;quot;
&amp;gt;&amp;gt; params = { :foo =&amp;gt; &amp;quot;FOO&amp;quot;, :baz =&amp;gt; &amp;quot;BAZ&amp;quot; }
=&amp;gt; {:foo=&amp;gt;&amp;quot;FOO&amp;quot;, :baz=&amp;gt;&amp;quot;BAZ&amp;quot;}
&amp;gt;&amp;gt; path.gsub(/:([^\/]+)/) { |b| params[b[1..-1].to_sym] }
=&amp;gt; &amp;quot;/FOO/bar/BAZ&amp;quot;
&amp;gt;&amp;gt; path.gsub(/:([^\/]+)/) { |b| b }
=&amp;gt; &amp;quot;/:foo/bar/:baz&amp;quot;
&amp;gt;&amp;gt; path.gsub(/:([^\/]+)/) { |b| b.upcase }
=&amp;gt; &amp;quot;/:FOO/bar/:BAZ&amp;quot;
&amp;gt;&amp;gt; path.gsub(/:([^\/]+)/) { |b| &amp;quot;--#{b}--&amp;quot; }
=&amp;gt; &amp;quot;/--:foo--/bar/--:baz--&amp;quot;
&amp;gt;&amp;gt; path.gsub(/:[^\/]+/) { |b| &amp;quot;--#{b}--&amp;quot; }
=&amp;gt; &amp;quot;/--:foo--/bar/--:baz--&amp;quot;
&amp;gt;&amp;gt; path.gsub(/:[^\/]+/) { |b| &amp;quot;--#{params[b]}--&amp;quot; }
=&amp;gt; &amp;quot;/----/bar/----&amp;quot;
&amp;gt;&amp;gt; path.gsub(/:[^\/]+/) { |b| &amp;quot;--#{params[b.to_sym]}--&amp;quot; }
=&amp;gt; &amp;quot;/----/bar/----&amp;quot;
&amp;gt;&amp;gt; path.gsub(/:[^\/]+/) { |b| &amp;quot;--#{params[b[1..-1].to_sym]}--&amp;quot; }
=&amp;gt; &amp;quot;/--FOO--/bar/--BAZ--&amp;quot;
&lt;/pre&gt;</content>
    <author>
      <name>hellekin</name>
      <email>hellekin@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/565-route-spec-ing/refactors/56363" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor56362</id>
    <published>2008-10-27T22:16:48-07:00</published>
    <title>[Ruby] On route spec'ing</title>
    <content type="html">&lt;p&gt;Ok, here's one solution, but... ahem... I don't understand it :)&lt;/p&gt;

&lt;pre&gt;## So, we replace our interpreted_route_path

  def interpreted_route_path(path, params)
    path.gsub(/:([^\/]+)/) { |b| params[b[1..-1].to_sym] }
  end


&amp;gt;&amp;gt; path =&amp;quot;/:foo/bar/:baz&amp;quot;
=&amp;gt; &amp;quot;/:foo/bar/:baz&amp;quot;
&amp;gt;&amp;gt; params = { :foo =&amp;gt; &amp;quot;FOO&amp;quot;, :baz =&amp;gt; &amp;quot;BAZ&amp;quot; }
=&amp;gt; {:foo=&amp;gt;&amp;quot;FOO&amp;quot;, :baz=&amp;gt;&amp;quot;BAZ&amp;quot;}
&amp;gt;&amp;gt; path.gsub(/:([^\/]+)/) { |b| params[b[1..-1].to_sym] }
=&amp;gt; &amp;quot;/FOO/bar/BAZ&amp;quot;
&amp;gt;&amp;gt; path.gsub(/:([^\/]+)/) { |b| b }
=&amp;gt; &amp;quot;/:foo/bar/:baz&amp;quot;
&amp;gt;&amp;gt; path.gsub(/:([^\/]+)/) { |b| b.upcase }
=&amp;gt; &amp;quot;/:FOO/bar/:BAZ&amp;quot;
&amp;gt;&amp;gt; path.gsub(/:([^\/]+)/) { |b| &amp;quot;--#{b}--&amp;quot; }
=&amp;gt; &amp;quot;/--:foo--/bar/--:baz--&amp;quot;
&amp;gt;&amp;gt; path.gsub(/:[^\/]+/) { |b| &amp;quot;--#{b}--&amp;quot; }
=&amp;gt; &amp;quot;/--:foo--/bar/--:baz--&amp;quot;
&amp;gt;&amp;gt; path.gsub(/:[^\/]+/) { |b| &amp;quot;--#{params[b]}--&amp;quot; }
=&amp;gt; &amp;quot;/----/bar/----&amp;quot;
&amp;gt;&amp;gt; path.gsub(/:[^\/]+/) { |b| &amp;quot;--#{params[b.to_sym]}--&amp;quot; }
=&amp;gt; &amp;quot;/----/bar/----&amp;quot;
&amp;gt;&amp;gt; path.gsub(/:[^\/]+/) { |b| &amp;quot;--#{params[b[1..-1].to_sym]}--&amp;quot; }
=&amp;gt; &amp;quot;/--FOO--/bar/--BAZ--&amp;quot;
&lt;/pre&gt;</content>
    <author>
      <name>hellekin</name>
      <email>hellekin@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/565-route-spec-ing/refactors/56362" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Code565</id>
    <published>2008-10-27T22:00:49-07:00</published>
    <updated>2008-10-28T14:52:14-07:00</updated>
    <title>[Ruby] route spec'ing</title>
    <content type="html">&lt;p&gt;I'm trying to extract a pattern from rails routes rspec'ing into a helper. &lt;/p&gt;

&lt;p&gt;The helper works great and makes it nice to read/write routing specs (only for :get right now) such as shown below. 
&lt;br /&gt;But the &amp;quot;interpreted_route_path&amp;quot; part really sucks. Any better ways?&lt;/p&gt;

&lt;pre&gt;## This part is ugly!
&amp;gt;&amp;gt; path
=&amp;gt; &amp;quot;/:foo/bar/:baz&amp;quot;
&amp;gt;&amp;gt; params
=&amp;gt; {:foo=&amp;gt;&amp;quot;FOO&amp;quot;, :baz=&amp;gt;&amp;quot;BAZ&amp;quot;}
&amp;gt;&amp;gt; path.split(&amp;quot;/&amp;quot;).map { |v| (params[v[1,v.length].to_sym] if !v.empty? &amp;amp;&amp;amp; v[0] == ':'[0]) || v }.join('/')
=&amp;gt; &amp;quot;/FOO/bar/BAZ&amp;quot;
&amp;gt;&amp;gt; 


## in spec/spec_helper.rb

  def interpreted_route_path(path, params)
    path.split('/').map { |v| (params[v[1,v.length].to_sym] if !v.empty? &amp;amp;&amp;amp; v[0] == ':'[0]) || v }.join('/')
  end

  # To check map.root:
  # use as: check_routing_for(:route_name =&amp;gt; 'root', :route_path =&amp;gt; '/', :controller =&amp;gt; 'foo', :action =&amp;gt; 'bar')

  def check_routing_for(options)
    route_name = options.delete(:route_name)
    route_path = options.delete(:route_path)
    controller, action = options.delete(:controller), options.delete(:action)
    
    class_eval do
      describe &amp;quot;map.#{route_name}&amp;quot; do
        before do
          @route_hash = { :controller =&amp;gt; controller, :action =&amp;gt; action }.merge(options)
        end
        it &amp;quot;Routes to #{route_path}&amp;quot; do
          route_for(@route_hash).should == interpreted_route_path(route_path, options)
        end
        it &amp;quot;Recognizes #{@route_hash.inspect}&amp;quot; do
          params_from(:get, interpreted_route_path(route_path, options)).should == @route_hash
        end
      end
    end
  end    

&lt;/pre&gt;</content>
    <author>
      <name>hellekin</name>
      <email>hellekin@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/565-route-spec-ing" rel="alternate"/>
  </entry>
</feed>

