Reputation: 4702
This is weird, and probably due to me being new to ruby. I have created a gem, it works, all the unit tests work, but when i do the following in irb it can't find the "ingredients" method;
1.9.2-p290 :002 > require "tablecloth"
=> true
1.9.2-p290 :003 > tc = TableCloth.new "1 cup of sugar"
=> #<TableCloth:0x864a728>
1.9.2-p290 :004 > tc.ingredients
NoMethodError: undefined method `ingredients' for #<TableCloth:0x864a728>
from (irb):4
from /home/mikey/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in `<main>'
1.9.2-p290 :005 >
Entire gem is here;
https://github.com/mikeyhogarth/tablecloth
Obviously this is due to me being new to ruby. It's not actually hindering the development, I just want to know why irb can't seem to register that method in this case!
Upvotes: 0
Views: 154
Reputation: 87376
I think you are loading a different, older version of the gem in IRB than you are in your unit tests. Your unit tests probably test the gem code sitting in your development directory, but when you do require "tablecloth"
in IRB it would load the gem that has been installed to your system's gem's directory. If you are using RVM, you can look at the $GEM_HOME environment variable to see what directory that is.
You probably need to run a rake task like rake install
or something like that to install your gem before you can use it in irb.
Upvotes: 2