<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>Elliott Blatt - Home</title>
  <id>tag:www.elliottblatt.com,2008:mephisto/</id>
  <generator uri="http://mephistoblog.com" version="0.7.3">Mephisto Noh-Varr</generator>
  <link href="http://www.elliottblatt.com/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://www.elliottblatt.com/" rel="alternate" type="text/html"/>
  <updated>2008-06-19T14:48:31Z</updated>
  <entry xml:base="http://www.elliottblatt.com/">
    <author>
      <name>elmo</name>
    </author>
    <id>tag:www.elliottblatt.com,2008-03-18:1</id>
    <published>2008-03-18T15:53:00Z</published>
    <updated>2008-06-19T14:48:31Z</updated>
    <category term="bdd"/>
    <category term="growl"/>
    <category term="mac"/>
    <category term="rails"/>
    <category term="rcov"/>
    <category term="rspec"/>
    <category term="tutorial"/>
    <category term="zentest"/>
    <link href="http://www.elliottblatt.com/2008/3/18/bdd-step-by-step" rel="alternate" type="text/html"/>
    <title>a step-by-step guide to establishing a BDD rails environment for your Mac</title>
<content type="html">
            &amp;lt;style&gt;
  pre {
    width:900px;
    color:#fff;
    line-height:1.2em;
    font-size:13px;
    background:#000;
    padding:10px;
  }
&amp;lt;/style&gt;

&lt;p&gt;If you're a rails developer and you've been contemplating making the move to behavior driven development with rails, this will be a good place for you to start.  Below you will find all the major steps necessary to get your  Mac rails development environment all tricked out for BDD, including the much-enjoyed growl notifications.  In addition to the fundamentals, (rspec, rspec_on_rails), it's highly reccomended that you install and configure a variety of supporting software applications (zentest, growl).  What follows will get you up and running -- how you customize further, is up to you.
&lt;/p&gt;

&lt;p&gt;This tutorial assumes that you have a particular rails project that you are working with.  I'll refer to this project as &lt;b&gt;yourproject&gt;&lt;/b&gt;.  Some commands will need to be executed from your project root, while others will need to be run from your home directory -- which I'll refer to as &lt;b&gt;yourcomputer&gt;&lt;/b&gt;.  Still, other commands may be entered from any directory you find yourself in.  Please be aware of which directory you are in when copy commands out of this tutorial, this will save you some headaches.
&lt;/p&gt;
&lt;ol&gt;

&lt;li&gt;&lt;h3&gt;Install the rspec plugin&lt;/h3&gt;
&lt;p&gt;It's also possible to install the rspec gem, but I like to use plugins. &lt;a href=&quot;http://rspec.rubyforge.org/documentation/rails/install.html&quot;&gt;see here for more information about rspec installation&lt;/a&gt;.&lt;/p&gt;
&lt;pre&gt;
yourproject&gt; ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec
&lt;/pre&gt;
&lt;/li&gt;

&lt;li&gt;&lt;h3&gt;Install rspec_on_rails plugin &lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;http://rspec.rubyforge.org/documentation/rails/install.html&quot;&gt;see here for more information about rspec_on_rails installation&lt;/a&gt;.&lt;/p&gt;

&lt;pre&gt;
yourproject&gt; ruby script/plugin install ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec_on_rails
&lt;/pre&gt;
 
&lt;/li&gt;

&lt;li&gt;&lt;h3&gt;Install ZenTest gem&lt;/h3&gt;
&lt;p&gt;You will need to install the ZenTest gem.&lt;/p&gt;
&lt;pre&gt;
yourcomputer&gt;sudo gem install ZenTest
&lt;/pre&gt;
&lt;a href=&quot;http://www.zenspider.com/ZSS/Products/ZenTest/&quot;&gt;see more information on zentest&lt;/a&gt;
&lt;/li&gt;

  &lt;li&gt;&lt;h3&gt;Install and configure growl (and growlnotify)&lt;/h3&gt;
 &lt;ol&gt;
  &lt;li&gt;
   &lt;p&gt;download and install Growl from  &lt;a href=&quot;http://growl.info/&quot;&gt;http://growl.info/&lt;/a&gt;
   &lt;/p&gt;
  &lt;/li&gt;
   &lt;li&gt;NOTE: While configuring &lt;b&gt;growl&lt;/b&gt;, make sure that the check-box labeled 'hide all notifications' is NOT checked. (!) &lt;/li&gt;
   &lt;li&gt;&lt;/h4&gt;Install growlnotify&lt;/h4&gt;
        &lt;p&gt;Your installation of &lt;b&gt;Growl&lt;/b&gt; will give you some extras, one of these extras is called &lt;b&gt;growlnotify&lt;/b&gt;.  Install this in the following manner:&lt;/p&gt;
&lt;pre&gt;
yourcomputer&gt;cd /Volumes/Growl 1.1.2/Extras/growlnotify/
yourcomputer&gt;sudo sh install.sh
&lt;/pre&gt;
    &lt;p&gt;The version numbers shown may be different, to find out where your &lt;b&gt;growlnotify&lt;/b&gt; is located, do the following:
 &lt;pre&gt;yourcomputer&gt;locate growlnotify&lt;/pre&gt;
&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/li&gt;

  &lt;li&gt;&lt;h3&gt;Install redgreen gem&lt;/h3&gt;
    &lt;p&gt;In all honesty, I'm not sure if  you really need to install this or not, I've read conflicting accounts, so, I'm not sure.  I've installed redgreen and it certainly doesn't hurt anything.&lt;/p&gt;
    &lt;pre&gt;yourcomputer&gt;sudo gem install redgreen&lt;/pre&gt;
  &lt;/li&gt;

  &lt;li&gt;&lt;h3&gt;Configure &lt;b&gt;autotest&lt;/b&gt; to work with &lt;b&gt;growlnotify&lt;/b&gt;&lt;/h3&gt;
     &lt;ol&gt;
       &lt;li&gt;in your &lt;b&gt;home (~) directory&lt;/b&gt;  create a hidden file named &lt;b&gt;.autotest&lt;/b&gt; (note the dot).
&lt;pre&gt;
yourcomputer&gt; vi .autotest
&lt;/pre&gt;
&lt;/li&gt;
 &lt;li&gt;&lt;p&gt;copy the following code and paste it into your &lt;b&gt;.autotest&lt;/b&gt; file: (this code has been copied  from http://blog.internautdesign.com/2006/11/12/autotest-growl-goodness ) and slightly modified by me.&lt;/p&gt;
&lt;pre&gt;

module Autotest::Growl

  def self.growl title, msg, img, pri=0, sticky=&quot;&quot;
    system &quot;growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{sticky}&quot;
  end

  Autotest.add_hook :ran_command do |at|
    results = [at.results].flatten.join(&quot;\n&quot;)
    output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+pending)?/)
    if output
      if $~[2].to_i &gt; 0
        growl &quot;Test Results&quot;, &quot;#{output}&quot;, &quot;~/Library/autotest/rails_fail.png&quot;, 2
      else
        growl &quot;Test Results&quot;, &quot;#{output}&quot;, &quot;~/Library/autotest/rails_ok.png&quot;
      end
    end
  end
end
&lt;/pre&gt;
 &lt;/li&gt;
      &lt;li&gt;In your ~/Library directory, create a directory called &lt;b&gt;autotest&lt;/b&gt;
&lt;pre&gt;
 yourcomputer&gt; cd ~/Library
 yourcomputer&gt; mkdir autotest
 &lt;/pre&gt;
      &lt;/li&gt;
       &lt;li&gt;Add these images to the new &lt;b&gt;autotest&lt;/b&gt; directory that you have just created.
           &lt;p&gt;&lt;img src=&quot;http://www.elliottblatt.com/assets/2008/3/18/rails_ok.png&quot;&gt;
                &lt;img src=&quot;http://www.elliottblatt.com/assets/2008/3/18/rails_fail.png&quot;&gt;
         &lt;/p&gt;
       &lt;/li&gt;
     &lt;/ol&gt;
  &lt;/li&gt; 

&lt;/li&gt;&lt;h3&gt;Putting it all together&lt;/h3&gt;
  &lt;ol&gt;
    &lt;li&gt;&lt;h4&gt;start autotest&lt;/h4&gt;
      &lt;pre&gt;
      yourproject&gt; autotest -rails
      &lt;/pre&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;h4&gt;generate your rspec and application scaffolding &lt;/h4&gt;
      &lt;pre&gt;
       yourproject&gt;ruby script/generate rspec
      &lt;/pre&gt;
    &lt;/li&gt;
   &lt;li&gt;At this point, all your spec test results should appear as growl notifications!  I'll be publishing more articles about how to use rspec with rails, so stay tuned.
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/li&gt;

&lt;li&gt;&lt;h3&gt;more resources&lt;/h3&gt;
&lt;ol&gt;
  &lt;li&gt;http://rspec.rubyforge.org/documentation/rails/install.html&lt;/li&gt;
  &lt;li&gt;http://www.zenspider.com/ZSS/Products/ZenTest/&lt;/li&gt;
  &lt;li&gt;http://www.growl.info/&lt;/li&gt;
  &lt;li&gt;http://peepcode.com/&lt;/li&gt;
  &lt;li&gt;http://rspec.rubyforge.org/documentation/index.html&lt;/li&gt;
&lt;/ol&gt; 
&lt;/li&gt;
&lt;/ol&gt;
          </content>  </entry>
</feed>
