# Testing Rails: problem running a Gruff sample

**URL:** <https://www.ruby-forum.com/t/testing-rails-problem-running-a-gruff-sample/53334>\
**Category:** Ruby\
**Created:** [February 1, 2006, 10:57pm UTC](https://www.ruby-forum.com/t/testing-rails-problem-running-a-gruff-sample/53334 "2006-02-01T22:57:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjlyders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/58f4c7/32.png) [@rjlyders](https://www.ruby-forum.com/u/rjlyders)\
**Post date:** [February 1, 2006, 10:57pm UTC](https://www.ruby-forum.com/t/testing-rails-problem-running-a-gruff-sample/53334/1 "2006-02-01T22:57:39Z")

</div>

Hi All,

I get errors when I try to run a Gruff sample for my WinXP/SP2 system  
and  
get an error which I can’t fathom.  
The sample is “Code Sample” from  
[http://nubyonrails.topfunky.com/pages/gruff](http://nubyonrails.topfunky.com/pages/gruff)  
(scroll down to find it). I call it GraphicsTest.rb and display it  
below.

When I test it from within SciTE, I get:

> ruby GraphicsTest.rb  
> GraphicsTest.rb:6: uninitialized constant Gruff (NameError)  
> Exit code: 1

Months ago, I had Gem, Ruby, FxRuby, Rails, etc. all beautifully  
installed  
and working. I believe the GraphicsTest.rb sample ran fine at that  
time.  
Then sometime later I had a brain cramp and deleted the entire  
installation.  
Or maybe I was a victim of alien invaders 🙂

I have now reinstalled everything using the one-click installer 1.8.2-15  
Stable Release. Shown below is the list of installed components  
according to  
“gem list --local”.

I ran simple tests on the various components (except Gruff) successfully  
until I tried to test Rails using the above sample. Any suggestions as  
to  
how I might get this test running properly?

–  
Regards,  
Richard

\*\*\* LOCAL GEMS \*\*\*  
actionmailer (1.1.5)  
actionpack (1.11.2)  
actionwebservice (1.0.0)  
activerecord (1.13.2)  
activesupport (1.2.5)  
fxri (0.3.2)  
fxruby (1.4.4, 1.2.6)  
gruff (0.0.9)  
rails (1.0.0)  
rake (0.7.0)  
sources (0.0.1)

=== GraphicTest.rb ===  
#!/usr/bin/ruby

require ‘rubygems’  
require ‘gruff’

g = Gruff::Line.new  
g.title = “My Graph”

g.data(“Apples”, [1, 2, 3, 4, 4, 3])  
g.data(“Oranges”, [4, 8, 7, 9, 8, 9])  
g.data(“Watermelon”, [2, 3, 1, 5, 6, 8])  
g.data(“Peaches”, [9, 9, 10, 8, 7, 9])

g.labels = {0 =\> ‘2003’, 2 =\> ‘2004’, 4 =\> ‘2005’}

g.write(‘my\_fruity\_graph.png’)

---

<div class="post-metadata">

**Author:** ![rjlyders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/58f4c7/32.png) [@rjlyders](https://www.ruby-forum.com/u/rjlyders)\
**Post date:** [February 1, 2006, 11:39pm UTC](https://www.ruby-forum.com/t/testing-rails-problem-running-a-gruff-sample/53334/2 "2006-02-01T23:39:25Z")

</div>

Richard L. wrote:

> Hi All,
> 
> I get errors when I try to run a Gruff sample for my WinXP/SP2 system  
> and  
> get an error which I can’t fathom.  
> The sample is “Code Sample” from  
> [http://nubyonrails.topfunky.com/pages/gruff](http://nubyonrails.topfunky.com/pages/gruff)  
> (scroll down to find it). I call it GraphicsTest.rb and display it  
> below.
> 
> When I test it from within SciTE, I get:
> 
> > ruby GraphicsTest.rb  
> > GraphicsTest.rb:6: uninitialized constant Gruff (NameError)  
> > Exit code: 1

I ran into the same issue and resolved it as follows:

You need to have RMagick installed and configured.

Instructions to install Rmagick on windows are here:  
[http://rmagick.rubyforge.org/install-faq.html#win](http://rmagick.rubyforge.org/install-faq.html#win)

However for the Rmagick install to work gem must be at 0.8.11 level.

In my case gem --version reported 0.8.10

So, I did the following to get gem updated:

gem install rubygems-update  
update\_rubygems

That took care of gem --version (reports 0.8.11)

Then I did the following:

downloaded RMagick-1.9.2-IM-6.2.4-6-win32.zip from the rubyforge site

unzipped it, then ran the following commands from the directory where  
the files where unzipped to

gem -install RMagick-win32-1.9.2-mswin32.gem  
postinstall.rb

Then ran a simple standalone program (same as the one you tried) that  
used gruff and voila! everything worked.

Adding it to my test Rails application was a breeze after that.

Hope that helps.

Raj

---

<div class="post-metadata">

**Author:** ![rjlyders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/58f4c7/32.png) [@rjlyders](https://www.ruby-forum.com/u/rjlyders)\
**Post date:** [February 3, 2006, 2:19am UTC](https://www.ruby-forum.com/t/testing-rails-problem-running-a-gruff-sample/53334/3 "2006-02-03T02:19:57Z")

</div>

Hi Raj.

> You need to have RMagick installed and configured.

I didn’t get a response in the first day after my post, so I thought  
the  
Gruff wasn’t of much interest to folks on this NG. I emailed Geoffrey  
Grosenbach, the Gruff developer, directly and he was kind enough to tell  
me  
the same thing, but he concluded “(I need to put together a simple  
RMagick-only script for testing as well.)”.

So your detailed guidance on how to install RMagick was very timely,  
indeed – and excellent!

> gem -install RMagick-win32-1.9.2-mswin32.gem

Just in case you post your instructions to some other poor soul, please  
note  
that there’s a hyphen in front of ‘install’.

My “Code Sample” from [http://nubyonrails.topfunky.com/pages/gruff](http://nubyonrails.topfunky.com/pages/gruff) worked  
fine: it created a .png file in the same directory as the .rbw source  
file.

But another sample from [http://topfunky.net/svn/gruff/test/area\_test.rb](http://topfunky.net/svn/gruff/test/area_test.rb)  
didn’t seem to work. I noted it didn’t include the “require ‘rubygems’”  
that the preceding sample did, but including it didn’t seem to make any  
difference. If you have any take on this, I’d appreciate hearing your  
advice.

> Hope that helps.

It certainly did. Thank you very much for taking the time to post it.

Best wishes,  
Richard

---

<div class="post-metadata">

**Author:** ![rjlyders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/58f4c7/32.png) [@rjlyders](https://www.ruby-forum.com/u/rjlyders)\
**Post date:** [February 22, 2006, 2:25am UTC](https://www.ruby-forum.com/t/testing-rails-problem-running-a-gruff-sample/53334/4 "2006-02-22T02:25:16Z")

</div>

Hi Raj,

> I must have skimmed through this part of your post and did not pay  
> attention to the above point that I should have responded to. Hope this  
> is isnt too late… I was able to run the referenced sample first try  
> without any modifications whatsoever. I did create a test/output  
> directory before I ran the program. That was about it

I abandoned this for a while, so I didn’t notice you latest post. I’ll  
give it another try in the next week or so.

Thanks for the follow-up.

Regards,  
Richard

---

<div class="post-metadata">

**Author:** ![rjlyders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/58f4c7/32.png) [@rjlyders](https://www.ruby-forum.com/u/rjlyders)\
**Post date:** [February 11, 2006, 5:57pm UTC](https://www.ruby-forum.com/t/testing-rails-problem-running-a-gruff-sample/53334/5 "2006-02-11T17:57:36Z")

</div>

Richard L. wrote:

> Hi Raj.  
> …  
> …
> 
> But another sample from [http://topfunky.net/svn/gruff/test/area\_test.rb](http://topfunky.net/svn/gruff/test/area_test.rb)  
> didn’t seem to work. I noted it didn’t include the “require ‘rubygems’”  
> that the preceding sample did, but including it didn’t seem to make any  
> difference. If you have any take on this, I’d appreciate hearing your  
> advice.

Hi Richard,

I must have skimmed through this part of your post and did not pay  
attention to the above point that I should have responded to. Hope this  
is isnt too late… I was able to run the referenced sample first try  
without any modifications whatsoever. I did create a test/output  
directory before I ran the program. That was about it

Raj
