# Assert\_routing vs file extensions

**URL:** <https://www.ruby-forum.com/t/assert-routing-vs-file-extensions/131883>\
**Category:** Rails\
**Created:** [March 14, 2008, 3:16am UTC](https://www.ruby-forum.com/t/assert-routing-vs-file-extensions/131883 "2008-03-14T03:16:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phlip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed8c4c/32.png) [@Phlip](https://www.ruby-forum.com/u/Phlip)\
**Post date:** [March 14, 2008, 3:16am UTC](https://www.ruby-forum.com/t/assert-routing-vs-file-extensions/131883/1 "2008-03-14T03:16:51Z")

</div>

Railsers:

Our versions are Rails 1.2.3 on ruby 1.8.6 (2007-09-23 patchlevel 110).

routes.rb contains this:

map.connect ‘/song/:filename\*extension’, :controller =\> ‘frogs’,  
:action =\> ‘index’

and our test contains this:

frog\_id = frog(:african\_bull).id  
assert\_routing “/song/#{frog\_id}.mp3”, :controller =\> ‘frogs’,  
:action =\> ‘index’,  
:filename =\> “#{frog\_id}”,  
:extension =\> [‘mp3’]

That looks perfectly correct, right? Here’s the error message:

The recognized options \<{“extension”=\>[".mp3"],  
“action”=\>“index”,  
“controller”=\>“frogs”,  
“filename”=\>“1”}\> did not match \<{“extension”=\>[“mp3”],  
“action”=\>“index”,  
“controller”=\>“frogs”,  
“filename”=\>“1”}\>, difference: \<{“extension”=\>[“mp3”]}\>

Ooookay. It says the “difference” is the part that’s exactly the same -  
“extension”=\>[“mp3”]!

How to fix?

–  
Phlip

---

<div class="post-metadata">

**Author:** ![Phlip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed8c4c/32.png) [@Phlip](https://www.ruby-forum.com/u/Phlip)\
**Post date:** [March 14, 2008, 4:10am UTC](https://www.ruby-forum.com/t/assert-routing-vs-file-extensions/131883/2 "2008-03-14T04:10:13Z")

</div>

Hi –

On Thu, 13 Mar 2008, Phlip wrote:

> and our test contains this:  
> “action”=\>“index”,  
> “controller”=\>“frogs”,  
> “filename”=\>“1”}\> did not match \<{“extension”=\>[“mp3”],  
> “action”=\>“index”,  
> “controller”=\>“frogs”,  
> “filename”=\>“1”}\>, difference: \<{“extension”=\>[“mp3”]}\>
> 
> Ooookay. It says the “difference” is the part that’s exactly the same -  
> “extension”=\>[“mp3”]!

Yeah, I’ve always loved that one 🙂

> How to fix?

\*extension is mopping up the dot, because filename matches everything  
up to but not including a dot, and \*extension gets everything else  
(and it all gets put into one string, because the dot doesn’t separate  
elements inside the glob).

So you need either :filename.\*extension in the route string, or  
[‘.mp3’] in the test.

David

–  
Upcoming Rails training from David A. Black and Ruby Power and Light:  
ADVANCING WITH RAILS, April 14-17 2008, New York City  
CORE RAILS, June 24-27 2008, London (Skills Matter)  
See [http://www.rubypal.com](http://www.rubypal.com) for details. Berlin dates coming soon!
