Close
Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

PIVOTAL LABS
Standup 06/13/2007

Interesting Things

  • Rails gotcha: Date.parse and Time.parse do not react the same when passed data that can’t be parsed:
<code>
$ script/console
Loading development environment.
>> Time.parse "monkey"
=> Thu Jun 14 08:43:10 PDT 2007
>> Date.parse "monkey"
ArgumentError: 3 elements of civil date are necessary
        from /usr/local/lib/ruby/1.8/date.rb:650:in `new_with_hash'
        from /usr/local/lib/ruby/1.8/date.rb:695:in `parse'
        from (irb):2
>>
</code>
  • Rails gotcha #2: in functional tests, assert_redirected_to can fail if you are not consistent in your “strings vs symbols” notation. Example:
<code>
class MonkeyWranglersController < ActionController
    def index
            redirect_to :controller "monkey_wranglers", :action => :list
    end
end
</code>

Now, the assertions:

<code>
get :index
assert_redirected_to :controller => "monkey_wranglers", :action => :list # passes
###
get :index
assert_redirected_to :controller => "monkey_wranglers", :action => "list" # fails
</code>

Comments
Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *