Forum: Ruby why hash not being passed into method?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Pauli P. (Guest)
on 2008-10-27 20:17
A rails plugin I'm trying to use has the following pattern of failing
tests:


--- unit test file for editor

def setup
  create_editor!(:role => 'author')
end



--- "test factory" method meant to simplify test writing

def create_editor!(attributes = {})
   default_attributes = {
     # :key => 'value'
   }
   Editor.create! default_attributes.merge(attributes)
end

Using ruby-debug I have confirmed that the value of attributes is nil
inside create_editor!

What's going on?  I don't belief that the plugin creator would have
published it if most of the tests failed.

I can play with the code to figure out how to correctly pass the hash (
I'm a ruby nuby, so the solution is not immediately obvious ) but I'm
curious about why it stopped working.

Any thoughts?

Pauli
Xavier S. (Guest)
on 2008-10-28 00:00
Pauli Price wrote:
> Using ruby-debug I have confirmed that the value of attributes is nil
> inside create_editor!
>
> What's going on?  I don't belief that the plugin creator would have
> published it if most of the tests failed.

Nothing obvious jumps out, please provide more source code (some code we
can execute to see the problem for ourselves?)
This topic is locked and can not be replied to.