<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Clayton Lengel-Zigich</title>
	
	<link>http://www.claytonlz.com</link>
	<description>Ruby on Rails Developer</description>
	<lastBuildDate>Sun, 08 Nov 2009 00:58:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9-rare</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/claytonlengelzigich" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>The Secret to Full Stack Testing with Cucumber and Webrat</title>
		<link>http://feedproxy.google.com/~r/claytonlengelzigich/~3/UE6F4j4r-RA/</link>
		<comments>http://www.claytonlz.com/index.php/2009/11/the-secret-to-full-stack-testing-with-cucumber-and-webrat/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 00:54:48 +0000</pubDate>
		<dc:creator>Clayton</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[bdd]]></category>
		<category><![CDATA[cucumber]]></category>

		<guid isPermaLink="false">http://www.claytonlz.com/?p=318</guid>
		<description><![CDATA[Today I gave a presentation at "Desert Code Camp":http://www.desertcodecamp.com/ about BDD, Cucumber, Webrat and User Stories. If you'd like to find review the slides or download the code I used during the presentation here they are.]]></description>
			<content:encoded><![CDATA[<p></p><p>Today I gave a presentation at <a href="http://www.desertcodecamp.com/">Desert Code Camp</a> about <span class="caps">BDD,</span> Cucumber, Webrat and User Stories. If you&#8217;d like to find review the slides or download the code I used during the presentation here they are.</p>

<h3>Slides and Code</h3>

<p><a href="http://www.claytonlz.com/wp-content/uploads/2009/11/slides.pdf">Desert Code Camp <span class="caps">BDD</span> Presentation Slides</a></p>

<p><a href="http://github.com/clayton/desert-code-camp" target="_self">http://github.com/clayton/desert-code-camp</a></p><img src="http://feeds.feedburner.com/~r/claytonlengelzigich/~4/UE6F4j4r-RA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.claytonlz.com/index.php/2009/11/the-secret-to-full-stack-testing-with-cucumber-and-webrat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.claytonlz.com/index.php/2009/11/the-secret-to-full-stack-testing-with-cucumber-and-webrat/</feedburner:origLink></item>
		<item>
		<title>Cucumber Table Transformations with Factory Girl Sequences</title>
		<link>http://feedproxy.google.com/~r/claytonlengelzigich/~3/uEDjOh2nuTI/</link>
		<comments>http://www.claytonlz.com/index.php/2009/11/cucumber-table-transformations-with-factory-girl-sequences/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 17:33:49 +0000</pubDate>
		<dc:creator>Clayton</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[authlogic]]></category>
		<category><![CDATA[cucumber]]></category>
		<category><![CDATA[factory_girl]]></category>
		<category><![CDATA[transformations]]></category>

		<guid isPermaLink="false">http://www.claytonlz.com/?p=313</guid>
		<description><![CDATA[If you're using "Cucumber":http://cukes.info and you're not using "Transformations":http://wiki.github.com/aslakhellesoy/cucumber/step-argument-transforms you're doing it wrong. I just started using these recently and ran into a problem with creating records using "Factory Girl":http://github.com/thoughtbot/factory_girl factories that made use of sequences. While trying to create multiple "Authlogic":http://github.com/binarylogic/authlogic user records with a unique <tt>email</tt> and unique <tt>single_access_token</tt> using a Cucumber table, the functionality of <tt>Factory.next(:email)</tt> wasn't working correctly, I would always get the same e-mail address. Turns out it was an easy fix, just had to use lazy attributes in my factory.]]></description>
			<content:encoded><![CDATA[<p></p><p>If you&#8217;re using <a href="http://cukes.info">Cucumber</a> and you&#8217;re not using <a href="http://wiki.github.com/aslakhellesoy/cucumber/step-argument-transforms">Transformations</a> you&#8217;re doing it wrong. I just started using these recently and ran into a problem with creating records using <a href="http://github.com/thoughtbot/factory_girl">factory_girl</a> factories that made use of sequences. While trying to create multiple <a href="http://github.com/binarylogic/authlogic">Authlogic</a> user records with a unique <tt>email</tt> and unique <tt>single_access_token</tt> using a Cucumber table, the functionality of <tt>Factory.next(:email)</tt> wasn&#8217;t working correctly, I would always get the same e-mail address. Turns out it was an easy fix, just had to use lazy attributes in my factory.</p>

<h4>The Scenario, Step Definition and Factory</h4>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="" style="font-family:monospace;">  Scenario: Presenter List
    Given the following presenters:
      | Name    | Bio                 | Website              |
      | Clayton | Rails dev @integrum | http://claytonlz.com |
      | Chris   | Scrum @integrum     |                      |
    And I am on the homepage
    When I follow &quot;Presenters&quot;
    Then I should see &quot;Clayton&quot;
    And I should see &quot;Rails dev @integrum&quot;
    And I should see &quot;http://claytonlz.com&quot;
    Then I should see &quot;Chris&quot;
    And I should see &quot;Scrum @integrum&quot;</pre></td></tr></table></div>




<p><strong>My  Step Definition</strong><br />
This uses the Transformation table below:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">Given <span style="color:#006600; font-weight:bold;">/</span>^the following presenters:$<span style="color:#006600; font-weight:bold;">/</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>table<span style="color:#006600; font-weight:bold;">|</span>
  table.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>attrs<span style="color:#006600; font-weight:bold;">|</span>
    Factory.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:user</span>, attrs<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>




<p>This transformation takes a table like the one in my scenario above, and assigns the values to a hash using the actual model attribute names (Name isn&#8217;t an attribute on a user but name is). The regular cucumber step definition &#8220;consumes&#8221; this hash for each entry in the table and passes it to a Factory for creation.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">Transform <span style="color:#006600; font-weight:bold;">/</span>^table:Name,Bio,Website$<span style="color:#006600; font-weight:bold;">/</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>table<span style="color:#006600; font-weight:bold;">|</span>
  table.<span style="color:#9900CC;">hashes</span>.<span style="color:#9900CC;">map</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>hash<span style="color:#006600; font-weight:bold;">|</span>
    <span style="color:#006600; font-weight:bold;">&#123;</span>:name <span style="color:#006600; font-weight:bold;">=&gt;</span> hash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:Name</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#ff3333; font-weight:bold;">:bio</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> hash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:Bio</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#ff3333; font-weight:bold;">:website</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> hash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:Website</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>




<p><strong>My Factory</strong></p>

<p>This is a pretty basic factory for an authlogic user model, I&#8217;m using factory_girl sequences to give me a &#8220;unique&#8221; e-mail and single access token, which are required by Authlogic.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">Factory.<span style="color:#9900CC;">define</span> <span style="color:#ff3333; font-weight:bold;">:user</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>user<span style="color:#006600; font-weight:bold;">|</span>
  user.<span style="color:#9900CC;">email</span> Factory.<span style="color:#9966CC; font-weight:bold;">next</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:email</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  user.<span style="color:#9900CC;">name</span> <span style="color:#996600;">&quot;&quot;</span>
  user.<span style="color:#9900CC;">bio</span> <span style="color:#996600;">&quot;&quot;</span>
  user.<span style="color:#9900CC;">website</span> <span style="color:#996600;">&quot;&quot;</span>
  user.<span style="color:#9900CC;">password</span> <span style="color:#996600;">&quot;password&quot;</span>
  user.<span style="color:#9900CC;">password_confirmation</span> <span style="color:#996600;">&quot;password&quot;</span>
  user.<span style="color:#9900CC;">single_access_token</span> Factory.<span style="color:#9966CC; font-weight:bold;">next</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:single_access_token</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>




<h4>The problem</h4>

<p>The above scenario will fail when it tries to create the user records via the factories. You&#8217;ll see a validation error about how the user model requires a unique e-mail and single access token. You&#8217;ll be wondering, &#8220;hey why are my sequences working?&#8221;. When you inspect the log you&#8217;ll see that they are in fact <span class="caps">NOT </span>working.</p>

<h4>The Quick Answer</h4>

<p>The easy answer to this is that you need to use lazy attributes in your factory for the sequences so that they are loaded each time instead of once.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">Factory.<span style="color:#9900CC;">define</span> <span style="color:#ff3333; font-weight:bold;">:user</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>user<span style="color:#006600; font-weight:bold;">|</span>
  user.<span style="color:#9900CC;">email</span> <span style="color:#006600; font-weight:bold;">&#123;</span> Factory.<span style="color:#9966CC; font-weight:bold;">next</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:email</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
  user.<span style="color:#9900CC;">name</span> <span style="color:#996600;">&quot;&quot;</span>
  user.<span style="color:#9900CC;">bio</span> <span style="color:#996600;">&quot;&quot;</span>
  user.<span style="color:#9900CC;">website</span> <span style="color:#996600;">&quot;&quot;</span>
  user.<span style="color:#9900CC;">password</span> <span style="color:#996600;">&quot;password&quot;</span>
  user.<span style="color:#9900CC;">password_confirmation</span> <span style="color:#996600;">&quot;password&quot;</span>
  user.<span style="color:#9900CC;">single_access_token</span> <span style="color:#006600; font-weight:bold;">&#123;</span> Factory.<span style="color:#9966CC; font-weight:bold;">next</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:single_access_token</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>




<p><strong>Notice the curly braces around the sequences</strong></p>

<h4>The Longer Answer</h4>

<p>The cucumber rdoc explains the Transform functionality, albeit somewhat hard to understand.</p>

<blockquote><p>Registers a proc that will be called with a step definition argument if it matches the pattern passed as the first argument to Transform. Alternatively, if the pattern contains captures then they will be yielded as arguments to the provided proc. The return value of the proc is consequently yielded to the step definition.</p></blockquote>

<p>I think the issue comes from something with the way these Procs are created, called and also their scope with regard to the step definition etc. I don&#8217;t think my ruby-fu is strong enough to give a good explanation but maybe I&#8217;m going in the right direction.</p><img src="http://feeds.feedburner.com/~r/claytonlengelzigich/~4/uEDjOh2nuTI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.claytonlz.com/index.php/2009/11/cucumber-table-transformations-with-factory-girl-sequences/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.claytonlz.com/index.php/2009/11/cucumber-table-transformations-with-factory-girl-sequences/</feedburner:origLink></item>
		<item>
		<title>Missing host to link to! Please provide :host parameter</title>
		<link>http://feedproxy.google.com/~r/claytonlengelzigich/~3/WhAqV_LzxAE/</link>
		<comments>http://www.claytonlz.com/index.php/2009/11/authlogic-activation-host-parameter-gotcha/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 08:53:46 +0000</pubDate>
		<dc:creator>Clayton</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[activation]]></category>
		<category><![CDATA[authlogic]]></category>
		<category><![CDATA[gotcha]]></category>

		<guid isPermaLink="false">http://www.claytonlz.com/?p=305</guid>
		<description><![CDATA[If you've followed my version of the "authlogic account activation tutorial":http://www.claytonlz.com/index.php/2009/07/authlogic-account-activation-tutorial/ or the "original version":http://github.com/matthooks/authlogic-activation-tutorial by Matt Hooks you might have run into this error]]></description>
			<content:encoded><![CDATA[<p></p><p>If you&#8217;ve followed my version of the <a href="http://www.claytonlz.com/index.php/2009/07/authlogic-account-activation-tutorial/">authlogic account activation tutorial</a> or the <a href="http://github.com/matthooks/authlogic-activation-tutorial">original version</a> by Matt Hooks you might have run into this error:</p>

<code>
Missing host to link to! Please provide :host parameter or set default_url_options[:host] when sending emails
</code>

<p>When authlogic sends e-mails with the account activation link, it uses a <tt>url_for</tt> helper to build that link. Because the &#8220;Notifier&#8221; mailer is an instance of <tt>ActionMailer::Base</tt> and not <tt>ActionController::Base</tt> it doesn&#8217;t know what the <tt>host</tt> parameter of the <span class="caps">URL </span>should be, so you have to tell it explicitly.</p>

<p>Put the following into your <tt>environments/development.rb</tt> and <tt>environments/test.rb</tt>:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># This assumes you're running your local development server on port 3000 via script/server</span>
config.<span style="color:#9900CC;">action_mailer</span>.<span style="color:#9900CC;">default_url_options</span> = <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:host</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;127.0.0.1:3000&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span></pre></td></tr></table></div>




<p>Put this into your <tt>environments/production.rb</tt>:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># Replace example.org with your actual domain name</span>
config.<span style="color:#9900CC;">action_mailer</span>.<span style="color:#9900CC;">default_url_options</span> = <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:host</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;example.org&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span></pre></td></tr></table></div>
<img src="http://feeds.feedburner.com/~r/claytonlengelzigich/~4/WhAqV_LzxAE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.claytonlz.com/index.php/2009/11/authlogic-activation-host-parameter-gotcha/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.claytonlz.com/index.php/2009/11/authlogic-activation-host-parameter-gotcha/</feedburner:origLink></item>
		<item>
		<title>Does the Chronic Time Parsing Library Break with DST Changes?</title>
		<link>http://feedproxy.google.com/~r/claytonlengelzigich/~3/PjnHItvVDVc/</link>
		<comments>http://www.claytonlz.com/index.php/2009/11/ruby-chronic-dst-error/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 17:30:15 +0000</pubDate>
		<dc:creator>Clayton</dc:creator>
				<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[chronic]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[weirdness]]></category>

		<guid isPermaLink="false">http://www.claytonlz.com/?p=298</guid>
		<description><![CDATA[I've been troubleshooting a problem on an existing application for the last week or so that deals with the parsing of dates using the <a href="http://chronic.rubyforge.org/">Chronic</a> time parsing library. Today the problem magically solved itself, without me doing anything. These types of self solving problems are usually more frustrating than problems you can't solve at all, so I took a little extra time to experiment with the particular date format I was using and found what might be a problem with the Chronic library when it gets to the "fall back" DST change in the fall.]]></description>
			<content:encoded><![CDATA[<p></p><p>I&#8217;ve been troubleshooting a problem on an existing application for the last week or so that deals with the parsing of dates using the <a href="http://chronic.rubyforge.org/">Chronic</a> time parsing library. Today the problem magically solved itself, without me doing anything. These types of self solving problems are usually more frustrating than problems you can&#8217;t solve at all, so I took a little extra time to experiment with the particular date format I was using and found what might be a problem with the Chronic library when it gets to the &#8220;fall back&#8221; DST change in the fall.</p>

<h4>Do You Observe <span class="caps">DST</span>?</h4>

<p>It looks like if your local environment is set to a timezone which observes <span class="caps">DST, </span>like Eastern Standard Time for instance, you get a chunk of dates around the switch in the fall where Chronic returns <tt>nil</tt> instead of the correct date. If you&#8217;re on a machine where the timezone is set to an area which does not observe <span class="caps">DST, </span>like Arizona, you won&#8217;t be able to replicate this problem.</p>

<h4>Replicating the problem</h4>

<p>Install the latest version of Chronic.</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> chronic</pre></div></div>




<p>Fire up <tt>irb</tt> and give the following a shot.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">require <span style="color: #ff0000;">'chronic'</span>
<span style="color: #7a0874; font-weight: bold;">&#40;</span>Date.parse<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;2009-01-01&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>..Date.parse<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;2009-12-31&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>.each <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #000000; font-weight: bold;">|</span>d<span style="color: #000000; font-weight: bold;">|</span>
  puts Chronic.parse<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;next tuesday 6am&quot;</span>, :now =<span style="color: #000000; font-weight: bold;">&gt;</span> d<span style="color: #7a0874; font-weight: bold;">&#41;</span>
end</pre></td></tr></table></div>




<p>With <tt>ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]</tt> on Ubuntu and my timezone set to <span class="caps">EST</span>/New York. I see a bunch of Tuesdays and then a blank section around the end of October / beginning of November.</p>



<pre>
...snip...
Tue Oct 20 06:00:00 -0400 2009
Tue Oct 20 06:00:00 -0400 2009
Tue Oct 27 06:00:00 -0400 2009
Tue Oct 27 06:00:00 -0400 2009
Tue Oct 27 06:00:00 -0400 2009
Tue Oct 27 06:00:00 -0400 2009
Tue Oct 27 06:00:00 -0400 2009
Tue Oct 27 06:00:00 -0400 2009
Tue Oct 27 06:00:00 -0400 2009
nil
nil
nil
nil
nil
nil
Tue Nov 03 06:00:00 -0500 2009
Tue Nov 10 06:00:00 -0500 2009
Tue Nov 10 06:00:00 -0500 2009
Tue Nov 10 06:00:00 -0500 2009
Tue Nov 10 06:00:00 -0500 2009
Tue Nov 10 06:00:00 -0500 2009
Tue Nov 10 06:00:00 -0500 2009
Tue Nov 10 06:00:00 -0500 2009
Tue Nov 17 06:00:00 -0500 2009
Tue Nov 17 06:00:00 -0500 2009
Tue Nov 17 06:00:00 -0500 2009
...snip...
</pre>



<p>If you change your timezone to something like <span class="caps">MST</span>/Arizona you&#8217;ll see this</p>



<pre>
...snip...
Tue Oct 20 06:00:00 -0400 2009
Tue Oct 20 06:00:00 -0400 2009
Tue Oct 27 06:00:00 -0400 2009
Tue Oct 27 06:00:00 -0400 2009
Tue Oct 27 06:00:00 -0400 2009
Tue Oct 27 06:00:00 -0400 2009
Tue Oct 27 06:00:00 -0400 2009
Tue Oct 27 06:00:00 -0400 2009
Tue Oct 27 06:00:00 -0400 2009
Tue Nov 03 06:00:00 -0500 2009
Tue Nov 03 06:00:00 -0500 2009
Tue Nov 03 06:00:00 -0500 2009
Tue Nov 03 06:00:00 -0500 2009
Tue Nov 03 06:00:00 -0500 2009
Tue Nov 03 06:00:00 -0500 2009
Tue Nov 03 06:00:00 -0500 2009
Tue Nov 10 06:00:00 -0500 2009
Tue Nov 10 06:00:00 -0500 2009
Tue Nov 10 06:00:00 -0500 2009
Tue Nov 10 06:00:00 -0500 2009
Tue Nov 10 06:00:00 -0500 2009
Tue Nov 10 06:00:00 -0500 2009
Tue Nov 10 06:00:00 -0500 2009
Tue Nov 17 06:00:00 -0500 2009
Tue Nov 17 06:00:00 -0500 2009
Tue Nov 17 06:00:00 -0500 2009
...snip...
</pre>



<h4>What&#8217;s the Fix?</h4>

<p>None as far as I know. I&#8217;m sure one could dig into the internals of the library and figure out how to deal with this problem, but I&#8217;m not up for that right now.</p><img src="http://feeds.feedburner.com/~r/claytonlengelzigich/~4/PjnHItvVDVc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.claytonlz.com/index.php/2009/11/ruby-chronic-dst-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.claytonlz.com/index.php/2009/11/ruby-chronic-dst-error/</feedburner:origLink></item>
		<item>
		<title>Make Fun of Your Client To Prevent Defects</title>
		<link>http://feedproxy.google.com/~r/claytonlengelzigich/~3/iG9oukeTk7E/</link>
		<comments>http://www.claytonlz.com/index.php/2009/10/make-fun-of-your-client/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 17:30:18 +0000</pubDate>
		<dc:creator>Clayton</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ideas]]></category>
		<category><![CDATA[Riffs]]></category>
		<category><![CDATA[clients]]></category>
		<category><![CDATA[communication]]></category>

		<guid isPermaLink="false">http://www.claytonlz.com/?p=283</guid>
		<description><![CDATA[One thing I've always heard about learning a new language is that you can't consider yourself fully fluent until you can tell a joke. Telling a joke requires the understanding of homonyms and how words flow together. "So a guy walks into a bar..." sounds different than "A man enters beverage store...".

When dealing with clients, it's easy to joke about your client, but don't miss an opportunity to prevent future missteps once you know more about them.]]></description>
			<content:encoded><![CDATA[<p></p><p>One thing I&#8217;ve always heard about learning a new language is that you can&#8217;t consider yourself fully fluent until you can tell a joke. Telling a joke requires the understanding of homonyms and how words flow together. &#8220;So a guy walks into a bar&#8230;&#8221; sounds different than &#8220;A man enters beverage store&#8230;&#8221;.</p>

<p>When dealing with clients, it&#8217;s easy to joke about your client, but don&#8217;t miss an opportunity to prevent future missteps once you know more about them.</p>

<p>How often do you get off the phone with a client and immediately have a funny remark about some critique or issue they have mentioned. Typically this manifests itself when the client brings up an issue, that while important to them, is considered trivial by the developer.</p>

<blockquote>
Can you believe this guy!? I built out this whiz-bang feature and he&#8217;s just complaining about the font being too small!<br />
</blockquote>

<p>The key part of this interaction is that you&#8217;ve now got a little insight into what makes this particular client tick. When you demo the next few features and he is unimpressed by the functionality, but comments on the spacing of form elements you should skip the joke and make a mental note for the future.</p>

<p>Once you can tell a joke about your client, <em>before</em> the interaction, and you have an &#8220;I told ya so!&#8221; moment with yourself or your pair afterwards, you know you&#8217;ve made it to the next level of understanding that client. Now, the next time you deploy a feature, discuss requirements or ask a question you can preempt the inevitable by accounting for those quirks and personal preferences of your client.</p>

<p>Instead of making a joke, make them happy, then you can both smile. ;)</p><img src="http://feeds.feedburner.com/~r/claytonlengelzigich/~4/iG9oukeTk7E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.claytonlz.com/index.php/2009/10/make-fun-of-your-client/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.claytonlz.com/index.php/2009/10/make-fun-of-your-client/</feedburner:origLink></item>
		<item>
		<title>Authlogic Account Activation Tutorial</title>
		<link>http://feedproxy.google.com/~r/claytonlengelzigich/~3/FXf_EZP0IA0/</link>
		<comments>http://www.claytonlz.com/index.php/2009/07/authlogic-account-activation-tutorial/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 07:57:27 +0000</pubDate>
		<dc:creator>Clayton</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[authlogic]]></category>

		<guid isPermaLink="false">http://www.claytonlz.com/?p=274</guid>
		<description><![CDATA[I found a great tutorial explaining how to setup user activation with authlogic, but it was a little hard to read so I've dumped it all into one easier to read file.]]></description>
			<content:encoded><![CDATA[<p></p><p>I found a great tutorial explaining how to setup user activation with authlogic, but it was a little hard to read so I&#8217;ve dumped it all into one easier to read file.</p>

<p>Here&#8217;s the original: http://github.com/matthooks/authlogic-activation-tutorial/tree/master<br />
Here&#8217;s my fork on github: http://github.com/clayton/authlogic-activation-tutorial/tree/master</p>

<p>Below is the formatted guide that is on github. </p>

<p><strong>Remember, all credit goes to <a href="http://github.com/matthooks">Matt Hooks</a> and his original <a href="http://github.com/matthooks/authlogic-activation-tutorial/tree/master">Authlogic Account Activation Tutorial</a></strong></p>

<h2>Introduction</h2>

<p>This is an easier to read version of Matt Hooks&#8217; <a href="http://github.com/matthooks/authlogic-activation-tutorial/tree/master">Authlogic Activation Tutorial</a>. The tutorial is divided into a number of steps and walks through the process of implementing user activation functionality into your pre-existing Rails app using <a href="http://github.com/binarylogic/authlogic/tree/master">Authlogic</a>. If you are just starting out with Authlogic, be sure to checkout the <a href="http://github.com/binarylogic/authlogic_example/tree/master">Authlogic Example Tutorial</a>.</p>

<h2>Step 1</h2>

<p>Let&#8217;s begin by adding an &#8216;active&#8217; field with a default of false to the user model.</p>

<p><code>script/generate migration AddActiveToUsers active:boolean</code></p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#008000; font-style:italic;"># new migration XXX_add_active_to_users.rb</span>
  <span style="color:#9966CC; font-weight:bold;">class</span> AddActiveToUsers <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Migration</span>
    <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">up</span>
      add_column <span style="color:#ff3333; font-weight:bold;">:users</span>, <span style="color:#ff3333; font-weight:bold;">:active</span>, <span style="color:#ff3333; font-weight:bold;">:boolean</span>, <span style="color:#ff3333; font-weight:bold;">:default</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">false</span>, <span style="color:#ff3333; font-weight:bold;">:null</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">false</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">down</span>
      remove_column <span style="color:#ff3333; font-weight:bold;">:users</span>, <span style="color:#ff3333; font-weight:bold;">:active</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>




<h2>Step 2</h2>

<p>Don&#8217;t forget to run the migraiton.</p>

<p><code>rake db:migrate</code></p>

<p>Authlogic automatically executes the following methods, if present, upon user action: active?, approved?, and confirmed?. Let&#8217;s create an &#8220;active?&#8221; method so we can hook into this magical goodness. And we should make sure that we protect the active attribute from mass-assignments by calling attr_accessible.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#008000; font-style:italic;"># added to user.rb</span>
  attr_accessible <span style="color:#ff3333; font-weight:bold;">:login</span>, <span style="color:#ff3333; font-weight:bold;">:email</span>, <span style="color:#ff3333; font-weight:bold;">:password</span>, <span style="color:#ff3333; font-weight:bold;">:password_confirmation</span>, <span style="color:#ff3333; font-weight:bold;">:openid_identifier</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> active?
    active
  <span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>




<h2>Step 3</h2>

<p>Now try to log in. You should receive the error, &#8220;Your account is not active.&#8221; So far so good. Let&#8217;s make a controller to handle our activations:</p>

<p><code>script/generate controller activations new create</code></p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#008000; font-style:italic;"># new file app/controllers/activations_controller.rb</span>
  <span style="color:#9966CC; font-weight:bold;">class</span> ActivationsController <span style="color:#006600; font-weight:bold;">&lt;</span> ApplicationController
    before_filter <span style="color:#ff3333; font-weight:bold;">:require_no_user</span>, <span style="color:#ff3333; font-weight:bold;">:only</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:new</span>, <span style="color:#ff3333; font-weight:bold;">:create</span><span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> new
      <span style="color:#0066ff; font-weight:bold;">@user</span> = User.<span style="color:#9900CC;">find_using_perishable_token</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:activation_code</span><span style="color:#006600; font-weight:bold;">&#93;</span>, 1.<span style="color:#9900CC;">week</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#CC00FF; font-weight:bold;">Exception</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#CC00FF; font-weight:bold;">Exception</span> <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@user</span>.<span style="color:#9900CC;">active</span>?
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> create
      <span style="color:#0066ff; font-weight:bold;">@user</span> = User.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:id</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
      <span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#CC00FF; font-weight:bold;">Exception</span> <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@user</span>.<span style="color:#9900CC;">active</span>?
&nbsp;
      <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@user</span>.<span style="color:#9900CC;">activate</span>!
        <span style="color:#0066ff; font-weight:bold;">@user</span>.<span style="color:#9900CC;">deliver_activation_confirmation</span>!
        redirect_to account_url
      <span style="color:#9966CC; font-weight:bold;">else</span>
        render <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:new</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>




<h2>Step 4</h2>

<p>I raise exceptions in these actions to make sure that someone who is already active cannot re-activate their account and to deal with an invalid perishable token. I&#8217;ll leave it up to you how you want to handle these errors &#8212; you should probably provide some sort of &#8220;My Token is Expired!&#8221; action that will reset the token and resend the activation email if the user does not get around to activating right away.</p>

<p>Going down the list, let&#8217;s define the missing actions. First:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#008000; font-style:italic;"># added to user.rb</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> activate!
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">active</span> = <span style="color:#0000FF; font-weight:bold;">true</span>
    save
  <span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>




<h2>Step 5</h2>

<p>Next, let&#8217;s make sure our user gets an e-mail with his activation code when he signs up. How are we getting our activation code? The same way we get our password reset code &#8212; through our perishable token:</p>

<p><strong>Update</strong>: If you are experiencing the &#8220;Missing host to link to! Please provide :host parameter &#8221; error see this post <a href="http://www.claytonlz.com/index.php/2009/11/authlogic-activation-host-parameter-gotcha/">Missing host to link to! Please provide :host parameter</a></p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">  # added to app/models/user.rb
  def deliver_activation_instructions!
    reset_perishable_token!
    Notifier.deliver_activation_instructions(self)
  end
&nbsp;
  def deliver_activation_confirmation!
    reset_perishable_token!
    Notifier.deliver_activation_confirmation(self)
  end
&nbsp;
  # added to app/models/notifier.rb
  def activation_instructions(user)
    subject       &quot;Activation Instructions&quot;
    from          &quot;Binary Logic Notifier &lt;noreply@binarylogic.com&gt;&quot;
    recipients    user.email
    sent_on       Time.now
    body          :account_activation_url =&gt; register_url(user.perishable_token)
  end
&nbsp;
  def activation_confirmation(user)
    subject       &quot;Activation Complete&quot;
    from          &quot;Binary Logic Notifier &lt;noreply@binarylogic.com&gt;&quot;
    recipients    user.email
    sent_on       Time.now
    body          :root_url =&gt; root_url
  end
&nbsp;
  # added to config/routes.rb
  map.register '/register/:activation_code', :controller =&gt; 'activations', :action =&gt; 'new'
  map.activate '/activate/:id', :controller =&gt; 'activations', :action =&gt; 'create'
&nbsp;
  &lt;!-- new file app/views/notifier/activation_instructions.erb --&gt; 
  Thank you for creating an account! Click the url below to activate your account!
&nbsp;
  <span style="color:#006600; font-weight:bold;">&lt;%</span>= <span style="color:#0066ff; font-weight:bold;">@account_activation_url</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
&nbsp;
  If the above URL does not work try copying and pasting it into your browser. If you continue to have problem, please feel free to contact us.
&nbsp;
  &lt;!-- new file app/views/notifier/activation_confirmation.erb --&gt;
  Your account has been activated.
&nbsp;
  <span style="color:#006600; font-weight:bold;">&lt;%</span>= <span style="color:#0066ff; font-weight:bold;">@root_url</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
&nbsp;
  If the above URL does not work try copying and pasting it into your browser. If you continue to have problem, please feel free to contact us.</pre></td></tr></table></div>




<h2>Step 6</h2>

<p>Now let&#8217;s modify the user create action:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#008000; font-style:italic;"># modified app/controllers/users_controller.rb</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> create
    <span style="color:#0066ff; font-weight:bold;">@user</span> = User.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:user</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
    <span style="color:#008000; font-style:italic;"># Saving without session maintenance to skip</span>
    <span style="color:#008000; font-style:italic;"># auto-login which can't happen here because</span>
    <span style="color:#008000; font-style:italic;"># the User has not yet been activated</span>
    <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@user</span>.<span style="color:#9900CC;">save_without_session_maintenance</span>
      <span style="color:#0066ff; font-weight:bold;">@user</span>.<span style="color:#9900CC;">deliver_activation_instructions</span>!
      flash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:notice</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;Your account has been created. Please check your e-mail for your account activation instructions!&quot;</span>
      redirect_to root_url
    <span style="color:#9966CC; font-weight:bold;">else</span>
      render <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:new</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>




<h2>Step 7</h2>

<p>As the comment says, we don&#8217;t need the Authlogic auto-login to take place so we save without maintaining the session. Now let&#8217;s define the &#8216;register&#8217; view.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">  &lt;!-- new file app/views/activations/new.html.erb --&gt;
&nbsp;
  &lt;h1&gt;Activate your account&lt;/h1&gt;
&nbsp;
  <span style="color:#006600; font-weight:bold;">&lt;%</span> form_for <span style="color:#0066ff; font-weight:bold;">@user</span>, <span style="color:#ff3333; font-weight:bold;">:url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> activate_path<span style="color:#006600; font-weight:bold;">&#40;</span>@user.<span style="color:#9900CC;">id</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#ff3333; font-weight:bold;">:html</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:method</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:post</span> <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
  	<span style="color:#006600; font-weight:bold;">&lt;%</span>= f.<span style="color:#9900CC;">error_messages</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
  	<span style="color:#006600; font-weight:bold;">&lt;%</span>= f.<span style="color:#9900CC;">submit</span> <span style="color:#996600;">&quot;Activate&quot;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
  <span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></td></tr></table></div>




<h2>Step 8</h2>

<p>Let&#8217;s see if things are working&#8230;</p>

<p>&#8230; (processing) &#8230;</p>

<p>Looks like our user got activated!</p>

<p>But there&#8217;s a slight problem. Since we didn&#8217;t update the user&#8217;s password, we didn&#8217;t get a magical Authlogic auto-login! How rude.</p>

<p>At this point it&#8217;s perfectly fine to let the user log themselves in. And you can certainly simplify the activation down to one action so the user doesn&#8217;t have to click another button. But, I like Authlogic&#8217;s session maintenance. I also like short signup forms. So let&#8217;s kill two birds with one stone.</p>

<p>Let&#8217;s set up the user creation form to only ask for a user&#8217;s login/email. Then, let&#8217;s ask the user to set their password/openid upon activation, which will log them in automatically.</p>

<p>First, let&#8217;s change our acts_as_authentic call to only check for password length on update if the user has no credentials set.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#008000; font-style:italic;"># modified user.rb</span>
  <span style="color:#008000; font-style:italic;"># For authlogic 2.0+</span>
  acts_as_authentic <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>c<span style="color:#006600; font-weight:bold;">|</span>
    c.<span style="color:#9900CC;">validates_length_of_password_field_options</span> = <span style="color:#006600; font-weight:bold;">&#123;</span>:on <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:update</span>, <span style="color:#ff3333; font-weight:bold;">:minimum</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">4</span>, <span style="color:#ff3333; font-weight:bold;">:if</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:has_no_credentials</span>?<span style="color:#006600; font-weight:bold;">&#125;</span>
    c.<span style="color:#9900CC;">validates_length_of_password_confirmation_field_options</span> = <span style="color:#006600; font-weight:bold;">&#123;</span>:on <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:update</span>, <span style="color:#ff3333; font-weight:bold;">:minimum</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">4</span>, <span style="color:#ff3333; font-weight:bold;">:if</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:has_no_credentials</span>?<span style="color:#006600; font-weight:bold;">&#125;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Pre-authlogic 2.0</span>
  <span style="color:#008000; font-style:italic;"># acts_as_authentic :login_field_validation_options =&gt; { :if =&gt; :openid_identifier_blank? },</span>
  <span style="color:#008000; font-style:italic;">#                   :password_field_validation_options =&gt; { :if =&gt; :openid_identifier_blank? },</span>
  <span style="color:#008000; font-style:italic;">#                   :password_field_validates_length_of_options =&gt; { :on =&gt; :update, :if =&gt; :has_no_credentials? }</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># ...</span>
  <span style="color:#008000; font-style:italic;"># we need to make sure that either a password or openid gets set</span>
  <span style="color:#008000; font-style:italic;"># when the user activates his account</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> has_no_credentials?
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">crypted_password</span>.<span style="color:#9900CC;">blank</span>? <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">openid_identifier</span>.<span style="color:#9900CC;">blank</span>?
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># ...</span>
  <span style="color:#008000; font-style:italic;"># now let's define a couple of methods in the user model. The first</span>
  <span style="color:#008000; font-style:italic;"># will take care of setting any data that you want to happen at signup</span>
  <span style="color:#008000; font-style:italic;"># (aka before activation)</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> signup!<span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">login</span> = params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:user</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:login</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">email</span> = params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:user</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:email</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    save_without_session_maintenance
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># the second will take care of setting any data that you want to happen</span>
  <span style="color:#008000; font-style:italic;"># at activation. at the very least this will be setting active to true</span>
  <span style="color:#008000; font-style:italic;"># and setting a pass, openid, or both.</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> activate!<span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">active</span> = <span style="color:#0000FF; font-weight:bold;">true</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">password</span> = params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:user</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:password</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">password_confirmation</span> = params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:user</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:password_confirmation</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">openid_identifier</span> = params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:user</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:openid_identifier</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    save
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># modified activations_controller.rb</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> create
    <span style="color:#0066ff; font-weight:bold;">@user</span> = User.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:id</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
    <span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#CC00FF; font-weight:bold;">Exception</span> <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@user</span>.<span style="color:#9900CC;">active</span>?
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@user</span>.<span style="color:#9900CC;">activate</span>!<span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#0066ff; font-weight:bold;">@user</span>.<span style="color:#9900CC;">deliver_activation_confirmation</span>!
      flash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:notice</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;Your account has been activated.&quot;</span>
      redirect_to account_url
    <span style="color:#9966CC; font-weight:bold;">else</span>
      render <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:new</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># modified users_controller.rb</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> create
    <span style="color:#0066ff; font-weight:bold;">@user</span> = User.<span style="color:#9900CC;">new</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@user</span>.<span style="color:#9900CC;">signup</span>!<span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#0066ff; font-weight:bold;">@user</span>.<span style="color:#9900CC;">deliver_activation_instructions</span>!
      flash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:notice</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;Your account has been created. Please check your e-mail for your account activation instructions!&quot;</span>
      redirect_to root_url
    <span style="color:#9966CC; font-weight:bold;">else</span>
      render <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:new</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>




<h2>Step 10</h2>

<p>Now we need to update our views to reflect the new signup process.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">  &lt;!-- modified app/views/activations/new.html.erb --&gt;
  &lt;h1&gt;Activate your account&lt;/h1&gt;
&nbsp;
  <span style="color:#006600; font-weight:bold;">&lt;%</span> form_for <span style="color:#0066ff; font-weight:bold;">@user</span>, <span style="color:#ff3333; font-weight:bold;">:url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> activate_path<span style="color:#006600; font-weight:bold;">&#40;</span>@user.<span style="color:#9900CC;">id</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#ff3333; font-weight:bold;">:html</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:method</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:post</span> <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>form<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
  	<span style="color:#006600; font-weight:bold;">&lt;%</span>= form.<span style="color:#9900CC;">error_messages</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
  	<span style="color:#006600; font-weight:bold;">&lt;%</span>= render <span style="color:#ff3333; font-weight:bold;">:partial</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;form&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:locals</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:form</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> form <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">%&gt;</span>
  	<span style="color:#006600; font-weight:bold;">&lt;%</span>= form.<span style="color:#9900CC;">submit</span> <span style="color:#996600;">&quot;Activate&quot;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
  <span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
&nbsp;
  &lt;!-- new file app/views/activations/_form.html.erb --&gt;
  <span style="color:#006600; font-weight:bold;">&lt;%</span>= form.<span style="color:#9900CC;">label</span> <span style="color:#ff3333; font-weight:bold;">:password</span>, <span style="color:#996600;">&quot;Set your password&quot;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>&lt;br /&gt;
  <span style="color:#006600; font-weight:bold;">&lt;%</span>= form.<span style="color:#9900CC;">password_field</span> <span style="color:#ff3333; font-weight:bold;">:password</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>&lt;br /&gt;
  &lt;br /&gt;
  <span style="color:#006600; font-weight:bold;">&lt;%</span>= form.<span style="color:#9900CC;">label</span> <span style="color:#ff3333; font-weight:bold;">:password_confirmation</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>&lt;br /&gt;
  <span style="color:#006600; font-weight:bold;">&lt;%</span>= form.<span style="color:#9900CC;">password_field</span> <span style="color:#ff3333; font-weight:bold;">:password_confirmation</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>&lt;br /&gt;
  &lt;br /&gt;
  <span style="color:#006600; font-weight:bold;">&lt;%</span>= form.<span style="color:#9900CC;">label</span> <span style="color:#ff3333; font-weight:bold;">:openid_identifier</span>, <span style="color:#996600;">&quot;Or use OpenID instead of your email / password&quot;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>&lt;br /&gt;
  <span style="color:#006600; font-weight:bold;">&lt;%</span>= form.<span style="color:#9900CC;">text_field</span> <span style="color:#ff3333; font-weight:bold;">:openid_identifier</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>&lt;br /&gt;</pre></td></tr></table></div>




<h2>The End</h2>

<p>And that&#8217;s it! Let me know if you have any suggestions for improvement.</p><img src="http://feeds.feedburner.com/~r/claytonlengelzigich/~4/FXf_EZP0IA0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.claytonlz.com/index.php/2009/07/authlogic-account-activation-tutorial/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://www.claytonlz.com/index.php/2009/07/authlogic-account-activation-tutorial/</feedburner:origLink></item>
		<item>
		<title>Using Ruby’s true in Cucumber Multiline Tables</title>
		<link>http://feedproxy.google.com/~r/claytonlengelzigich/~3/cVP4Cb4K0BE/</link>
		<comments>http://www.claytonlz.com/index.php/2009/06/using-rubys-true-in-cucumber-multiline-tables/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 04:02:39 +0000</pubDate>
		<dc:creator>Clayton</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.claytonlz.com/?p=266</guid>
		<description><![CDATA[Last week my pair and I ran into a problem with a failing Cucumber scenario. We were using one of the more awesome features of Cucumber, multiline tables, when we got the unexpected failure. We realized that what we were doing was probably a common pattern and would certain trip other's up.]]></description>
			<content:encoded><![CDATA[<p></p><p>Last week my pair and I ran into a problem with a failing Cucumber scenario. We were using one of the more awesome features of Cucumber, multiline tables, when we got the unexpected failure. We realized that what we were doing was probably a common pattern and would certain trip other&#8217;s up.</p>

<h3>Scenario and Step</h3>

<p>If you&#8217;re not familiar with multiline tables in cucumber, take a look at the <a href="http://wiki.github.com/aslakhellesoy/cucumber/multiline-step-arguments">wiki entry</a>.  We were specifying a list of attributes on one of our models that we wanted to have access to in our step. First, here is an example scenario outline.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">Scenario: Finding a specific dog
  Given an existing microchipped dog named <span style="color:#996600;">&quot;George&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">When</span> I search <span style="color:#9966CC; font-weight:bold;">for</span> a dog with the following attributes:
    <span style="color:#006600; font-weight:bold;">|</span> name   <span style="color:#006600; font-weight:bold;">|</span> microchipped <span style="color:#006600; font-weight:bold;">|</span>
    <span style="color:#006600; font-weight:bold;">|</span> George <span style="color:#006600; font-weight:bold;">|</span> <span style="color:#0000FF; font-weight:bold;">true</span>         <span style="color:#006600; font-weight:bold;">|</span>
  <span style="color:#9966CC; font-weight:bold;">Then</span> I find <span style="color:#996600;">&quot;1&quot;</span> dog
  <span style="color:#9966CC; font-weight:bold;">And</span> that dog should be named <span style="color:#996600;">&quot;George&quot;</span></pre></td></tr></table></div>




<p>Our step was taking the multiline table attributes and using them in an ActiveRecord find, like this.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">/</span>^I search <span style="color:#9966CC; font-weight:bold;">for</span> a dog with the following attributes:$<span style="color:#006600; font-weight:bold;">/</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>table<span style="color:#006600; font-weight:bold;">|</span>
  table.<span style="color:#9900CC;">hashes</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>attributes<span style="color:#006600; font-weight:bold;">|</span>
    <span style="color:#0066ff; font-weight:bold;">@dog</span> = Dog.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:first</span>, <span style="color:#ff3333; font-weight:bold;">:conditions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> attributes<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>




<p>In our example we are looking for two attributes a string called &#8220;name&#8221; and a boolean called &#8220;microchipped&#8221;. However, this find will always fail, even if your &#8216;Given an existing microchipped dog named &#8220;George&#8221;&#8216; step explicitly sets up the correct object in the beginning of the test.</p>

<h3>The Fix</h3>

<p>We found that if we changed our scenario to look like this, everything worked fine.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">Scenario: Finding a specific dog
  Given an existing microchipped dog named <span style="color:#996600;">&quot;George&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">When</span> I search <span style="color:#9966CC; font-weight:bold;">for</span> a dog with the following attributes:
    <span style="color:#006600; font-weight:bold;">|</span> name   <span style="color:#006600; font-weight:bold;">|</span> microchipped <span style="color:#006600; font-weight:bold;">|</span>
    <span style="color:#006600; font-weight:bold;">|</span> George <span style="color:#006600; font-weight:bold;">|</span> <span style="color:#006666;">1</span>            <span style="color:#006600; font-weight:bold;">|</span>
  <span style="color:#9966CC; font-weight:bold;">Then</span> I find <span style="color:#996600;">&quot;1&quot;</span> dog
  <span style="color:#9966CC; font-weight:bold;">And</span> that dog should be named <span style="color:#996600;">&quot;George&quot;</span></pre></td></tr></table></div>




<p>See the change? We changed &#8220;true&#8221; for microchipped to &#8220;1&#8243;. Typically when you&#8217;re working with rails you can pass <tt>true</tt> in the conditions of an ActiveRecord find and Rails will convert that to the correct <span class="caps">SQL </span>string for you. However, because cucumber passes each argument in the multiline table rows as strings, Rails never has the chance to covert that <tt>true</tt> for you.</p>

<p>In the first, failing, example you end up with something like this for your <span class="caps">SQL</span>:</p>


<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> dogs <span style="color: #993333; font-weight: bold;">WHERE</span> name <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;George&quot;</span> <span style="color: #993333; font-weight: bold;">AND</span> microchipped <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #993333; font-weight: bold;">LIMIT</span> <span style="color: #cc66cc;">1</span>;</pre></div></div>




<p>In the second, passing, example you end up with something like this:</p>


<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> dogs <span style="color: #993333; font-weight: bold;">WHERE</span> name <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;George&quot;</span> <span style="color: #993333; font-weight: bold;">AND</span> microchipped <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #993333; font-weight: bold;">LIMIT</span> <span style="color: #cc66cc;">1</span>;</pre></div></div>
<img src="http://feeds.feedburner.com/~r/claytonlengelzigich/~4/cVP4Cb4K0BE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.claytonlz.com/index.php/2009/06/using-rubys-true-in-cucumber-multiline-tables/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.claytonlz.com/index.php/2009/06/using-rubys-true-in-cucumber-multiline-tables/</feedburner:origLink></item>
		<item>
		<title>Test Driven Development Talk with ASUSoDA</title>
		<link>http://feedproxy.google.com/~r/claytonlengelzigich/~3/jwVIa3LEeiQ/</link>
		<comments>http://www.claytonlz.com/index.php/2009/04/test-driven-development-talk-with-asusoda/#comments</comments>
		<pubDate>Tue, 28 Apr 2009 05:14:31 +0000</pubDate>
		<dc:creator>Clayton</dc:creator>
				<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[Social Networking]]></category>

		<guid isPermaLink="false">http://www.claytonlz.com/?p=255</guid>
		<description><![CDATA[Tonight I had the privilege of giving a presentation on Test Driven Development to the "ASUSoDA":http://asusoda.com group at ASU.  I focused on a higher level aspect of testing and the benefits and pitfalls of TDD. After my planned presentation I was also able to demo my "Intern Management App":http://github.com/clayton/cucumber-demo/tree/master which was fun given the lighthearted nature of the examples.]]></description>
			<content:encoded><![CDATA[<p></p><p>Tonight I had the privilege of giving a presentation on Test Driven Development to the <a href="http://asusoda.com"><span class="caps">ASUS</span>oDA</a> group at <span class="caps">ASU. </span> I focused on the higher level aspects of testing and the specific benefits and pitfalls of <span class="caps">TDD.</span> After my planned presentation I was also able to demo my <a href="http://github.com/clayton/cucumber-demo/tree/master">Intern Management App</a> which was fun given the lighthearted nature of the examples.</p>

<p>Here are the slides from my presentation: <a href="http://www.claytonlz.com/wp-content/uploads/2009/04/asusoda_tdd_20090427.pdf">852k <span class="caps">PDF</span></a></p><img src="http://feeds.feedburner.com/~r/claytonlengelzigich/~4/jwVIa3LEeiQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.claytonlz.com/index.php/2009/04/test-driven-development-talk-with-asusoda/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.claytonlz.com/index.php/2009/04/test-driven-development-talk-with-asusoda/</feedburner:origLink></item>
		<item>
		<title>How To: Setup RSpec, Cucumber, Webrat, RCov and Autotest on Leopard</title>
		<link>http://feedproxy.google.com/~r/claytonlengelzigich/~3/tYHkTUt5L1s/</link>
		<comments>http://www.claytonlz.com/index.php/2009/04/how-to-setup-rspec-cucumber-webrat-rcov-and-autotest-on-leopard/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 20:00:24 +0000</pubDate>
		<dc:creator>Clayton</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[cucumber]]></category>
		<category><![CDATA[factory girl]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[rcov]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[webrat]]></category>

		<guid isPermaLink="false">http://www.claytonlz.com/?p=220</guid>
		<description><![CDATA[RSpec, Cucumber, Webrat, RCov and Autotest are a powerful combination of tools for testing your Rails app. Unfortunately getting them to all work nicely together can be a bit of challenge. I recently configured a development environment from scratch on OS X 10.5 Leopard and kept track of all of the little details.]]></description>
			<content:encoded><![CDATA[<p></p><p>RSpec, Cucumber, Webrat, RCov and Autotest are a powerful combination of tools for testing your Rails app. Unfortunately getting them to all work nicely together can be a bit of challenge. I recently configured a development environment from scratch on OS X 10.5 Leopard and kept track of all of the little details.</p>

<h3>Prerequisites</h3>

<p>I&#8217;m assuming you&#8217;ve got the following installed:</p>


<ul>
<li>ruby</li>
<li>ruby gems 1.3.1</li>
<li><a href="http://developer.apple.com/Tools/">Apple development tools</a></li>
<li>git</li>
<li>rails &gt;= 2.3.2</li>
<li>You&#8217;ve added github to your gem sources (gem sources -a http://gems.github.com)<br />
<br /></li>
</ul>



<h3>RSpec &amp; RSpec-Rails</h3>

<p>First let&#8217;s grab the rspec<sup class="footnote"><a href="#fn1">1</a></sup> and rspec-rails<sup class="footnote"><a href="#fn2">2</a></sup> gems.</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">sudo gem install rspec</pre></div></div>





<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">sudo gem install rspec-rails</pre></div></div>




<h3>Cucumber</h3>

<p>Next we&#8217;ll install the cucumber<sup class="footnote"><a href="#fn3">3</a></sup> gem</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">sudo gem install cucumber</pre></div></div>




<h3>Webrat</h3>

<p>Webrat<sup class="footnote"><a href="#fn4">4</a></sup> is used by cucumber to simulate a browser for your integration tests. Webrat will also install nokogiri<sup class="footnote"><a href="#fn5">5</a></sup>.</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">sudo gem install webrat</pre></div></div>




<h3>RCov</h3>

<p>I thought RCov<sup class="footnote"><a href="#fn6">6</a></sup> would get installed with RSpec, but it wasn&#8217;t for me. You might not need to do this, but just to make sure&#8230;</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">sudo gem install rcov</pre></div></div>




<h3>Autotest</h3>

<p>Autotest<sup class="footnote"><a href="#fn7">7</a></sup> comes from ZenTest<sup class="footnote"><a href="#fn8">8</a></sup> and allows you to have a kick ass workflow where you are constantly running relevant tests and less-constantly automatically running your entire test suite.</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">sudo gem install ZenTest</pre></div></div>




<h3>Optionally, Thoughtbot&#8217;s Factory Girl</h3>

<p>Factory girl<sup class="footnote"><a href="#fn9">9</a></sup> is a really helpful fixture replacement (and more) gem to use in conjunction with cucumber, checkout their <a href="http://giantrobots.thoughtbot.com/2008/6/6/waiting-for-a-factory-girl">much better explanation</a></p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">sudo gem install thoughtbot-factory_girl --source http://gems.github.com</pre></div></div>




<h3>Optionally, Carlos Brando&#8217;s Autotest Notification</h3>

<p>While autotest normally runs in a terminal window, it can be setup to hook into applications like <a href="http://growl.info/">growl</a> or <a href="http://www.fullphat.net/index.php">snarl</a>. The Autotest Notification<sup class="footnote"><a href="#fn9">9</a></sup> gem helps make this setup a lot easier. </p>

<p><strong>You will need growl installed and configured for this step</strong> the installation instructions on this gems github page are very easy to follow.</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">sudo gem install carlosbrando-autotest-notification --source=http://gems.github.com</pre></div></div>




<p>Next you need to turn autotest notifications &#8220;on&#8221;</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">an-install</pre></div></div>




<h3>A Sample Rails App</h3>

<p>Let&#8217;s create a sample rails app for the rest of this guide.</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">rails sample-app</pre></div></div>




<p><strong>Configuring Environment Variables</strong></p>

<p>Autotest relies on some environment variables to run all of your features and specs correctly. If autotest &#8220;hangs&#8221; after you try to run it, or it just never seems to be watching your specs or features, this will most likely solve your problem.</p>

<p>Open the test.rb environment definition file in <code>sample-app/config/environments/test.rb</code> and add the following.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'AUTOFEATURE'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;true&quot;</span>
ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'RSPEC'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;true&quot;</span></pre></td></tr></table></div>




<p>These lines will test autotest to run, and look for changes to, your specs (rather than test unit tests) and your cucumber features.</p>

<p><strong>Update</strong></p>

<p>If you don&#8217;t want to add these environment variables to every rails project you&#8217;ve got on your machine, you can also choose to set them as environment variables in your .bash_profile or .bashrc (or whatever shell you&#8217;re using) files.</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">export AUTOFEATURE=true
export RSPEC=true</pre></div></div>




<p><strong>Unpacking Gems</strong></p>

<p>Next let&#8217;s freeze (unpack) some gems that we&#8217;ll be using in our app. I&#8217;ve run into problems trying to use the system gems with cucumber, rspec and webrat, especially when I have multiple versions of any of them installed. Unpacking them into my rails app solves this problem for me.</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">mkdir sample-app/vendor/gems
cd sample-app/vendor/gems
sudo gem unpack rails
sudo gem unpack rspec
sudo gem unpack rspec-rails
sudo gem unpack cucumber</pre></div></div>




<p>Because webrat (and nokogiri) are native gems, that is, they are built locally on your machine based on its architecture, we won&#8217;t unpack those.</p>

<p><strong>config.gem support</strong><br />
The current accepted practice, when using rails 2.3, and as suggested by the rspec guy(s) is to use rails&#8217; <code>config.gem</code> functionality.</p>

<p>Open sample-app/config/environments/test.rb and add the following lines:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">config.<span style="color:#9900CC;">gem</span> <span style="color:#996600;">&quot;rspec&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:lib</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">false</span>, <span style="color:#ff3333; font-weight:bold;">:version</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;&gt;= 1.2.0&quot;</span> 
config.<span style="color:#9900CC;">gem</span> <span style="color:#996600;">&quot;rspec-rails&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:lib</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">false</span>, <span style="color:#ff3333; font-weight:bold;">:version</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;&gt;= 1.2.0&quot;</span> 
config.<span style="color:#9900CC;">gem</span> <span style="color:#996600;">&quot;cucumber&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:lib</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">false</span>, <span style="color:#ff3333; font-weight:bold;">:version</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;&gt;= 0.2.3&quot;</span>
config.<span style="color:#9900CC;">gem</span> <span style="color:#996600;">&quot;thoughtbot-factory_girl&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:lib</span>    <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;factory_girl&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:source</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;http://gems.github.com&quot;</span>
config.<span style="color:#9900CC;">gem</span> <span style="color:#996600;">&quot;webrat&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:lib</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">false</span>, <span style="color:#ff3333; font-weight:bold;">:version</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;&gt;= 0.4.3&quot;</span>
config.<span style="color:#9900CC;">gem</span> <span style="color:#996600;">&quot;nokogiri&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:lib</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">false</span>, <span style="color:#ff3333; font-weight:bold;">:version</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;&gt;= 1.2.3&quot;</span></pre></div></div>




<p>Your version numbers may be different, but these are all current at the time of writing.</p>

<p><strong>Boot Strapping RSpec and Cucumber</strong></p>

<p>Before you can get very far with rspec or cucumber you need to run the bootstrapping scripts to give yourself the default files and directories.</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;"># From inside your rails app sample-app/
script/generate rspec
script/generate cucumber</pre></div></div>




<p><strong>Factories</strong><br />
Depending on where you&#8217;re going to use your factories the most, you might want to save your file in either <code>spec/</code> or <code>features/</code>. I chose the latter. Only complete this step if you plan to use the FactoryGirl gem.</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">touch sample-app/features/factories.rb</pre></div></div>




<h3>Getting Accurate RCov Data</h3>

<p>By default RCov is setup to only use your specs when calculating code coverage. If you&#8217;re using Cucumber <em>and</em> RSpec, you&#8217;ll obviously want to include both types of tests to calculate your project&#8217;s true code coverage.</p>

<p>I picked up this rcov rake task from my co-worker <a href="http://jay.mcgavren.com/blog/">Jay McGavren</a> it does all of the heavy lifting for you, we&#8217;ll just need to make a couple of changes.</p>

<p>Drop <a href="http://gist.github.com/89659">this file</a> into sample-app/lib/tasks/rcov.rake and use it by calling <code>rake rcov:all</code> from your terminal.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'cucumber/rake/task'</span> <span style="color:#008000; font-style:italic;">#I have to add this</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'spec/rake/spectask'</span>
&nbsp;
namespace <span style="color:#ff3333; font-weight:bold;">:rcov</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  <span style="color:#6666ff; font-weight:bold;">Cucumber::Rake::Task</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:cucumber</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>t<span style="color:#006600; font-weight:bold;">|</span>    
    t.<span style="color:#9900CC;">rcov</span> = <span style="color:#0000FF; font-weight:bold;">true</span>
    t.<span style="color:#9900CC;">rcov_opts</span> = <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">--</span>rails <span style="color:#006600; font-weight:bold;">--</span>exclude osx\<span style="color:#006600; font-weight:bold;">/</span>objc,gems\<span style="color:#006600; font-weight:bold;">/</span>,spec\<span style="color:#006600; font-weight:bold;">/</span>,features\<span style="color:#006600; font-weight:bold;">/</span> <span style="color:#006600; font-weight:bold;">--</span>aggregate coverage.<span style="color:#9900CC;">data</span><span style="color:#006600; font-weight:bold;">&#125;</span>
    t.<span style="color:#9900CC;">rcov_opts</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#006600; font-weight:bold;">%</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">-</span>o <span style="color:#996600;">&quot;coverage&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#6666ff; font-weight:bold;">Spec::Rake::SpecTask</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:rspec</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>t<span style="color:#006600; font-weight:bold;">|</span>
    t.<span style="color:#9900CC;">spec_opts</span> = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'--options'</span>, <span style="color:#996600;">&quot;<span style="color:#000099;">\&quot;</span>#{RAILS_ROOT}/spec/spec.opts<span style="color:#000099;">\&quot;</span>&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    t.<span style="color:#9900CC;">spec_files</span> = FileList<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'spec/**/*_spec.rb'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    t.<span style="color:#9900CC;">rcov</span> = <span style="color:#0000FF; font-weight:bold;">true</span>
    t.<span style="color:#9900CC;">rcov_opts</span> = <span style="color:#CC0066; font-weight:bold;">lambda</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      <span style="color:#CC00FF; font-weight:bold;">IO</span>.<span style="color:#CC0066; font-weight:bold;">readlines</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;#{RAILS_ROOT}/spec/rcov.opts&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">map</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>l<span style="color:#006600; font-weight:bold;">|</span> l.<span style="color:#CC0066; font-weight:bold;">chomp</span>.<span style="color:#CC0066; font-weight:bold;">split</span> <span style="color:#996600;">&quot; &quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">flatten</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  desc <span style="color:#996600;">&quot;Run both specs and features to generate aggregated coverage&quot;</span>
  task <span style="color:#ff3333; font-weight:bold;">:all</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>t<span style="color:#006600; font-weight:bold;">|</span>
    rm <span style="color:#996600;">&quot;coverage.data&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">exist</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;coverage.data&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#6666ff; font-weight:bold;">Rake::Task</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;rcov:cucumber&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">invoke</span>
    <span style="color:#6666ff; font-weight:bold;">Rake::Task</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;rcov:rspec&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">invoke</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>




<p>The important part here is on line 7, we want rcov to exclude our features directory. We obviously don&#8217;t need or want rcov telling us that our feature files are not &#8220;covered&#8221;. To solve this problem we&#8217;ve simply excluded the features directory from rcov&#8217;s processing.</p>

<p>We also need to slightly modify <code>sample-app/spec/rcov.opts</code> to get the full rspec + cucumber coverage data.</p>

<p>Your rcov.opts should look like this:</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">--exclude &quot;spec/*,gems/*,features/*&quot; 
--rails
--aggregate &quot;coverage.data&quot;</pre></div></div>




<p>We again want to ignore our cucumber features and we also want to tell rcov to aggregate data in a file called coverage.data. This is used in the above rake task.</p>

<h3>Write Some Specs and Features!</h3>

<p>Act like you know what you&#8217;re doing and write some models, controllers whatever. Add some specs and features too.</p>

<h3>Autotest Workflow</h3>

<p>Open a terminal and make your way to your sample rails app and fire up autotest. You might see something like the following, depending on how many specs and features you&#8217;ve got.</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">$&gt; autotest
loading autotest/cucumber_rails_rspec
opts 
...
&nbsp;
Finished in 0.06276 seconds
&nbsp;
3 examples, 0 failures
================================================================================
&nbsp;
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby /Library/Ruby/Gems/1.8/gems/cucumber-0.2.3/bin/cucumber --format progress --format rerun --out /var/folders/Aq/Aqp06i3dFnqse+tQgQA+1++++TI/-Tmp-/autotest-cucumber.75956.0 features
.................
&nbsp;
4 scenarios
17 passed steps
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby /Library/Ruby/Gems/1.8/gems/rspec-1.2.2/bin/spec --autospec spec/models/intern_spec.rb -O spec/spec.opts 
...
&nbsp;
Finished in 0.062995 seconds
&nbsp;
3 examples, 0 failures
================================================================================
&nbsp;
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby /Library/Ruby/Gems/1.8/gems/cucumber-0.2.3/bin/cucumber --format progress --format rerun --out /var/folders/Aq/Aqp06i3dFnqse+tQgQA+1++++TI/-Tmp-/autotest-cucumber.75956.1 features
.................
&nbsp;
4 scenarios
17 passed steps</pre></div></div>




<h3>The <span class="caps">REALLY </span>important stuff</h3>


<ol>
<li>make sure you&#8217;ve got &#8220;ENV['AUTOFEATURE'] = true&#8221; in your test.rb otherwise autotest won&#8217;t run your features automatically</li>
<li>make sure you&#8217;ve got &#8220;ENV['RSPEC'] = true&#8221; in your bash profile or else autotest won&#8217;t run your specs automatically</li>
<li>make sure you&#8217;ve got &#8220;&#8211;aggregate = &#8216;coverage.data&#8217;&#8221; in your spec/rcov.opts file if you&#8217;re going to use the above rake task and hope to get combined rcov coverage data between rspec and cucumber</li>
<li>make sure you&#8217;re excluding the features directory from rcov where required or else you&#8217;ll end up with misleading rcov data.</li>
</ol>



<h3>Gem Versions</h3>

<p>Here&#8217;s a list of the current gems and their versions that I used in preparing this guide.</p>


<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">*** LOCAL GEMS ***
&nbsp;
actionmailer (2.3.2, 1.3.6, 1.3.3)
actionpack (2.3.2, 1.13.6, 1.13.3)
actionwebservice (1.2.6, 1.2.3)
activerecord (2.3.2, 1.15.6, 1.15.3)
activeresource (2.3.2)
activesupport (2.3.2, 1.4.4, 1.4.2)
acts_as_ferret (0.4.1)
addressable (2.0.2)
builder (2.1.2)
capistrano (2.0.0)
carlosbrando-autotest-notification (1.9.1)
cgi_multipart_eof_fix (2.5.0, 2.2)
cucumber (0.2.3)
daemons (1.0.9, 1.0.7)
data_objects (0.9.11)
diff-lcs (1.1.2)
dnssd (0.6.0)
extlib (0.9.11)
fastthread (1.0.1, 1.0)
fcgi (0.8.7)
ferret (0.11.4)
gem_plugin (0.2.3, 0.2.2)
highline (1.2.9)
hpricot (0.6)
libxml-ruby (0.3.8.4)
mongrel (1.1.4, 1.0.1)
mysql (2.7)
needle (1.3.0)
net-sftp (1.1.0)
net-ssh (1.1.2)
nokogiri (1.2.3)
polyglot (0.2.5)
rack (0.9.1)
rails (2.3.2, 1.2.6, 1.2.3)
rake (0.8.4, 0.7.3)
rcov (0.8.1.2.0)
RedCloth (3.0.4)
rspec (1.2.2)
rspec-rails (1.2.2)
ruby-openid (1.1.4)
ruby-yadis (0.3.4)
rubynode (0.1.3)
sources (0.0.1)
sqlite3-ruby (1.2.1)
term-ansicolor (1.0.3)
termios (0.9.4)
textmate (0.9.2)
thor (0.9.9)
thoughtbot-factory_girl (1.2.0)
treetop (1.2.5)
webrat (0.4.3)
ZenTest (4.0.0)</pre></div></div>




<h3>El Fin</h3>

<p>Hopefully this guide was useful or had that one little step that you needed to get everything working. I&#8217;m sure this will all be out of date in the coming weeks, but I&#8217;ll try to keep it as up-to-date as possible. If you see any errors, or can better explain some of the missing pieces, please post a comment. Thanks!</p>

<p class="footnote" id="fn1"><sup>1</sup> <a href="http://github.com/dchelimsky/rspec/tree/master">http://github.com/dchelimsky/rspec/tree/master</a></p>

<p class="footnote" id="fn2"><sup>2</sup> <a href="http://github.com/dchelimsky/rspec-rails/tree/master">http://github.com/dchelimsky/rspec-rails/tree/master</a></p>

<p class="footnote" id="fn3"><sup>3</sup> <a href="http://github.com/aslakhellesoy/cucumber/tree/master">http://github.com/aslakhellesoy/cucumber/tree/master</a></p>

<p class="footnote" id="fn4"><sup>4</sup> <a href="http://wiki.github.com/brynary/webrat">http://wiki.github.com/brynary/webrat</a></p>

<p class="footnote" id="fn5"><sup>5</sup> <a href="http://github.com/tenderlove/nokogiri/tree/master">http://github.com/tenderlove/nokogiri/tree/master</a> </p>

<p class="footnote" id="fn6"><sup>6</sup> <a href="http://rubyforge.org/projects/rcov/">http://rubyforge.org/projects/rcov/</a></p>

<p class="footnote" id="fn7"><sup>7</sup> <a href="http://www.zenspider.com/ZSS/Products/ZenTest/#rsn">http://www.zenspider.com/ZSS/Products/ZenTest/#rsn</a></p>

<p class="footnote" id="fn8"><sup>8</sup> <a href="http://www.zenspider.com/ZSS/Products/ZenTest/">http://www.zenspider.com/ZSS/Products/ZenTest/</a></p>

<p class="footnote" id="fn9"><sup>9</sup> <a href="http://github.com/thoughtbot/factory_girl/tree/master">http://github.com/thoughtbot/factory_girl/tree/master</a></p>

<p class="footnote" id="fn10"><sup>10</sup> <a href="http://github.com/carlosbrando/autotest-notification/tree/master">http://github.com/carlosbrando/autotest-notification/tree/master</a></p><img src="http://feeds.feedburner.com/~r/claytonlengelzigich/~4/tYHkTUt5L1s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.claytonlz.com/index.php/2009/04/how-to-setup-rspec-cucumber-webrat-rcov-and-autotest-on-leopard/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		<feedburner:origLink>http://www.claytonlz.com/index.php/2009/04/how-to-setup-rspec-cucumber-webrat-rcov-and-autotest-on-leopard/</feedburner:origLink></item>
		<item>
		<title>The FAIL Monster Loves Excuses</title>
		<link>http://feedproxy.google.com/~r/claytonlengelzigich/~3/1DjkXQ87JNY/</link>
		<comments>http://www.claytonlz.com/index.php/2009/03/the-fail-monster-loves-excuses/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 17:15:58 +0000</pubDate>
		<dc:creator>Clayton</dc:creator>
				<category><![CDATA[Ideas]]></category>
		<category><![CDATA[Riffs]]></category>
		<category><![CDATA[accountability]]></category>
		<category><![CDATA[FAIL]]></category>
		<category><![CDATA[learning]]></category>
		<category><![CDATA[people]]></category>

		<guid isPermaLink="false">http://www.claytonlz.com/?p=175</guid>
		<description><![CDATA[Do you remember watching the FAIL Monster on Sesame Street? Never heard of the FAIL Monster? Weird, I'm pretty sure he was "Cookie Monster's":http://www.youtube.com/watch?v=dhUFxaauNTE cousin or something. He would pop-up and sing a little song about your failures and then at the end he would go crazy and NOM NOM NOM all of your excuses. The really strange thing is that when I grew up, I still saw the FAIL Monster, except he was all over, eating up everyone's excuses, not just mine. When was the last time the FAIL Monster paid _you_ a visit?]]></description>
			<content:encoded><![CDATA[<p></p><p>Do you remember watching the <span class="caps">FAIL</span> Monster on Sesame Street? Never heard of the <span class="caps">FAIL</span> Monster? Weird, I&#8217;m pretty sure he was <a href="http://www.youtube.com/watch?v=dhUFxaauNTE">Cookie Monster&#8217;s</a> cousin or something. He would pop-up and sing a little song about your failures and then at the end he would go crazy and <span class="caps">NOM NOM NOM </span>all of your excuses. The really strange thing is that when I grew up, I still saw the <span class="caps">FAIL</span> Monster, except he was all over, eating up everyone&#8217;s excuses, not just mine. When was the last time the <span class="caps">FAIL</span> Monster paid <em>you</em> a visit?</p>

<h3>The <span class="caps">FAIL</span> Monster Is Your Worst Best Friend</h3>

<p>When you first meet him you&#8217;re trying to figure out what this asshole is doing hanging out right after you really screwed up. You realize that he&#8217;s no good, but as time goes on, you start enjoying his company. He loves showing up because he knows there will be excuses aplenty.</p>

<p>Here are some situations when you might see him:</p>


<ul>
<li>You&#8217;ve messed up and can&#8217;t take responsibility</li>
<li>The project is off track and it&#8217;s not at <em>all</em> your fault</li>
<li>If only <em>&lt; outside agent &gt;</em> would have completed <em>&lt; task &gt;</em> on time</li>
<li>You start using <a href="http://www.youtube.com/watch?v=5110hk9W71E">Fat Bastard&#8217;s</a> circular logic to explain away your problems</li>
<li>&#8220;I don&#8217;t have <em>&lt; resource &gt;</em> to do <em>&lt; what is right &gt;</em></li>
<li>You <a href="http://smartic.us/2008/8/15/tatft-i-feel-a-revolution-coming-on">don&#8217;t write tests</a><br />
<br /></li>
</ul>



<h3>Put the <span class="caps">FAIL</span> Monster on a Diet</h3>

<p>Here is a quick guide to help you trim down your personal <span class="caps">FAIL</span> Monster:</p>


<ol>
<li>Quit making so many goddamned excuses!<br />
<br /></li>
</ol>



<p>Stop making excuses for your lack of understanding, your irresponsibility, your lack of prospects and your shit attitude. Take the time to push yourself, learn a new skill, read a book, meet people, take a leadership role, achieve greatness and succeed.</p>

<p>You can make excuses for everything, the only thing they&#8217;re good for is feeding your own <span class="caps">FAILURE.</span></p><img src="http://feeds.feedburner.com/~r/claytonlengelzigich/~4/1DjkXQ87JNY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.claytonlz.com/index.php/2009/03/the-fail-monster-loves-excuses/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.claytonlz.com/index.php/2009/03/the-fail-monster-loves-excuses/</feedburner:origLink></item>
	</channel>
</rss>
