Why hash not being passed into method?


#1

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


#2

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?)