# Why hash not being passed into method?

**URL:** <https://www.ruby-forum.com/t/why-hash-not-being-passed-into-method/151907>\
**Category:** Ruby\
**Created:** [October 27, 2008, 7:17pm UTC](https://www.ruby-forum.com/t/why-hash-not-being-passed-into-method/151907 "2008-10-27T19:17:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marfarma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a3d4f5/32.png) [@marfarma](https://www.ruby-forum.com/u/marfarma)\
**Post date:** [October 27, 2008, 7:17pm UTC](https://www.ruby-forum.com/t/why-hash-not-being-passed-into-method/151907/1 "2008-10-27T19:17:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![marfarma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a3d4f5/32.png) [@marfarma](https://www.ruby-forum.com/u/marfarma)\
**Post date:** [October 27, 2008, 11:00pm UTC](https://www.ruby-forum.com/t/why-hash-not-being-passed-into-method/151907/2 "2008-10-27T23:00:41Z")

</div>

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