<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>Pathfinder Development &#187; Ruby on Rails</title>
	<atom:link href="http://www.pathf.com/blogs/category/ruby-on-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pathf.com/blogs</link>
	<description>Running commentary about agile development, user experience design and Ajax.</description>
	<lastBuildDate>Tue, 16 Mar 2010 13:42:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>mort_calc gem: Rails Mortgage Calculation Gem</title>
		<link>http://www.pathf.com/blogs/2010/02/mortcalc-gem/</link>
		<comments>http://www.pathf.com/blogs/2010/02/mortcalc-gem/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 21:26:39 +0000</pubDate>
		<dc:creator>Perry Hertler</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[mortgage calculation]]></category>
		<category><![CDATA[rails gem]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=4829</guid>
		<description><![CDATA[Ruby gem for calculating APR<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2010/02/mortcalc-gem/">mort_calc gem: Rails Mortgage Calculation Gem</a></p>



Related posts:<ol><li><a href='http://www.pathf.com/blogs/2009/07/launched-rapid-reporting-employment-chek/' rel='bookmark' title='Permanent Link: Launched:  Rapid Reporting Employment Chek'>Launched:  Rapid Reporting Employment Chek</a></li><li><a href='http://www.pathf.com/blogs/2008/11/installing-edge-ferretacts_as_ferret/' rel='bookmark' title='Permanent Link: Installing Edge Ferret/acts_as_ferret'>Installing Edge Ferret/acts_as_ferret</a></li><li><a href='http://www.pathf.com/blogs/2008/09/tips-tricks-from-windy-city-rails/' rel='bookmark' title='Permanent Link: Rails Performance, Code Metrics, and Locking Down your Application: Tips &#038; Tricks from Windy City Rails 2008'>Rails Performance, Code Metrics, and Locking Down your Application: Tips &#038; Tricks from Windy City Rails 2008</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>I recently published the <a href="http://gemcutter.org/gems/mortgage_calc" rel="nofollow" >mort_calc gem</a> at <a href="http://gemcutter.org" rel="nofollow" >gemcutter.org</a>. The code can be found at <a href="http://github.com/perry3819/mort_calc/" rel="nofollow" >http://github.com/perry3819/mort_calc/</a>.</p>
<p>The gem calculates the <a href="http://en.wikipedia.org/wiki/Annual_percentage_rate" rel="nofollow" >APR</a> and monthly payment for a mortgage in the United States.</p>
<p>Calculating the monthly payment is straight forward.</p>
<p><img class="alignnone size-full wp-image-4831" title="monthly_payment" src="http://www.pathf.com/blogs/wp-content/uploads/2010/02/monthly_payment.png" alt="monthly_payment" width="161" height="66" /></p>
<p>C = Loan amount</p>
<p>E = Extra costs</p>
<p>r = monthly interest rate = interest rate / 1200</p>
<p>N = amortization term in months</p>
<p>An iterative approach is needed to find the APR. The equation for the APR follows.<br />
<span id="more-4829"></span></p>
<p><img class="alignnone size-full wp-image-4830" title="apr" src="http://www.pathf.com/blogs/wp-content/uploads/2010/02/apr.png" alt="apr" width="163" height="75" /></p>
<p>a = APR/1200</p>
<p>N = amortization term in months</p>
<p>P = Monthly payment (including all fees paid by borrower)</p>
<p>C = Loan amount</p>
<p>The following graph shows the APR calculation plotted for N = 360, P = 2500, and C = 400,000. The APR is where the line crosses the <strong>A</strong> axis.</p>
<p><img class="alignnone size-full wp-image-4835" title="apr_plot" src="http://www.pathf.com/blogs/wp-content/uploads/2010/02/apr_plot.png" alt="apr_plot" width="499" height="325" /></p>
<p>I chose the<a href="http://en.wikipedia.org/wiki/Newton's_method" rel="nofollow" > Newton-Raphson method</a> to quickly find a precise solution.</p>
<p><img class="alignnone size-full wp-image-4834" title="Screen shot 2010-02-16 at 1.51.57 PM" src="http://www.pathf.com/blogs/wp-content/uploads/2010/02/Screen-shot-2010-02-16-at-1.51.57-PM.png" alt="Screen shot 2010-02-16 at 1.51.57 PM" width="140" height="46" /></p>
<p>The <a href="http://github.com/perry3819/mort_calc/blob/master/lib/mortgage_calc/mortgage_util.rb" rel="nofollow" >MortgageUtil</a>.calculate_apr method provides a starting value of the interest rate, which makes the Newton-Raphson converge on a accurate solution between 1 and 3 passes.<br />
<script src="http://gist.github.com/305850.js?file=gistfile1.txt"></script></p>
<p><strong>Installation</strong></p>
<p>% sudo gem install gemcutter</p>
<p>% gem tumble</p>
<p>% sudo gem install mortgage_calc</p>
<p><strong>Example</strong><br />
<script src="http://gist.github.com/305874.js?file=gistfile1.txt"></script></p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2010/02/mortcalc-gem/">mort_calc gem: Rails Mortgage Calculation Gem</a></p>


<p>Related posts:<ol><li><a href='http://www.pathf.com/blogs/2009/07/launched-rapid-reporting-employment-chek/' rel='bookmark' title='Permanent Link: Launched:  Rapid Reporting Employment Chek'>Launched:  Rapid Reporting Employment Chek</a></li><li><a href='http://www.pathf.com/blogs/2008/11/installing-edge-ferretacts_as_ferret/' rel='bookmark' title='Permanent Link: Installing Edge Ferret/acts_as_ferret'>Installing Edge Ferret/acts_as_ferret</a></li><li><a href='http://www.pathf.com/blogs/2008/09/tips-tricks-from-windy-city-rails/' rel='bookmark' title='Permanent Link: Rails Performance, Code Metrics, and Locking Down your Application: Tips &#038; Tricks from Windy City Rails 2008'>Rails Performance, Code Metrics, and Locking Down your Application: Tips &#038; Tricks from Windy City Rails 2008</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2010/02/mortcalc-gem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrading Rails Applications &#8211; Some things to keep in mind!</title>
		<link>http://www.pathf.com/blogs/2009/12/upgrading-rails-applications-mind/</link>
		<comments>http://www.pathf.com/blogs/2009/12/upgrading-rails-applications-mind/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 20:06:27 +0000</pubDate>
		<dc:creator>Karthik Muthupalaniappan</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Web Application Development]]></category>
		<category><![CDATA[Web Infrastructure]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Upgrade]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=4517</guid>
		<description><![CDATA[So we just went through this humongous (believe me!) effort of upgrading the technical platform for one of our existing Rails applications that was running Rails 2.1, Ruby 1.7 and Mongrel cluster. The goal was to upgrade to Rails 2.3, Enterprise Ruby 1.8.6 and Passenger. It all started out as well as you would think. [...]<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/12/upgrading-rails-applications-mind/">Upgrading Rails Applications &#8211; Some things to keep in mind!</a></p>



Related posts:<ol><li><a href='http://www.pathf.com/blogs/2008/11/testing-various-roles-in-ruby-on-rails/' rel='bookmark' title='Permanent Link: Testing various roles in ruby on rails'>Testing various roles in ruby on rails</a></li><li><a href='http://www.pathf.com/blogs/2008/07/developing-iphone-applications-using-ruby-on-rails-and-eclipse-part-2-displaying-iphone-content-to-the-client-also-up-on-ibm-developerworks/' rel='bookmark' title='Permanent Link: &#8220;Developing iPhone applications using Ruby on Rails and Eclipse, Part 2: Displaying iPhone content to the client&#8221; Also up on IBM Developerworks'>&#8220;Developing iPhone applications using Ruby on Rails and Eclipse, Part 2: Displaying iPhone content to the client&#8221; Also up on IBM Developerworks</a></li><li><a href='http://www.pathf.com/blogs/2008/07/developing-iphone-applications-using-ruby-on-rails-and-eclipse-part-3-developing-advanced-views-for-iphone-now-available-on-ibm-developerworks/' rel='bookmark' title='Permanent Link: &#8220;Developing iPhone applications using Ruby on Rails and Eclipse, Part 3: Developing advanced views for iPhone&#8221; now available on IBM Developerworks'>&#8220;Developing iPhone applications using Ruby on Rails and Eclipse, Part 3: Developing advanced views for iPhone&#8221; now available on IBM Developerworks</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>So we just went through this humongous (believe me!) effort of upgrading the technical platform for one of our existing Rails applications that was running Rails 2.1, Ruby 1.7 and Mongrel cluster. The goal was to upgrade to Rails 2.3, Enterprise Ruby 1.8.6 and Passenger. It all started out as well as you would think. Updating the Rails gem, Ruby version, installing/configuring <a href="http://www.modrails.com/" rel="nofollow"  target="_blank">Passenger</a> and updating relevant gems was pretty quick and smooth. Some quick and dirty testing of the application did not reveal any major problems or issues. Great! You are thinking the upgrade is mostly done att this point before you move on to the tests in the application!</p>
<p><strong>Tests</strong></p>
<p>Tests can prove to be major hurdle in upgrading Rails applications.  In our specific case,  close to 70% of the tests were either broken or failing due to a number of reasons.  Actually, the number of broken tests was way way greater than failing tests which led us to think the changes in the Rails testing API caused most of these issues.  Some of the issues were also caused by a plugin or gem that was used to support the tests not being compatible with the new API. It took us quite a bit of effort to figure out the reasons for the issues and also find the fixes.<br />
<span id="more-4517"></span><br />
<strong>Plugins</strong></p>
<p>I think this is other major pain point. If your application uses a bunch of plugins to support what it does, then be wary of the roadblocks they can pose when it is time to upgrade Rails or Ruby in your application.  The problem mostly arises because of the fact that the community or the user group that built the plugin dont continue to support it or doesnt bother to make it compatible with newer versions of Ruby or Rails. In situations like these, you get thrown into a state of dilemma thinking about whether to write a new plugin to replace the existing one or fix the existing one both of which could be time-consuming.  It makes sense to spend time finding about what exactly is the need for the plugin in the application and if it is indispensable etc before making a wise decision.</p>
<p><strong>Deploying the upgraded application</strong></p>
<p>Though this may not be as hairy as the first two, it could be still prove to be a challenge especially when your the application server is changing (Mongrel -&gt; Passenger).  I think it is important to ensure the script is modified appropriately and is tested adequately in your staging environment before you deploy the upgraded application to the real-world.</p>
<p><strong>Session handling issue with Rails 2.3</strong></p>
<p>For the benefit of Rails community out there, I d like to briefly recount one of the problems that caused me a quite a bit of headache during the upgrade.  The application in question is a content management website with multiple subdomains. The issue that I saw after the upgrade was after user logged into the one of the subdomains in the site and navigated away to a different subdomain, the user got logged out. When the user returned to the subdomain where he logged in originally, he was logged in again.  After several hours of effort trying to debug the issue (at one point,  I was even thinking about stripping out Restful authentication and plugging in Authlogic), this <a href="http://stackoverflow.com/questions/941939/share-rails-sessions-among-applications" rel="nofollow"  target="_blank">post</a> saved the day for me.  It boiled down to setting this in the &lt;environment&gt;.rb file for the different environments :</p>
<pre class="ruby">config.<span style="color:#9900CC;">action_controller</span>.<span style="color:#9900CC;">session</span> = <span style="color:#006600; font-weight:bold;">&#123;</span>
  <span style="color:#ff3333; font-weight:bold;">:domain</span> =&gt; <span style="color:#996600;">&quot;&lt;root-domain-name&gt;&quot;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;</pre>
<p>This allowed the session information to be persisted across multiple subdomains of the site.</p>
<p><strong>Some Advice</strong></p>
<ul>
<li>Generally, the amount of effort to upgrade is going to be directly proportional to the time between the upgrades. So, upgrade your application often!</li>
<li>When choosing plugins or gems to support your application, consider the upgradability of these before you decide to use them!</li>
<li>Last but not the least, spend atleast 25% of the time necessary for the upgrade itself to estimate how long it might take to get it done <img src='http://www.pathf.com/blogs/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </li>
</ul>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/12/upgrading-rails-applications-mind/">Upgrading Rails Applications &#8211; Some things to keep in mind!</a></p>


<p>Related posts:<ol><li><a href='http://www.pathf.com/blogs/2008/11/testing-various-roles-in-ruby-on-rails/' rel='bookmark' title='Permanent Link: Testing various roles in ruby on rails'>Testing various roles in ruby on rails</a></li><li><a href='http://www.pathf.com/blogs/2008/07/developing-iphone-applications-using-ruby-on-rails-and-eclipse-part-2-displaying-iphone-content-to-the-client-also-up-on-ibm-developerworks/' rel='bookmark' title='Permanent Link: &#8220;Developing iPhone applications using Ruby on Rails and Eclipse, Part 2: Displaying iPhone content to the client&#8221; Also up on IBM Developerworks'>&#8220;Developing iPhone applications using Ruby on Rails and Eclipse, Part 2: Displaying iPhone content to the client&#8221; Also up on IBM Developerworks</a></li><li><a href='http://www.pathf.com/blogs/2008/07/developing-iphone-applications-using-ruby-on-rails-and-eclipse-part-3-developing-advanced-views-for-iphone-now-available-on-ibm-developerworks/' rel='bookmark' title='Permanent Link: &#8220;Developing iPhone applications using Ruby on Rails and Eclipse, Part 3: Developing advanced views for iPhone&#8221; now available on IBM Developerworks'>&#8220;Developing iPhone applications using Ruby on Rails and Eclipse, Part 3: Developing advanced views for iPhone&#8221; now available on IBM Developerworks</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2009/12/upgrading-rails-applications-mind/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>What is the ideal Senior Developer skillset?</title>
		<link>http://www.pathf.com/blogs/2009/11/ideal-senior-developer-skillset/</link>
		<comments>http://www.pathf.com/blogs/2009/11/ideal-senior-developer-skillset/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 22:21:53 +0000</pubDate>
		<dc:creator>John McCaffrey</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Software Development Best Practices]]></category>
		<category><![CDATA[assembla]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[career]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[Interview]]></category>
		<category><![CDATA[job]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=4335</guid>
		<description><![CDATA[


We're currently in the process of interviewing candidates for 1-2 Senior, and 2-3 junior level Rails Developers, and I'm wondering about the skills that are most critical, and how best to identify the best candidates.
My normal interview process flows like this:

Quick Phone screen evaluating basic development skills, background, availability, personality
Basic coding problem (less than 1hr [...]<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/11/ideal-senior-developer-skillset/">What is the ideal Senior Developer skillset?</a></p>



Related posts:<ol><li><a href='http://www.pathf.com/blogs/2008/01/20-useful-faceb/' rel='bookmark' title='Permanent Link: 20 useful Facebook/FBJS developer resources'>20 useful Facebook/FBJS developer resources</a></li><li><a href='http://www.pathf.com/blogs/2007/11/the-art-of-inte/' rel='bookmark' title='Permanent Link: Faking the art of interrogation'>Faking the art of interrogation</a></li><li><a href='http://www.pathf.com/blogs/2008/01/interview-songb/' rel='bookmark' title='Permanent Link: Interview: Songbird developer evangelist Stephen Lau'>Interview: Songbird developer evangelist Stephen Lau</a></li></ol>]]></description>
			<content:encoded><![CDATA[<div class="right">
<a href="http://www.pathf.com/blogs/wp-content/uploads/2009/11/IMGP3922.JPG" target="_blank"><img class="alignright size-full wp-image-4339" title="IMGP3922" src="http://www.pathf.com/blogs/wp-content/uploads/2009/11/IMGP3922.JPG" alt="IMGP3922" width="368" height="257" /></a>
</div>
<p>We're currently in the process of interviewing candidates for 1-2 Senior, and 2-3 junior level Rails Developers, and I'm wondering about the skills that are most critical, and how best to identify the best candidates.</p>
<p>My normal interview process flows like this:</p>
<ol>
<li>Quick Phone screen evaluating basic development skills, background, availability, personality</li>
<li>Basic coding problem (less than 1hr to complete)</li>
<li>Phone call to review coding problem, 'how would you handle X?' questions, etc</li>
<li>On site interview targeting: Communication, Communication, Communication, (and tech)</li>
<li>Final decision</li>
</ol>
<p>Independent of the language they will be working with, I've found decent success with having candidates answer some standard dev questions, solve a basic coding problem, and demonstrate their ability to whiteboard a design.</p>
<p>The problem is that it doesn't scale. When we've opened up positions in the past, either Senior or Junior, there have been so many applications that its hard to contact them all. This leads to a reshuffling of the tasks and matching criteria, in an attempt to identify the 'best' matches, and 'filter out' the others.  So instead of calling each candidate first, we might simply reply to them with the details of the coding assignment. I've seen 40 people send the "I'm an extremely hard worker, very interested in your position and would do anything to join your wonderful company" cover letter and resume, and then get whittled down to only 10 candidates that actually submit the assignment.  (Note to applicants: 'showing up' is an important first step!)</p>
<p>I came across an interesting post titled <a href="http://www.rubyinside.com/11-tips-on-hiring-a-rails-developer-662.html" rel="nofollow" title="11 tips on hiring a rails developer"  target="_blank">'11 tips on hiring a rails developer'</a> which mentioned some 'filtering' criteria to identify the best candidates</p>
<p>You can read the full description of each one, but there are a few of these that I wanted to highlight:</p>
<ol>
<li><strong><span style="font-family: 'Lucida Grande',Verdana,Helvetica,Arial; font-size: 13px; line-height: 20px; text-align: left;">Don't use Monster.com or recruitment agencies.</span></strong></li>
<li><span style="font-family: 'Lucida Grande',Verdana,Helvetica,Arial; font-size: 13px; line-height: 20px; text-align: left;">Poach Talent from other companies!<br />
</span></li>
<li><span style="font-family: 'Lucida Grande',Verdana,Helvetica,Arial; font-size: 13px; line-height: 20px; text-align: left;">Don't hire someone that doesn't know Rails at all.</span></li>
<li><strong><span style="font-family: 'Lucida Grande',Verdana,Helvetica,Arial; font-size: 13px; line-height: 20px; text-align: left;">Look for open source contributions.</span></strong></li>
<li><strong><span style="font-family: 'Lucida Grande',Verdana,Helvetica,Arial; font-size: 13px; line-height: 20px; text-align: left;">A personal Rails blog is required.</span></strong></li>
<li><strong><span style="font-family: 'Lucida Grande',Verdana,Helvetica,Arial; font-size: 13px; line-height: 20px; text-align: left;">A university degree is not important.</span></strong></li>
<li><span style="font-family: 'Lucida Grande',Verdana,Helvetica,Arial; font-size: 13px; line-height: 20px; text-align: left;">Be wary of holes in proficiency.</span></li>
<li><span style="font-family: 'Lucida Grande',Verdana,Helvetica,Arial; font-size: 13px; line-height: 20px; text-align: left;">Avoid brand-name superstars.</span></li>
<li><span style="font-family: 'Lucida Grande',Verdana,Helvetica,Arial; font-size: 13px; line-height: 20px; text-align: left;">Hire perpetually.</span></li>
<li><span style="font-family: 'Lucida Grande',Verdana,Helvetica,Arial; font-size: 13px; line-height: 20px; text-align: left;">Have a company Rails blog</span></li>
<li><strong><span style="font-family: 'Lucida Grande',Verdana,Helvetica,Arial; font-size: 13px; line-height: 20px; text-align: left;">Special compensation.</span></strong></li>
</ol>
<p>So each of these tips is meant as a heuristic or proxy of the true underlying ability. Any time you are making generalizations you are going to miss out on a few exceptions, but hopefully you end up with what you are looking for.</p>
<p>Starting with the most controversial first, <strong>(#5) </strong> while I like the idea of giving a strong preference to someone that has a rails blog, and loves  Ruby, Rails, and Web Development enough to be opinionated and spend their own time ranting about it, I'm not sure I could make it a filtering criteria. Doesn't that seem a bit strong?</p>
<p>I feel the same about<strong> (#4)</strong> Open Source contribution. I think its great if they have it, but I'm not sure I would reject any candidates that haven't contributed to open source.</p>
<p>While I've met many systems administrators that <strong>(#6)</strong> don't have a degree, and are very good at their craft, I haven't really encountered many solid developers that don't have a degree. That's not to say they aren't out there, I'm just saying I've never encountered them, and I'm reluctant to use it as a filter. Do you think that there are many strong Rails developers out there without degrees? (I don't care if they  have a CS degree, but I think I prefer that they have some kind of degree)</p>
<p>As it relates to <strong>(#1)</strong> and<strong> (#11)</strong>, I know for sure that the economics of finding a candidate through your own network and contacts can be less expensive than the recruiter fees (assuming you find a decent candidate and don't waste a lot of your own time doing it), and if you are able to find someone directly, it frees up cash for such amenities as 'New Macbook Pro', 'RailsConf', and 'Fridge full of XXX'.</p>
<h4>If I was in charge of everything</h4>
<p>I really like what <a href="http://blog.jonudell.net/2009/02/09/a-conversation-with-andy-singleton-about-distributed-software-development/" rel="nofollow"  target="_blank">Andy Singleton</a> describes regarding how his team at <a href="http://www.assembla.com" rel="nofollow"  target="_blank">Assembla</a> is organized and tackles Agile Development, and on the right project, I'd really like take his advice and try this one:</p>
<p>"<span style="color: #29303b; font-family: Georgia,Verdana,Arial,serif; font-size: 12px; line-height: 18px; text-align: left;"><strong>Don’t interview</strong>. Just pay people to join a project, pull a task from the queue, and find out what they can do."</span></p>
<p><span style="color: #29303b; font-family: Georgia,Verdana,Arial,serif; font-size: 12px; line-height: 18px; text-align: left;">Anyways,  I'd be very interested in your thoughts regarding what makes for a Solid Rails developer, where you find them, how you keep them, and what you've learned.</span></p>
<p><span style="color: #29303b; font-family: Georgia,Verdana,Arial,serif; font-size: 12px; line-height: 18px; text-align: left;">(Oh, and if you know any passionate Rails Developers in the Chicago area, send them over!)<br />
</span></p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/11/ideal-senior-developer-skillset/">What is the ideal Senior Developer skillset?</a></p>


<p>Related posts:<ol><li><a href='http://www.pathf.com/blogs/2008/01/20-useful-faceb/' rel='bookmark' title='Permanent Link: 20 useful Facebook/FBJS developer resources'>20 useful Facebook/FBJS developer resources</a></li><li><a href='http://www.pathf.com/blogs/2007/11/the-art-of-inte/' rel='bookmark' title='Permanent Link: Faking the art of interrogation'>Faking the art of interrogation</a></li><li><a href='http://www.pathf.com/blogs/2008/01/interview-songb/' rel='bookmark' title='Permanent Link: Interview: Songbird developer evangelist Stephen Lau'>Interview: Songbird developer evangelist Stephen Lau</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2009/11/ideal-senior-developer-skillset/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>A Pair of Kings Beats A Single Ace: Pair Programming, Agile Rails, and You</title>
		<link>http://www.pathf.com/blogs/2009/09/a-pair-of-kings-beats-a-single-ace-pair-programming-agile-rails-and-you/</link>
		<comments>http://www.pathf.com/blogs/2009/09/a-pair-of-kings-beats-a-single-ace-pair-programming-agile-rails-and-you/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 14:59:01 +0000</pubDate>
		<dc:creator>Noel Rappin</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Software Development Best Practices]]></category>
		<category><![CDATA[agile]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=4158</guid>
		<description><![CDATA[
A lot of pair programming chatter this week. Starting with a New York times article describing pair programming at Hashrocket. It's an interesting article, with a tone that could be described as "anthropologist describing the strange, yet quaint customs of the native tribe"
Obie Fernandez followed up with a list of 10 reasons why pairing doesn't [...]<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/09/a-pair-of-kings-beats-a-single-ace-pair-programming-agile-rails-and-you/">A Pair of Kings Beats A Single Ace: Pair Programming, Agile Rails, and You</a></p>



Related posts:<ol><li><a href='http://www.pathf.com/blogs/2007/11/the-importance/' rel='bookmark' title='Permanent Link: The Importance of Pair Programming'>The Importance of Pair Programming</a></li><li><a href='http://www.pathf.com/blogs/2009/07/growing-into-pair-programming/' rel='bookmark' title='Permanent Link: Growing Into Pair Programming'>Growing Into Pair Programming</a></li><li><a href='http://www.pathf.com/blogs/2007/09/pair-programmin/' rel='bookmark' title='Permanent Link: Pair Programming with VNC'>Pair Programming with VNC</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.pathf.com/blogs/wp-content/uploads/2009/09/C34FF759-31EE-407B-A9E2-0A4611213735.jpg" alt="C34FF759-31EE-407B-A9E2-0A4611213735.jpg" border="0" width="200" height="211" class="right"/></p>
<p>A lot of pair programming chatter this week. Starting with <a href="http://www.nytimes.com/2009/09/20/jobs/20pre.html?_r=2" rel="nofollow" >a New York times article describing pair programming at Hashrocket</a>. It's an interesting article, with a tone that could be described as "anthropologist describing the strange, yet quaint customs of the native tribe"</p>
<p>Obie Fernandez <a href="http://blog.obiefernandez.com/content/2009/09/10-reasons-pair-programming-is-not-for-the-masses.html" rel="nofollow" >followed up with a list of 10 reasons why pairing doesn't work in most cases</a>. It's actually a list of the things that Hashrocket does to support pairing, although entries like "2. Most software developers just don't want to work that hard" and "1. Most software shops don't really care about excellence" do have a certain, "aren't we great" vibe to them, causing Mike Gunderloy <a href="http://twitter.com/MikeG1/status/4314308701" rel="nofollow" >to dryly observe</a>: "Funny, Extreme Programming Explained never said anything about fancy hw or being awesome as a prerequisite for pair programming." </p>
<p>C'mon Mike -- everybody knows that being awesome is a prerequisite for <em>everything</em> in XP.</p>
<p>Josh Susser adds <a href="http://blog.hasmanythrough.com/2009/9/23/pair-programming-isnt-right-for-all-projects" rel="nofollow" >that pair programming isn't right for all projects</a>, particularly projects that have long compile times that force the pair to stare blankly at the screen.</p>
<p>I'd also add this <a href="http://www.twit.tv/floss87" rel="nofollow" >interview with Kent Beck</a> because a) every programmer could use some more Kent Beck in their life and b) because he talks about XP as being concerned with the the social context of programmers, with pairing being a part of that.</p>
<p>Now you are caught up. Here's the part where I talk. </p>
<p><span id="more-4158"></span>I've had a running debate with Dietrich for two years now. He thinks that Pair Programming is the number one most important part of an agile team. I think it's testing. That said, I do think pairing can be a nutritious part of your agile breakfast. But it's tricky to do right and easy to do wrong.</p>
<p><strong>Pairing is for the long haul</strong>. Like pretty much everything in the Agile toolkit, the real gain in pairing happens over time and is hard to quantify because it's the absence of friction later in the project. Code is cleaner and easier to change. System knowledge is more distributed, so you are less likely to freak out when Fred catches H1N1 a week before. </p>
<p>Actually, I'd describe most of the XP practices as "we thought we were trading short-term productivity for long-term productivity, then found that we got short-term gains as well." Certainly can apply to TDD. </p>
<p><strong>Project size and make up matters</strong>. A team of three developers, for example, is a challenge for an always-pairing environment. Even a team of two is a problem -- some tasks really don't lend themselves to pairing. If people on the team also has non-developer responsibilities, that's another challenge. </p>
<p><strong>Some people really don't like it</strong>. And I think it's glib to say "those people are lazy" or "those people don't care about excellence". Even I find pair programming really tiring, but in a "I worked hard today, plus I had to deal with another person all day." It's not unusual for programmers to be very strong Meyers-Briggs introvert-intuitives, and it's not surprising that personality type would find pairing a challenge. It's not insurmountable, but you do need to structure the pairing with people in mind -- the Hashrocket 25 minutes on/ 5 minutes off thing is a good start.</p>
<p>While I'm here, I think you can really overstate the "people work harder with somebody next to them" thing. Pairing is great and helpful because of the continual review and talking about what you are doing. Conceiving pairing as a way to use peer pressure to keep your coders off of Twitter is, I submit, not very much in keeping with the spirit of the Agile Manifesto.</p>
<p><strong>The physical layout is really important</strong>. A lot of Obie's piece is about this. I just want to emphasize first that pairing is a lot louder than solo programming, and this can be an issue in open office environments, and also that pairing really does work better on a neutral environment that isn't either developer's home machine.</p>
<p><strong>Pairing is hard to reconcile with offsite practices</strong> And I don't mean just when you're working with six guys in Krakow, but also any kind of work at home, flexible hours, programmer-friendly kind of time structure is a real challenge to integrate with pairing.</p>
<p>Hmm... A lot of challenges, not much guidance. Which matches my feelings. When put in the right context, pairing is fantastic. But the context can be elusive, even for people with the best of intentions and talent.</p>
<p>Would this have been a better blog post if I had paired with a co-worker?</p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/09/a-pair-of-kings-beats-a-single-ace-pair-programming-agile-rails-and-you/">A Pair of Kings Beats A Single Ace: Pair Programming, Agile Rails, and You</a></p>


<p>Related posts:<ol><li><a href='http://www.pathf.com/blogs/2007/11/the-importance/' rel='bookmark' title='Permanent Link: The Importance of Pair Programming'>The Importance of Pair Programming</a></li><li><a href='http://www.pathf.com/blogs/2009/07/growing-into-pair-programming/' rel='bookmark' title='Permanent Link: Growing Into Pair Programming'>Growing Into Pair Programming</a></li><li><a href='http://www.pathf.com/blogs/2007/09/pair-programmin/' rel='bookmark' title='Permanent Link: Pair Programming with VNC'>Pair Programming with VNC</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2009/09/a-pair-of-kings-beats-a-single-ace-pair-programming-agile-rails-and-you/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Ruby on Rails Internship</title>
		<link>http://www.pathf.com/blogs/2009/09/ruby-rails-internship/</link>
		<comments>http://www.pathf.com/blogs/2009/09/ruby-rails-internship/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 21:07:09 +0000</pubDate>
		<dc:creator>Dietrich Kappe</dc:creator>
				<category><![CDATA[Pathfinder General]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Ruby on Rails Internship]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=4085</guid>
		<description><![CDATA[
If you're an ambitious new Rails developer in Chicago who wants to work along side Dr. Noel and our other sage Rails developers, check out our Rails Internship.

Pathfinder Development - creating innovative software that builds business value. 
Ruby on Rails Internship


Related posts:Why Chicago is Rails-town, USASummer Software Development InternshipSelling colleagues on progressive enhancement<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/09/ruby-rails-internship/">Ruby on Rails Internship</a></p>



Related posts:<ol><li><a href='http://www.pathf.com/blogs/2008/08/why-chicago-is-rails-town-usa/' rel='bookmark' title='Permanent Link: Why Chicago is Rails-town, USA'>Why Chicago is Rails-town, USA</a></li><li><a href='http://www.pathf.com/blogs/2009/05/summer-software-development/' rel='bookmark' title='Permanent Link: Summer Software Development Internship'>Summer Software Development Internship</a></li><li><a href='http://www.pathf.com/blogs/2008/06/selling-colleagues-on-progressive-enhancement/' rel='bookmark' title='Permanent Link: Selling colleagues on progressive enhancement'>Selling colleagues on progressive enhancement</a></li></ol>]]></description>
			<content:encoded><![CDATA[<div style="float:right;padding:10px"><img title="Ruby on Rails" src="http://www.pathf.com/blogs/wp-content/uploads/2008/08/rails.png" alt="Ruby on Rails" width="50" height="64" /></div>
<p>If you're an ambitious new Rails developer in Chicago who wants to work along side Dr. Noel and our other sage Rails developers, check out our <a href="http://careers.pathf.com/index.php?m=careers&amp;p=showJob&amp;ID=45" rel="nofollow" title="Ruby on Rails Internship"  target="_blank">Rails Internship</a>.</p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/09/ruby-rails-internship/">Ruby on Rails Internship</a></p>


<p>Related posts:<ol><li><a href='http://www.pathf.com/blogs/2008/08/why-chicago-is-rails-town-usa/' rel='bookmark' title='Permanent Link: Why Chicago is Rails-town, USA'>Why Chicago is Rails-town, USA</a></li><li><a href='http://www.pathf.com/blogs/2009/05/summer-software-development/' rel='bookmark' title='Permanent Link: Summer Software Development Internship'>Summer Software Development Internship</a></li><li><a href='http://www.pathf.com/blogs/2008/06/selling-colleagues-on-progressive-enhancement/' rel='bookmark' title='Permanent Link: Selling colleagues on progressive enhancement'>Selling colleagues on progressive enhancement</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2009/09/ruby-rails-internship/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails DateTime.to_time, Time, and a case of &#8216;Why do you need to do that?&#8217;</title>
		<link>http://www.pathf.com/blogs/2009/09/rails-datetimetotime-time-case-why-that/</link>
		<comments>http://www.pathf.com/blogs/2009/09/rails-datetimetotime-time-case-why-that/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 19:24:07 +0000</pubDate>
		<dc:creator>John McCaffrey</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[CI]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[Hudson]]></category>
		<category><![CDATA[LINUX]]></category>
		<category><![CDATA[os]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[time]]></category>
		<category><![CDATA[timezone]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=4076</guid>
		<description><![CDATA[
The problem:  I needed to display a warning to a user if the data they were looking at was more than 90 days old.
The solution:  Create a method that takes 2 dates (either DateTime or Time), and returns the number of days, or hours between them.
  def self.difference_in_dates&#40;date1, date2, unit = 1.day&#41;
 [...]<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/09/rails-datetimetotime-time-case-why-that/">Rails DateTime.to_time, Time, and a case of &#8216;Why do you need to do that?&#8217;</a></p>



Related posts:<ol><li><a href='http://www.pathf.com/blogs/2008/08/ruby-on-rails-with-windows-how-i-made-it-work/' rel='bookmark' title='Permanent Link: Ruby on Rails with Windows &#8211; How I made it work'>Ruby on Rails with Windows &#8211; How I made it work</a></li><li><a href='http://www.pathf.com/blogs/2009/09/edge-case-city-requirements-testing-dates-hr-business-logic/' rel='bookmark' title='Permanent Link: edge case city: requirements and testing dates for HR business logic'>edge case city: requirements and testing dates for HR business logic</a></li><li><a href='http://www.pathf.com/blogs/2009/03/rails-test-prescriptions-is-now-on-sale/' rel='bookmark' title='Permanent Link: Rails Test Prescriptions is now on sale'>Rails Test Prescriptions is now on sale</a></li></ol>]]></description>
			<content:encoded><![CDATA[<div class="right"><a href="http://www.pathf.com/blogs/wp-content/uploads/2009/09/balboa_clock.jpg"><img class="alignright size-full wp-image-4176" title="balboa_clock" src="http://www.pathf.com/blogs/wp-content/uploads/2009/09/balboa_clock.jpg" alt="balboa_clock" width="536" height="382" /></a></div>
<p><strong>The problem</strong>:  I needed to display a warning to a user if the data they were looking at was more than 90 days old.</p>
<p><strong>The solution</strong>:  Create a method that takes 2 dates (either DateTime or Time), and returns the number of days, or hours between them.</p>
<pre class="ruby">  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">difference_in_dates</span><span style="color:#006600; font-weight:bold;">&#40;</span>date1, date2, unit = <span style="color:#006666;">1</span>.<span style="color:#9900CC;">day</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#0000FF; font-weight:bold;">nil</span> <span style="color:#9966CC; font-weight:bold;">if</span> date1.<span style="color:#0000FF; font-weight:bold;">nil</span>? || date2.<span style="color:#0000FF; font-weight:bold;">nil</span>? || unit == <span style="color:#006666;">0</span>
      <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span> date1.<span style="color:#9900CC;">to_time</span> - date2.<span style="color:#9900CC;">to_time</span> <span style="color:#006600; font-weight:bold;">&#41;</span> / unit<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">round</span>.<span style="color:#9900CC;">abs</span>
  <span style="color:#9966CC; font-weight:bold;">end</span></pre>
<p>The problem was simple enough, and my tests were all passing, so I moved on to my next task.</p>
<p>That code has been out in production for several months, but earlier this week, a new developer told me he got an error when running the test:</p>
<pre>  NoMethodError: undefined method `to_f'
    for Mon, 21 Sep 2009 14:29:38 -0500:DateTime</pre>
<p>(we're running this in Rails 2.0.2)</p>
<p>I looked at the code, knowing it was working before, ran the unit tests myself, and didn't see the issue. Now I'm on Windows and everyone else is on a mac, so as soon as I run into an issue that no one else has seen I want to prove if its a Windows problem. But wait, this test has been running in our Continuous Integration server (Hudson) for months, and no one else on the team ever had any issues with it, and the code has been working in production without any errors in the logs.</p>
<p>I jumped into rails script/console to see what's up, and here's what I found:</p>
<pre class="ruby"> &gt;&gt; x = <span style="color:#CC00FF; font-weight:bold;">DateTime</span>.<span style="color:#9900CC;">now</span>
=&gt; Wed, <span style="color:#006666;">23</span> Sep <span style="color:#006666;">2009</span> <span style="color:#006666;">00</span>:<span style="color:#006666;">00</span>:<span style="color:#006666;">00</span> <span style="color:#006666;">+0000</span>
&gt;&gt;; x.<span style="color:#9900CC;">to_time</span>
=&gt; Wed Sep <span style="color:#006666;">23</span> <span style="color:#006666;">00</span>:<span style="color:#006666;">00</span>:<span style="color:#006666;">00</span> UTC <span style="color:#006666;">2009</span>
&gt;&gt; x.<span style="color:#9900CC;">to_time</span>.<span style="color:#9900CC;">to_f</span>
=&gt; <span style="color:#006666;">1253664000.0</span></pre>
<p>Which is what I expected, but when I asked the other developer to run that same instruction, he got an error.</p>
<pre>&gt;&gt; DateTime.now.to_time.to_f
NoMethodError: undefined method `to_f'
  for Mon, 21 Sep 2009 14:29:38 -0500:DateTime</pre>
<p>What's up with that? We're running the same code, and all of our libraries are the same version. Looking at the date value in his error, I saw the timezone, and decided to try this variation locally:</p>
<pre class="ruby">&gt;&gt;  x = <span style="color:#CC00FF; font-weight:bold;">DateTime</span>.<span style="color:#9900CC;">parse</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;2009-09-21T14:29:38-0500&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
=&gt; Mon, <span style="color:#006666;">21</span> Sep <span style="color:#006666;">2009</span> <span style="color:#006666;">14</span>:<span style="color:#006666;">29</span>:<span style="color:#006666;">38</span> <span style="color:#006666;">-0500</span>
&gt;&gt; x.<span style="color:#9900CC;">to_time</span>.<span style="color:#9966CC; font-weight:bold;">class</span>
=&gt;; <span style="color:#CC00FF; font-weight:bold;">DateTime</span></pre>
<p>So I'm gathering that when there is a timezone and you ask DateTime.to_time, its just going to give you back a DateTime.<br />
<span id="more-4076"></span> I wasn't expecting this, and its exactly why my code was failing, because <em>sometimes </em> the DateTime.to_time will return just a DateTime object.  The <a href="http://www.railsbrain.com/api/rails-2.0.2/doc/index.html?a=C00000045&amp;name=DateTime#" rel="nofollow"  target="_blank">Rails 2.0.2 docs</a> do state this:</p>
<pre><strong>to_time()</strong>
Attempts to convert self to a Ruby Time object; returns self if out of range of Ruby Time class If self has an offset other than 0, self will just be returned unaltered, since there’s no clean way to map it to a Time</pre>
<p>Ok, so I guess I have no excuse, its written right there in the docs, but I guess I, didn't really look at the docs for the to_time method, or if I did, I didn't really get what it was telling me. Either way I have a problem that isn't going to change.</p>
<p>When I asked my colleagues at Pathfinder, they all said "Why do you need to do that?" and "couldn't you find a gem or plugin that does that already?"</p>
<p>Which is a solid point. If you are doing something as common as checking for the difference between two dates you should expect to see either some straight code examples of the best way to do it, or a plugin or gem that solves that problem. I'll need to dig into this a little further, but for the moment I simply updated the code to:</p>
<pre class="ruby">  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">difference_in_dates</span><span style="color:#006600; font-weight:bold;">&#40;</span>time1, time2, unit = <span style="color:#006666;">1</span>.<span style="color:#9900CC;">day</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#0000FF; font-weight:bold;">nil</span> <span style="color:#9966CC; font-weight:bold;">if</span> time1.<span style="color:#0000FF; font-weight:bold;">nil</span>? || time2.<span style="color:#0000FF; font-weight:bold;">nil</span>? || unit == <span style="color:#006666;">0</span>
    <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span> time1 - time2<span style="color:#006600; font-weight:bold;">&#41;</span>  / unit<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">round</span>.<span style="color:#9900CC;">abs</span>
  <span style="color:#9966CC; font-weight:bold;">end</span></pre>
<p>and I looked through the places I was using this code and made sure I only passed in a Time object, so now I've 'fixed' the bug so that the tests don't fail for anyone else, and I've bought myself some time to figure out what's the best course of action.</p>
<p>But I'm still curious why DateTime.now behaves differently depending on OS? What's going on there?<br />
I jumped on to our build server (CentOs) and ran DateTime.now, and see no timezone, and that's why the tests don't fail there.<br />
I jumped over to my heroku server and saw that DateTime.now includes a timezone.</p>
<p>Wondering what the os was I ran:</p>
<pre>`uname -sr`.chomp.strip
"Linux 2.6.18-xenU-ec2-v1.0"
&gt;&gt; `cat /etc/issue.net`
=&gt; "Debian GNU/Linux 4.0"</pre>
<p>So what dictates the Date and Time setup? Is it purely an OS thing, or is it just a component of how time is setup on the server?</p>
<p>I jumped over to another Debian box, and there DateTime.now doesn't include the timezone, so now I'm thinking that its not as simple as just the OS, but something else.  (please someone, enlighten me!)</p>
<p><strong>Conclusion</strong>: Don't be an idiot<br />
I did a few things wrong here, and I deserve to be flamed for it:</p>
<ol>
<li>Read the docs, understand the code you are relying on. In most cases, ruby and rails just does what you'd expect, but its still worth reading into, even when things seem to be working just fine.</li>
<li>If the problem you are trying to solve seems common, google around, ask others what they have done, dig into the framework, etc. Assume you aren't the first to run into it.</li>
<li>If it seems that what you are doing isn't common, or isn't handled in the frameworks/libraries you are using, perhaps it means you are looking at the problem the wrong way and there is another, simpler solution out there.</li>
<li>Test your assumptions. I will say that at least I had tests that covered my assumptions, and failed when they weren't true. I may not have written the best solution, but at least it worked on every system we deployed it to, and never failed in production</li>
</ol>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/09/rails-datetimetotime-time-case-why-that/">Rails DateTime.to_time, Time, and a case of &#8216;Why do you need to do that?&#8217;</a></p>


<p>Related posts:<ol><li><a href='http://www.pathf.com/blogs/2008/08/ruby-on-rails-with-windows-how-i-made-it-work/' rel='bookmark' title='Permanent Link: Ruby on Rails with Windows &#8211; How I made it work'>Ruby on Rails with Windows &#8211; How I made it work</a></li><li><a href='http://www.pathf.com/blogs/2009/09/edge-case-city-requirements-testing-dates-hr-business-logic/' rel='bookmark' title='Permanent Link: edge case city: requirements and testing dates for HR business logic'>edge case city: requirements and testing dates for HR business logic</a></li><li><a href='http://www.pathf.com/blogs/2009/03/rails-test-prescriptions-is-now-on-sale/' rel='bookmark' title='Permanent Link: Rails Test Prescriptions is now on sale'>Rails Test Prescriptions is now on sale</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2009/09/rails-datetimetotime-time-case-why-that/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Corners of the Rubyverse: RVM and MacRuby</title>
		<link>http://www.pathf.com/blogs/2009/09/corners-of-the-rubyverse-rvm-and-macruby/</link>
		<comments>http://www.pathf.com/blogs/2009/09/corners-of-the-rubyverse-rvm-and-macruby/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 16:59:18 +0000</pubDate>
		<dc:creator>Noel Rappin</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Software Development Best Practices]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=4047</guid>
		<description><![CDATA[
Please continue reading after the next sentence.
I installed Snow Leopard a couple of weeks ago.
Wait -- don't stop reading. This isn't a post about how to install MySQL or a post about whether or not Snow Leopard is the Greatest Thing Ever. There are plenty of other places on the Internet where you can get [...]<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/09/corners-of-the-rubyverse-rvm-and-macruby/">Corners of the Rubyverse: RVM and MacRuby</a></p>



Related posts:<ol><li><a href='http://www.pathf.com/blogs/2009/03/keeping-up-with-the-joneses-keeping-rails-and-its-extensions-up-to-date/' rel='bookmark' title='Permanent Link: Keeping Up With The Joneses: Keeping Rails and its extensions up to date'>Keeping Up With The Joneses: Keeping Rails and its extensions up to date</a></li><li><a href='http://www.pathf.com/blogs/2009/08/rails-development-on-windows-native-or-virtualize/' rel='bookmark' title='Permanent Link: Rails Development on Windows: Native or Virtualize'>Rails Development on Windows: Native or Virtualize</a></li><li><a href='http://www.pathf.com/blogs/2008/11/installing-edge-ferretacts_as_ferret/' rel='bookmark' title='Permanent Link: Installing Edge Ferret/acts_as_ferret'>Installing Edge Ferret/acts_as_ferret</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.pathf.com/blogs/wp-content/uploads/2009/09/C2418006-9AF1-4724-A2CF-27460658A115.jpg" alt="C2418006-9AF1-4724-A2CF-27460658A115.jpg" border="0" width="300" height="300" class="right"/></p>
<p>Please continue reading after the next sentence.</p>
<p>I installed Snow Leopard a couple of weeks ago.</p>
<p>Wait -- don't stop reading. This isn't a post about how to install MySQL or a post about whether or not Snow Leopard is the Greatest Thing Ever. There are plenty of other places on the Internet where you can get that information.</p>
<p>I wanted to talk about two cool corners of the Ruby universe that I started using as a result of my Snow Leopard installation: MacRuby and RVM<span id="more-4047"></span><br />
<h3>RVM: Ruby Version Manager</h3>
<p>One of the Ruby changes in Snow Leopard was an upgrade of the system Ruby version to 1.8.7. All fine, except that one of the projects I work on is on an older version of Rails that is not compatible. Clearly, I needed to get an 1.8.6 Ruby on my machine, ideally without messing up the system installation that other applications are using.</p>
<p>Enter <a href="http://rvm.beginrescueend.com" rel="nofollow" >Ruby Version Manager</a> (RVM), a handy command line tool for installing and managing multiple Ruby interpreters on your system. In theory, usage is as simple as this:</p>
<pre style="white-space: pre !important;">
$ gem install rvm
$ rvm-install
</pre>
<p>At this point RVM asks you to make a slight change to your shell files. Then just this:</p>
<pre style="white-space: pre !important;">
$ rvm use 1.8.6
</pre>
<p>"But you didn't have 1.8.6", I hear you cry. True. RVM will go out, download, compile, and install Ruby 1.8.6 to my local machine without interfering with anything else on the system (it installs in ~/.rvm). You can install Ruby 1.8.x, Ruby 1.9.x, Ruby Enterprise, JRuby, Rubinius, and (I think) MacRuby.</p>
<p>(Okay -- that's the ideal. In practice, it took a little bit of system tweaks and command line tweaks. <a href="http://afreshcup.com/2009/09/02/migrating-to-snow-leopard-for-rails-development-a-definitive-guide/" rel="nofollow" >Mike Gunderloy's Snow Leopard guide</a> was helpful here. Although I've been able to get all the main Ruby versions to install, I'm still struggling some of the more esoteric version. Once installation is done, the command line interface is really good and things just work.)</p>
<p>Now, the Ruby in my shell is the new 1.8.6. But any other running terminal shells are unaffected -- especially helpful if you are working on multiple projects. Each Ruby maintains its own Gem listing, although there's work ongoing to make it easy to share gems.</p>
<p>To get back to the system Ruby, just</p>
<pre style="white-space: pre !important;">
rvm use system
</pre>
<p>You can also specify any Ruby version as the default.</p>
<p>This is outstandingly cool, not just to solve my problem, but also as an easy way to create a harness to test your Ruby program or library against multiple Ruby setups. There are other useful features about setting different versions and managing shells, check it out.</p>
<h3>MacRuby</h3>
<p>Here's the thing. For the last several years I've had this script that communicates with iTunes via AppleScript, and creates a bunch of random playlists according to criteria that is a bit more complex that an iTunes smart playlist. For instance, it can create a playlist made up of two-song blocks by the same artist. Okay, it's wildly overdone, but I like it.</p>
<p>It broke in Snow Leopard. I don't know why. It seems like the Scripting Bridge framework occasionally decides to go out for a cup of coffee, and my script times out.</p>
<p>This seemed like as good a time as any to investigate MacRuby. <a href="http://www.macruby.org" rel="nofollow" >MacRuby</a> is an implementation of Ruby in Mac OS X Objective-C. Unlike a lot of hybrid language/vm tools, MacRuby gives you direct access to the native objects. So, if you ask for a string, you get an object that acts as both a Ruby string and a Cocoa NSString, responding to methods of either. MacRuby uses Ruby 1.9 key/value arguments to translate Objective-C method names. </p>
<pre style="white-space: pre !important;">
[person name];
[person setName:name];
[person setFirstName:first lastName:last];
</pre>
<p>In Ruby (this example is from a tutorial on the MacRuby site)</p>
<pre style="white-space: pre !important;">
person.name
person.setName(name)
person.setFirstName(first, lastName:last)
</pre>
<p>Unlike regular Ruby, the order of the keyword arguments must match the Cocoa method selector.</p>
<p>For most people, this allows writing Cocoa applications in Ruby, including integration with XCode and Interface Builder. </p>
<p>That's extremely useful, and I plan on trying it soon. For my purposes, the point is that it uses the Scripting Bridge directly, and I hoped that would allow it to bypass whatever weirdness was breaking my original script. (The original script was in Python, but I had a 75% functional Ruby version that I never actually built the I/O on, so it was largely a matter of learning the MacRuby way to communicate with iTunes.) Here's a sample, cobbled together from various parts of the script:</p>
<pre style="white-space: pre !important;">
def itunes
  @itunes ||= SBApplication.applicationWithBundleIdentifier(
    "com.apple.itunes")
end

def library
  @library ||= itunes.sources.objectWithName("Library")
end

def all_music
  @all_music ||= library.userPlaylists.objectWithName("Music")
end

all_music.fileTracks.each_with_index do |track, index|
  # stuff here
end

def create_itunes_playlist
  playlist = itunes.classForScriptingClass(
      "playlist").alloc.initWithProperties(
      {'name' => name})
  library.playlists.addObject(playlist)
  playlist
end

#chosen_tracks are my object wrappers around Cocoa
#itunes_track is the actual cocoa object
playlist = create_itunes_playlist
chosen_tracks.each_with_index do |track, index|
  track.itunes_track.duplicateTo(playlist)
end
</pre>
<p>Overall, everything works as advertised (it seems as though MacRuby is better able to deal with whatever happens to cause the Scripting Bridge to take a nap. I'm using the pre-release MacRuby 0.5, so there's the occasional feature glitch (gem installation is a little dicey, for example). But the MacRuby team is actively, even furiously, pushing forward, and this looks like it'll be very useful, very soon.</p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/09/corners-of-the-rubyverse-rvm-and-macruby/">Corners of the Rubyverse: RVM and MacRuby</a></p>


<p>Related posts:<ol><li><a href='http://www.pathf.com/blogs/2009/03/keeping-up-with-the-joneses-keeping-rails-and-its-extensions-up-to-date/' rel='bookmark' title='Permanent Link: Keeping Up With The Joneses: Keeping Rails and its extensions up to date'>Keeping Up With The Joneses: Keeping Rails and its extensions up to date</a></li><li><a href='http://www.pathf.com/blogs/2009/08/rails-development-on-windows-native-or-virtualize/' rel='bookmark' title='Permanent Link: Rails Development on Windows: Native or Virtualize'>Rails Development on Windows: Native or Virtualize</a></li><li><a href='http://www.pathf.com/blogs/2008/11/installing-edge-ferretacts_as_ferret/' rel='bookmark' title='Permanent Link: Installing Edge Ferret/acts_as_ferret'>Installing Edge Ferret/acts_as_ferret</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2009/09/corners-of-the-rubyverse-rvm-and-macruby/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>WindyCityRails: My Presentation Checklist</title>
		<link>http://www.pathf.com/blogs/2009/09/windycityrails-my-presentation-checklist/</link>
		<comments>http://www.pathf.com/blogs/2009/09/windycityrails-my-presentation-checklist/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 16:14:16 +0000</pubDate>
		<dc:creator>Noel Rappin</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Technologies and Platforms]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=4009</guid>
		<description><![CDATA[WindyCityRails 2008
Sometimes I write these just for me.
As I've mentioned a couple of times, tomorrow I'll be speaking at WindyCityRails, and I need a checklist of all things I don't want to forget, and all thing things I want to do to make the talk great.

Preparing the Talk
Figure out what you want to say first. [...]<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/09/windycityrails-my-presentation-checklist/">WindyCityRails: My Presentation Checklist</a></p>



Related posts:<ol><li><a href='http://www.pathf.com/blogs/2007/06/artifacts-of-a/' rel='bookmark' title='Permanent Link: Artifacts of a Presentation'>Artifacts of a Presentation</a></li><li><a href='http://www.pathf.com/blogs/2008/07/1008/' rel='bookmark' title='Permanent Link: Ruby Code Audit Checklist'>Ruby Code Audit Checklist</a></li><li><a href='http://www.pathf.com/blogs/2008/09/windy-city-rails/' rel='bookmark' title='Permanent Link: Windy City Rails'>Windy City Rails</a></li></ol>]]></description>
			<content:encoded><![CDATA[<div class="right"><a href="" rel="nofollow" ><img src="http://farm4.static.flickr.com/3097/2892206860_20c318941b_m.jpg" alt="WindyCityRails 2008" border="0" width="" height="" class="right"/></a><br clear="all"/><span class="right" style="font-size: smaller"><a href="http://www.windycityrails.org/" rel="nofollow" >WindyCityRails 2008</a></span></div>
<p>Sometimes I write these just for me.</p>
<p>As I've mentioned a couple of times, tomorrow I'll be speaking at <a href="http://www.windycityrails.org" rel="nofollow" >WindyCityRails</a>, and I need a checklist of all things I don't want to forget, and all thing things I want to do to make the talk great.<br />
<span id="more-4009"></span><br />
<h3>Preparing the Talk</h3>
<p>Figure out what you want to say first. The outline view in PowerPoint and Keynote is a great way to organize what you want to say without worrying about how it looks.</p>
<p>Determine a small number of things that you think are key items that you want the audience to walk away with. Mention them at the start, summarize them at the end.</p>
<p>The classic advice is not to put too much text on your slides, and avoid reading the text directly. A pragmatic way to manage this is to set your body text font pretty large (I use 44 point fonts for my body text if I can get away with it), and break up any slide that threatens to overrun.</p>
<p>That said, you can make the opposite mistake as well -- I find it tiring to go to a talk where all the slides are two-words and a non-sequitur picture. People may be viewing just your slides online, they need a little bit of context. Even people in the room often need a bit of context on the slides to help follow what you are saying.</p>
<p>Building up the slides during the talk point by point using animation can be a good way to keep from reading too much text on the slides. And it can help time a "punch line" by keeping it from the audience until you are ready. But don't use it everywhere. (I've always wanted to give a talk that used bullet points like Colbert does in The Word segment, as ironic commentary. But that's very hard, and I'm not sure it would work.)</p>
<p>I do like to separate off major sections of the talk with title-only slides. I've started tying these sections together by putting images on the title slide, and carrying those images in the background of the slides in the section at something like 20% opaque. It makes it easier for people in the audience to follow along.</p>
<p>Keep the number of moving parts to a minimum -- rather than switch to an editor to show code, copy the code into your slides. TextMate has a "Copy to RTF" bundle that preserves syntax highlighting, or take a screen shot.</p>
<p>Similarly, try to avoid having to run code during your talk. (Unless the interactivity is the point, as in a longer workshop).</p>
<p>Try not to depend on Internet access for a demo, you never know how flakey the Internet is going to be at a venue. At the very least, have a bunch of screenshots in hand as a plan B. </p>
<p>Practice. Do a dry run by yourself. If you see something wrong in your slides or missing in your talk, write it down. But do try and get a clean dry run at some point, so you get a sense of how long the talk is.</p>
<p>If possible, practice in front of other people. Nearly every talk that somebody at Pathfinder gives has a practice run as a company brown bag. This is invaluable feedback as to what is interesting in your talk and what is not.</p>
<p>In many situations, your last slide will be up for a while while you answer questions or something. Put something useful on there, generally either a summary or places to go for more information.</p>
<h3>Doing the Talk</h3>
<p>Make sure you bring everything you need. Laptop. Power Cord. Monitor Adapter. Remote Control. Don't assume that anything will be as you expect in the actual setup. As I type this I'm going to put my monitor adapter in my backpack. Put a copy of your talk on a thumb drive. Put a copy online using Dropbox or Gmail it to yourself. </p>
<p>If at all possible, scope out the space well before your talk. Where will you stand? Will you be able to see your own slides? Will you need a remote, or will you need to stand in front of your presentation machine?</p>
<p>Try and set up early if you can (if you are part of a conference program, you're limited because there's a previous speaker). Still, the less the audience sees you fumbling with cables the better off you are. It helps if you can check to see if the display resolution matches your slides.</p>
<p>Before the talk, shut down as many programs as you can on your laptop. Especially shut down notifiers -- you don't want an IM from your mom popping up in the middle. </p>
<p>I use a Mac utility called <a href="http://lightheadsw.com/caffeine/" rel="nofollow" >Caffeine</a> to keep my computer from going to sleep in the middle of the talk, because it's annoying when that happens. </p>
<p>The point of all this is to reduce the amount of things that can go wrong so that you can be as relaxed and have fun during the talk.</p>
<p>Getting started can be awkward. Sometimes it helps to get the audience involved by asking a question or two right off the bat -- this can also help you gauge how much the audience already knows about your topic. It can also be an unobtrusive way to make sure that everybody can hear you.</p>
<p>At the end, if there's time, take questions. Get in the habit of repeating the question before you answer it. There's a good chance that most of the audience didn't hear the question. If you are miked and being recorded, the recording probably won't pick up the question unless you repeat it.</p>
<p>Stick around afterword if you can, often there will be one or two more people who have questions.</p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/09/windycityrails-my-presentation-checklist/">WindyCityRails: My Presentation Checklist</a></p>


<p>Related posts:<ol><li><a href='http://www.pathf.com/blogs/2007/06/artifacts-of-a/' rel='bookmark' title='Permanent Link: Artifacts of a Presentation'>Artifacts of a Presentation</a></li><li><a href='http://www.pathf.com/blogs/2008/07/1008/' rel='bookmark' title='Permanent Link: Ruby Code Audit Checklist'>Ruby Code Audit Checklist</a></li><li><a href='http://www.pathf.com/blogs/2008/09/windy-city-rails/' rel='bookmark' title='Permanent Link: Windy City Rails'>Windy City Rails</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2009/09/windycityrails-my-presentation-checklist/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>edge case city: requirements and testing dates for HR business logic</title>
		<link>http://www.pathf.com/blogs/2009/09/edge-case-city-requirements-testing-dates-hr-business-logic/</link>
		<comments>http://www.pathf.com/blogs/2009/09/edge-case-city-requirements-testing-dates-hr-business-logic/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 16:42:25 +0000</pubDate>
		<dc:creator>Jason Sendelbach</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Software Development Best Practices]]></category>
		<category><![CDATA[Agile Development]]></category>
		<category><![CDATA[Application Development]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[Test Driven Development]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=3996</guid>
		<description><![CDATA[edge case city: requirements and testing dates for HR business logic
We have an internal application that does staffing, time entry, and now Paid Time Off (PTO) accrual, scheduling and management.  It is quite nice, as it has replaced three existing systems, and replaced a number of manual, tedious tasks.  I started it last [...]<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/09/edge-case-city-requirements-testing-dates-hr-business-logic/">edge case city: requirements and testing dates for HR business logic</a></p>



Related posts:<ol><li><a href='http://www.pathf.com/blogs/2009/01/the-testing-interviews/' rel='bookmark' title='Permanent Link: The Testing Interviews'>The Testing Interviews</a></li><li><a href='http://www.pathf.com/blogs/2006/04/ajax_and_leaky_/' rel='bookmark' title='Permanent Link: Ajax and Leaky Business Logic'>Ajax and Leaky Business Logic</a></li><li><a href='http://www.pathf.com/blogs/2006/06/the_hazards_of_-3/' rel='bookmark' title='Permanent Link: The Hazards of Exposing Business Logic on the Client'>The Hazards of Exposing Business Logic on the Client</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>edge case city: requirements and testing dates for HR business logic</p>
<p>We have an internal application that does staffing, time entry, and now Paid Time Off (PTO) accrual, scheduling and management.  It is quite nice, as it has replaced three existing systems, and replaced a number of manual, tedious tasks.  I started it last year, as our current system was very inefficient.  It was a simple Ruby on Rails app that I was able to get working in a few weeks.  Over time the functionality grew.</p>
<p>We recently added in PTO accrual and functionality to debit PTO time.  In doing so in a test driven manner was great, as we could put all the edge cases.  What we found was that many of the requirements were plentiful with edge cases.  For instance, we get paid on the 15th or end of the month, unless that is a weekend. Then we get paid on a Friday - Except if that Friday is a holiday, then the previous Thursday - Except - if that is also a holiday.... So it is really the previous non-weekend, non-holiday on or before the 15th  or end of the month.  The same holds true to determine the beginning of the billing period.  If the Monday is the 2nd, than for some operations the effective billing period start is Tuesday the third.... Ugh...</p>
<p>Our initial thoughts were filled with visions of lots of very similar tests for all contexts that do things depending on the start or end of a billing period.  We didn't want to have lots of duplicate test code to test all edge cases, so we decided to extend the Date object to have a few helper methods to do the complicated logic in one place.  We get the full range of the billing period start and end, and then trim off any holidays or weekends.  What this did, was allow us to test the complicated logic in unit tests with a full set of complicated edge cases.  We created many crazy examples of billing periods starting and ending on weekends, holidays, and holidays before and after weekends.  This created a very robust set of methods to be used anywhere in the system.</p>
<p>We then mocked a call to each Date helper method everywhere in the system where it cared about what day it was, and weather it was the start/end of a billing period.  We had only a few edge cases now: is it the true effective billing period start/end, or not.  Our tests could then focus on the guts of what it actually did, regardless of the effective date.</p>
<p>This demonstrates how powerful unit testing is, and how mocking can really keep your tests concise.  It made not only our code cleaner, but our tests cleaner.  It reduced duplicate code, and increased our assurance that the code will function as designed.  </p>
<p>That being said, it still doesn't change the fact that implementing HR logic in any language is a pain in the ass.  I have worked on a couple of systems for accounting departments in the past, and their business requirements are much worse than HR.  Dealing with job codes, general ledger accounts, etc can make your head spin.  All I know, is that without TDD, this system would be buggy.</p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/09/edge-case-city-requirements-testing-dates-hr-business-logic/">edge case city: requirements and testing dates for HR business logic</a></p>


<p>Related posts:<ol><li><a href='http://www.pathf.com/blogs/2009/01/the-testing-interviews/' rel='bookmark' title='Permanent Link: The Testing Interviews'>The Testing Interviews</a></li><li><a href='http://www.pathf.com/blogs/2006/04/ajax_and_leaky_/' rel='bookmark' title='Permanent Link: Ajax and Leaky Business Logic'>Ajax and Leaky Business Logic</a></li><li><a href='http://www.pathf.com/blogs/2006/06/the_hazards_of_-3/' rel='bookmark' title='Permanent Link: The Hazards of Exposing Business Logic on the Client'>The Hazards of Exposing Business Logic on the Client</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2009/09/edge-case-city-requirements-testing-dates-hr-business-logic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ask A Rails Tester Person</title>
		<link>http://www.pathf.com/blogs/2009/09/ask-a-rails-tester-person/</link>
		<comments>http://www.pathf.com/blogs/2009/09/ask-a-rails-tester-person/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 15:39:20 +0000</pubDate>
		<dc:creator>Noel Rappin</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Software Development Best Practices]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[Test Driven Development]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=3945</guid>
		<description><![CDATA[
Ask Mr. Lizard, from Jim Henson's Dinosaurs
It's time to play "Ask A Tester Person", where I answer questions that I've gotten via email or otherwise about Rails Testing topics. 
If you have a question for Ask A Tester Person, send it to railsprescriptions at gmail.com.

Before I continue, I want to mention that Pathfinder's own John [...]<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/09/ask-a-rails-tester-person/">Ask A Rails Tester Person</a></p>



Related posts:<ol><li><a href='http://www.pathf.com/blogs/2009/07/elements-of-testing-style/' rel='bookmark' title='Permanent Link: Elements of Testing Style'>Elements of Testing Style</a></li><li><a href='http://www.pathf.com/blogs/2009/05/rails-testing-frequently-asked-questions-the-non-code-version/' rel='bookmark' title='Permanent Link: Rails Testing Frequently Asked Questions &#8212; The Non-Code Version'>Rails Testing Frequently Asked Questions &#8212; The Non-Code Version</a></li><li><a href='http://www.pathf.com/blogs/2009/03/rails-test-prescriptions-is-now-on-sale/' rel='bookmark' title='Permanent Link: Rails Test Prescriptions is now on sale'>Rails Test Prescriptions is now on sale</a></li></ol>]]></description>
			<content:encoded><![CDATA[<div class="right"><img src="http://www.pathf.com/blogs/wp-content/uploads/2009/09/8B461F0C-C372-4689-A81C-146FD44E5EEB.jpg" alt="Ask Mr. Lizard" border="0" width="" height="" class="right"/><br clear="all"/><br />
<span class="right" style="font-size: smaller">Ask Mr. Lizard, from Jim Henson's Dinosaurs</span></div>
<p>It's time to play "Ask A Tester Person", where I answer questions that I've gotten via email or otherwise about Rails Testing topics. </p>
<p>If you have a question for Ask A Tester Person, send it to railsprescriptions at gmail.com.</p>
<div style="border: thin solid blue; padding: 5px">
Before I continue, I want to mention that Pathfinder's own John McCaffrey and myself will both be presenting at <a href="http://www.windycityrails" rel="nofollow" >WindyCityRails 2009</a>, which is September 12th at the Westin Chicago River North. There are still some seats available for the main conference talks, registration is open until September 10th. So sign up and we'll see you there.
</div>
<p>I've got two questions today:<br />
<span id="more-3945"></span><br />
<h3>Question 1: I'm writing too many tests!</h3>
<blockquote><p>One subject I still have questions<br />
about is how to test authorization in controller tests. In my<br />
applications I've been testing three different user cases for every<br />
controller action, but this leads to, for example:</p>
<pre style="white-space: pre !important;">
test_edit_by_anonymous_user
test_edit_by_unauthorized_user
test_edit_by_authorized_user
</pre>
<p>So every action has at least three tests, which obviously means a<br />
*ton* of tests for the entire application. This has always felt like<br />
overdoing it but I haven't yet been able to convince myself that just<br />
testing the authorization part of the code is sufficient. If I could<br />
isolate the authorization mechanism for testing that might convince<br />
me, but I'm not really able to do that (maybe my authorization process<br />
needs to be redesigned?), and I'm not sure I'd be convinced<br />
anyway...how the application responds in all three cases seems like<br />
something that *should* be tested for every action...
</p></blockquote>
<p>I doubt that your authorization process needs to be redesigned, but then I've never seen your authentication process.</p>
<p>I'd recommend a couple of different things to clean this up a bit. On the assumption that unauthorized access has largely the same behavior across the application, you can create a boilerplate test like this example -- the example uses Shoulda, but the basic idea should work in any framework.</p>
<pre style="white-space: pre !important;">
  self.def should_block_access_for_anonymous_user(*actions)
    actions.each do |action|
      should "block anonymous access for #{action}" do
        logout_current_user
        get action
        assert_redirected_to root_path
      end
    end
	end
</pre>
<p>Which you would then use as:</p>
<pre style="white-space: pre !important;">
  should_block_access_for_anonymous_user :edit, :update, :delete
</pre>
<p>The implementation shown here is probably a little too simplistic for full use (you might need to pass more information than just the action for each request), but the simple version could easily cover the most basic authentication issues with very little fuss.</p>
<p>If your authentication system is more complicated, the other option is nested contexts -- again, this is in Shoulda, but can be adapted to RSpec or the Context gem:</p>
<pre style="white-space: pre !important;">
context "GET edit" do

  setup do
    # generic edit setup here
  end

  context "with an anonymous user" do
    setup do
      logout
      get edit
    end

    should "not allow access" do
      assert_redirected_to root_path
    end
  end

  context "with an admin user" do
    setup do
      login_as_admin
      get edit
    end

    should "allow access" do
      assert_response :success
    end
  end

end
</pre>
<p>The upside of this compared with what you are probably doing is that it consolidate the setup between the different options. The downside is that it can be kind of verbose and hard to follow. But it's still potentially easier than writing three separate tests for each action.</p>
<h3>Question two: I'm creating too many objects!</h3>
<blockquote><p>Okay, I actually can't find the email that this came from, which is driving me crazy, because how do you lose an email message these days? Anyway, the gist was that this person's tests were running very slowly because he or she was creating so many objects for each test -- I distinctly remember the number 50 to 100 being tossed around. So the question was how to avoid creating so many objects?
</p></blockquote>
<p>The bottom line is that there's no way that you should need to create 50 to 100 objects for every TDD test, or even for any TDD test -- it's pretty rare that a unit-level test really needs that much data to work. There are a lot of potential issues here. Three that spring to mind are:</p>
<ul>
<li>You are trying to test too much code at one time. It's possible (though still not very likely) that an integration test might need that many objects, but testing a single method almost never does</li>
<li>You've transitioned from fixtures to factories, but you are still writing your tests as though you were using fixtures.</li>
<li>You have perhaps an unnecessary fixation on providing "realistic" data in unit tests.</li>
</ul>
<p>There's some overlap here. One cause of this is problem is that in fixtureland, there's very little marginal cost to creating new objects, so the tendency is to create fairly large aggregations of objects that cover all possibilities and have that be the universe for all the tests. When you transition to factories, though, keeping that big data blob around is not necessary. Since you can and should be custom-creating the data for each unit test, most model methods only need one model with specific attributes in order to specify the logic. Sometimes that model will need associated objects, but the factory tool can be set to create those automatically.</p>
<p>A special find method or named scope can be tested with as little as two objects -- one to be found and one to be skipped. Sort logic similarly can be tested with two or maybe three objects. If the logic is really complicated, it's better to do multiple tests with small amounts of data than one test with the whole shebang. The idea of a "unit" test is to verify one small piece of logic with as little data as possible, not to check program behavior under realistic data load -- that's what integration tests, performance tests, and actual user acceptance is for. </p>
<p>I feel like I'm answering the question "How do I create fewer objects in my tests?" with "By creating fewer objects in your tests", I hope this answer gives you some tools for minimizing the number of objects you need to create in your tests.</p>
<p>Related Services:  <a href="http://www.pathf.com/services/technology-expertise/ruby-on-rails/" rel="nofollow" >Ruby on Rails Development</a>, <a href="http://www.pathf.com/services" rel="nofollow" >Custom Software Development</a>, <a href="http://www.pathf.com//services/testing-quality-assurance/" rel="nofollow" >Testing and Quality Assurance</a></p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/09/ask-a-rails-tester-person/">Ask A Rails Tester Person</a></p>


<p>Related posts:<ol><li><a href='http://www.pathf.com/blogs/2009/07/elements-of-testing-style/' rel='bookmark' title='Permanent Link: Elements of Testing Style'>Elements of Testing Style</a></li><li><a href='http://www.pathf.com/blogs/2009/05/rails-testing-frequently-asked-questions-the-non-code-version/' rel='bookmark' title='Permanent Link: Rails Testing Frequently Asked Questions &#8212; The Non-Code Version'>Rails Testing Frequently Asked Questions &#8212; The Non-Code Version</a></li><li><a href='http://www.pathf.com/blogs/2009/03/rails-test-prescriptions-is-now-on-sale/' rel='bookmark' title='Permanent Link: Rails Test Prescriptions is now on sale'>Rails Test Prescriptions is now on sale</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2009/09/ask-a-rails-tester-person/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>acts_without_database: Now a Rails Plugin</title>
		<link>http://www.pathf.com/blogs/2009/09/actswithoutdatabase-rails-plugin/</link>
		<comments>http://www.pathf.com/blogs/2009/09/actswithoutdatabase-rails-plugin/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 16:49:08 +0000</pubDate>
		<dc:creator>Anthony Caliendo</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Software Development Best Practices]]></category>
		<category><![CDATA[Technologies and Platforms]]></category>
		<category><![CDATA[Web Application Development]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=3886</guid>
		<description><![CDATA[
Quite a while ago, I wrote a blog post which included some code which allowed you to use ActiveRecord without needing a database table.
I recently needed that functionality again, so I converted that code into a plugin and put it on github so that I could easily include it in another project.  While doing [...]<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/09/actswithoutdatabase-rails-plugin/">acts_without_database: Now a Rails Plugin</a></p>



Related posts:<ol><li><a href='http://www.pathf.com/blogs/2008/09/tankengine-new-plugin-for-rails-iphone-development/' rel='bookmark' title='Permanent Link: TankEngine: New plugin for Rails iPhone Development'>TankEngine: New plugin for Rails iPhone Development</a></li><li><a href='http://www.pathf.com/blogs/2008/12/acts_without_database-using-activerecord-for-non-database-backed-objects/' rel='bookmark' title='Permanent Link: acts_without_database: Leverage ActiveRecord with Non-Database Backed Objects'>acts_without_database: Leverage ActiveRecord with Non-Database Backed Objects</a></li><li><a href='http://www.pathf.com/blogs/2008/05/rails-developme/' rel='bookmark' title='Permanent Link: Rails Development for iPhone with rails_iui'>Rails Development for iPhone with rails_iui</a></li></ol>]]></description>
			<content:encoded><![CDATA[<div class="right"><img src="http://www.pathf.com/blogs/wp-content/uploads/2008/08/rails.png" alt="Ruby on Rails" title="Ruby on Rails" width="50" height="64" class="alignnone size-full wp-image-1100" /></div>
<p>Quite a while ago, I wrote a <a href="http://www.pathf.com/blogs/2008/12/acts_without_database-using-activerecord-for-non-database-backed-objects/">blog post</a> which included some code which allowed you to use ActiveRecord without needing a database table.</p>
<p>I recently needed that functionality again, so I converted that code into a plugin and put it on github so that I could easily include it in another project.  While doing this, I also cleaned up and simplified the code quite a bit.</p>
<p>The github page is here: <a href="http://github.com/AnthonyCaliendo/acts_without_database/" rel="nofollow" >http://github.com/AnthonyCaliendo/acts_without_database/</a></p>
<p>Related Services:  <a href="http://www.pathf.com/services/technology-expertise/ruby-on-rails/" rel="nofollow" >Ruby on Rails Development</a><br />
, <a href="http://www.pathf.com/services" rel="nofollow" >Custom Software Development</a></p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/09/actswithoutdatabase-rails-plugin/">acts_without_database: Now a Rails Plugin</a></p>


<p>Related posts:<ol><li><a href='http://www.pathf.com/blogs/2008/09/tankengine-new-plugin-for-rails-iphone-development/' rel='bookmark' title='Permanent Link: TankEngine: New plugin for Rails iPhone Development'>TankEngine: New plugin for Rails iPhone Development</a></li><li><a href='http://www.pathf.com/blogs/2008/12/acts_without_database-using-activerecord-for-non-database-backed-objects/' rel='bookmark' title='Permanent Link: acts_without_database: Leverage ActiveRecord with Non-Database Backed Objects'>acts_without_database: Leverage ActiveRecord with Non-Database Backed Objects</a></li><li><a href='http://www.pathf.com/blogs/2008/05/rails-developme/' rel='bookmark' title='Permanent Link: Rails Development for iPhone with rails_iui'>Rails Development for iPhone with rails_iui</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2009/09/actswithoutdatabase-rails-plugin/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Chiphone Meeting: Chicago iPhone user group gets its TDD on</title>
		<link>http://www.pathf.com/blogs/2009/08/chiphone-meeting-chicago-iphone-user-group-tdd/</link>
		<comments>http://www.pathf.com/blogs/2009/08/chiphone-meeting-chicago-iphone-user-group-tdd/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 16:25:30 +0000</pubDate>
		<dc:creator>John McCaffrey</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Software Development Best Practices]]></category>
		<category><![CDATA[iPhone/Mobile]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[Confluence]]></category>
		<category><![CDATA[Dojo]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mock]]></category>
		<category><![CDATA[ocmock]]></category>
		<category><![CDATA[pairing]]></category>
		<category><![CDATA[Pathfinder General]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[randori]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=3816</guid>
		<description><![CDATA[
Eric Smith from 8th light gave a hands-on TDD presentation at last night's Chiphone meeting, hosted at Obtiva's downtown office, (conveniently located near the the train).
There was a good crowd of people, most attendees have 'played around' with iphone development, 4 have actively developed apps (3 people have live apps in the store).  From my quick [...]<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/08/chiphone-meeting-chicago-iphone-user-group-tdd/">Chiphone Meeting: Chicago iPhone user group gets its TDD on</a></p>



Related posts:<ol><li><a href='http://www.pathf.com/blogs/2009/06/chicagoruby-meeting-test-prescriptions-recap/' rel='bookmark' title='Permanent Link: ChicagoRuby meeting &#8216;Test Prescriptions&#8217; recap'>ChicagoRuby meeting &#8216;Test Prescriptions&#8217; recap</a></li><li><a href='http://www.pathf.com/blogs/2009/01/book-review-core-animation-for-mac-os-x-and-the-iphone/' rel='bookmark' title='Permanent Link: Book Review: Core Animation for Mac OS X and the iPhone'>Book Review: Core Animation for Mac OS X and the iPhone</a></li><li><a href='http://www.pathf.com/blogs/2009/01/chicago-javascript-meetup-group-draws-a-big-audience-with-varied-skill-levels/' rel='bookmark' title='Permanent Link: Chicago JavaScript Meetup Group draws a big audience with varied skill levels'>Chicago JavaScript Meetup Group draws a big audience with varied skill levels</a></li></ol>]]></description>
			<content:encoded><![CDATA[<div class="right"><a href="http://www.pathf.com/blogs/wp-content/uploads/2009/08/chiphone.png"><img class="alignright size-full wp-image-3823" title="chiphone" src="http://www.pathf.com/blogs/wp-content/uploads/2009/08/chiphone.png" alt="chiphone" width="250" height="434" /></a></div>
<p>Eric Smith from <a href="http://blog.8thlight.com" rel="nofollow"  target="_blank">8th light</a> gave a hands-on TDD presentation at last night's <a href="http://chiphonegroup.org/" rel="nofollow"  target="_blank">Chiphone</a> meeting, hosted at Obtiva's downtown office, (conveniently located near the the train).</p>
<p>There was a good crowd of people, most attendees have 'played around' with iphone development, 4 have actively developed apps (3 people have live apps in the store).  From my quick survey of those that have submitted apps, it seems most of them were free utility apps or simple games, with at least one commercial app <a href="http://www.3boxed.com/dashconfluence/Dash_for_Confluence.html" rel="nofollow"  target="_blank">Dash for Confluence</a>. It also seemed that no one had yet needed to do any animation beyond the basics, with just a bit of core-animation, but no need for more lower-level openGL or animation engines.</p>
<p>Eric started off by saying that he's given talks on iPhone testing, but that just telling people what to do is not the same as letting them experience it for themselves,  so we did a <a href="http://codingdojo.org/cgi-bin/wiki.pl?RandoriKata" rel="nofollow"  target="_blank">Randori</a>, where a pair starts working on some code, and every 3 minutes one person from the pair swaps out and chooses his replacement from the crowd.</p>
<p>What I liked about this was that I felt like I got to know the audience better, and actually watch people reason their way through the code or a testing/mocking issue.  (You know how sometimes you go to a user group, and it can be hard to get a chance to talk to others, or sometimes there is a 'know-it-all' guy, and you just want him to shut up. Knowing that you are going to have to go up there and code is a great way to silence those types)</p>
<p>When it was my turn,  there was an interesting issue with one of the tests that had us all stumped for a bit, but ultimately ended up being one of those problems where you need to deconstruct everything and build it back up. (The issue was that while we were trying to set fooController.textView.text = @"foobar", we hadn't instantiated a textView object, or set it on the controller yet.)<br />
 <span id="more-3816"></span><br />
We got into some testing, mocking strategies, and a few Xcode tips &amp; tricks, but not being all that familiar with the mocking framework, it would have been nice to just do a little intro on the api, but whenever someone was stumped the answer was shouted out pretty quickly.</p>
<p>It was nice to get some pizza, so a big thanks to <a href="http://www.obtiva.com/" rel="nofollow"  target="_blank">Obtiva</a> &amp; <a href="http://blog.8thlight.com" rel="nofollow"  target="_blank">8thlight</a> for putting this together. I wish we could do some presentations here at <a href="http://www.pathf.com/" rel="nofollow"  target="_blank">Pathfinder</a>, but our space is better for a meet &amp; greet, than a presentation. (plus I don't think as many people would come to the River North area)</p>
<p>I was new to a Randori, and I think this style of presentation is good, but I do have a few ideas I think I'll include when I host one:</p>
<ol>
<li> Set out a basic agenda, introducing the approach, the codebase, relevant api, and where we're hoping to end up</li>
<li> Moderate the work (and the crowd), and be ready to help out in case the pair gets stuck (which means you really have to keep an eye on what they are doing)</li>
<li> Make the work meaninful, and the outcome tangible. (we were able to see our posts getting pushed to twitter, which was nice)</li>
<li> Push the final code up to github as a branch, so they can check it out later and compare the original to what they created as a group</li>
</ol>
<p>There were a few times when I couldn't quite hear what the pair was saying, or read the screen that well, and though it wasn't a large group there were a few side conversations that made it harder for me to follow. I think this was most likely to happen when the pair was struggling, so a little moderation would probably keep things moving along fast enough to keep everyone engaged. I saw another post that also laid out some strategies for <a href="http://www.notesfromatooluser.com/2008/10/tdd-randori-session.html" rel="nofollow"  target="_blank">how to best host a Randori session</a>.</p>
<p>I'm looking forward to the next chiphone meeting, and I think there was some talk of doing a group project to make a little app for next month's <a href="http://WindyCityRails.org" rel="nofollow"  target="_blank">WindyCityRails.org</a> conference.</p>
<p>Related Services:  <a href="http://www.pathf.com/services/iphone-application-development/" rel="nofollow" >iPhone Application Development</a>,<br />
<a href="http://www.pathf.com/services/technology-expertise/ruby-on-rails/" rel="nofollow" >Ruby on Rails Development</a>, <a href="http://www.pathf.com/services" rel="nofollow" >Custom Software Development</a></p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/08/chiphone-meeting-chicago-iphone-user-group-tdd/">Chiphone Meeting: Chicago iPhone user group gets its TDD on</a></p>


<p>Related posts:<ol><li><a href='http://www.pathf.com/blogs/2009/06/chicagoruby-meeting-test-prescriptions-recap/' rel='bookmark' title='Permanent Link: ChicagoRuby meeting &#8216;Test Prescriptions&#8217; recap'>ChicagoRuby meeting &#8216;Test Prescriptions&#8217; recap</a></li><li><a href='http://www.pathf.com/blogs/2009/01/book-review-core-animation-for-mac-os-x-and-the-iphone/' rel='bookmark' title='Permanent Link: Book Review: Core Animation for Mac OS X and the iPhone'>Book Review: Core Animation for Mac OS X and the iPhone</a></li><li><a href='http://www.pathf.com/blogs/2009/01/chicago-javascript-meetup-group-draws-a-big-audience-with-varied-skill-levels/' rel='bookmark' title='Permanent Link: Chicago JavaScript Meetup Group draws a big audience with varied skill levels'>Chicago JavaScript Meetup Group draws a big audience with varied skill levels</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2009/08/chiphone-meeting-chicago-iphone-user-group-tdd/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Bridging the Gap Between Rails Developers and HTML Designers</title>
		<link>http://www.pathf.com/blogs/2009/08/bridging-the-gap-between-rails-developers-and-html-designers/</link>
		<comments>http://www.pathf.com/blogs/2009/08/bridging-the-gap-between-rails-developers-and-html-designers/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 15:56:23 +0000</pubDate>
		<dc:creator>Noel Rappin</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Software Development Best Practices]]></category>
		<category><![CDATA[User Experience Design]]></category>
		<category><![CDATA[uxd]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=3817</guid>
		<description><![CDATA[<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/08/bridging-the-gap-between-rails-developers-and-html-designers/">Bridging the Gap Between Rails Developers and HTML Designers</a></p>



Related posts:<ol><li><a href='http://www.pathf.com/blogs/2008/07/a-new-workflow-for-web-designers/' rel='bookmark' title='Permanent Link: A New Workflow for Web Designers'>A New Workflow for Web Designers</a></li><li><a href='http://www.pathf.com/blogs/2008/05/down-with-html/' rel='bookmark' title='Permanent Link: Down with HTML + Code Markup!'>Down with HTML + Code Markup!</a></li><li><a href='http://www.pathf.com/blogs/2006/04/designers_on_jo/' rel='bookmark' title='Permanent Link: Designers on Joel'>Designers on Joel</a></li></ol>]]></description>
			<content:encoded><![CDATA[<div class="right"><img src="http://www.pathf.com/blogs/wp-content/uploads/2009/08/5E22427E-BAAE-41A1-B7A8-B1FF4D55753E.jpg" alt="5E22427E-BAAE-41A1-B7A8-B1FF4D55753E.jpg alt="Mind The Gap" border="0" width="" height="" class="right"/><br clear="all"/>
</div>
<p>To make a cheap joke and paraphrase a common quote, web developers and web designers are two groups separated by common languages. In our case, the languages are HTML and CSS, which are the output of both the web design process and the web development process. Developers and designers produce their HTML/CSS in different ways and with different goals. Here are some ideas for bridging the gap so that the developers and designers on your team can work together smoothly.</p>
<p>Designers and developers obviously have different goals for their HTML -- developers have issues of reducing duplication, organization, and performance that are largely not the designer's concerns. The designer is primarily concerned with how the HTML looks and behaves to the user.</p>
<p><span id="more-3817"></span>By the way, I'm absolutely not trying to make this some kind of left brain/right brain thing. It's more of a software needs vs. domain expertise thing. Once upon a time, I was writing scripts that outputted router configuration files, and I had exactly the same issues with the router domain experts -- my software engineering desire to structure the code without duplication conflicted with the way the router experts liked to structure their hand-written configuration instructions.</p>
<p>Our teams have had success with getting everybody on the team using common tools as much as possible. This means putting designs and code in the same code repository, and it means the development team supports the designers in creating a set up to run the current development version of the app locally. (By the way, <a href="http://www.viget.com/inspire/git-a-designers-perspective/" rel="nofollow" >this article by Mindy Wagner</a> might be helpful if you are trying to convert everybody to Git.)</p>
<p>From the developer perspective, if you are working with HTML provided by designers, it's important to keep the view layer of your code accessible to the HTML providers. Exactly what this means is subject to negotiation. Left to my own devices, I'd be putting all kinds of HTML generation in Ruby via helpers or something more esoteric. That didn't work out well when the designer needed to go mucking about in metaprogrammed Ruby code to start changing CSS classes. We do better with putting pure logical stuff in helpers and using partials to split view logic. I'm pretty sure that if I were to suggest Haml for a project, the designers would veto it -- Haml barely meshes with the way I think of HTML, the designers I've shown it to have basically recoiled in horror.</p>
<p>That said, everybody likes <a href="http//lesscss.org" rel="nofollow" >Less CSS</a>, which seems to augment CSS in ways that seem very intuitive to CSS designers, and which are very satisfying to coders. It does all the things that you would expect CSS to do if it was a real language, but vanilla CSS works just fine. It really caught on quickly here.</p>
<p>From the designer perspective, get everything out of photoshop and into HTML/CSS as early as possible. It's just too easy to put stuff into a photoshop image that represents hours of development work, leaving the developers in the position of trying to determine which parts of the impossible image are vital, and which are just chrome. Doing the wireframes in HTML/CSS keeps the design honest.</p>
<p>We use <a href="http://www.pathf.com/blogs/2008/08/integrating-design-drafts-into-your-rails-app/">this little hack</a> to integrate wireframes into the development app, which is really nice for developers when working with in-progress designs. </p>
<p>Ultimately what it comes down to is for everybody in the team to take some responsibility for making the team work together. The developers need to make the code base accessible to designers and to be alert to basic design issues and flexible in adapting wireframes into the site. Designers need to help place their deliverables in a format that keeps the developer from having to guess how things are supposed to work -- nobody wants that. </p>
<p>Related Services:  <a href="http://www.pathf.com/services/technology-expertise/ruby-on-rails/" rel="nofollow" >Ruby on Rails Development</a>, <a href="http://www.pathf.com/services/user-experience-design/" rel="nofollow" >User Experience Design</a>, <a href="http://www.pathf.com/services/technology-expertise/ajax-and-rich-internet-applications/" rel="nofollow" >Ajax Rich Internet Applications</a></p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/08/bridging-the-gap-between-rails-developers-and-html-designers/">Bridging the Gap Between Rails Developers and HTML Designers</a></p>


<p>Related posts:<ol><li><a href='http://www.pathf.com/blogs/2008/07/a-new-workflow-for-web-designers/' rel='bookmark' title='Permanent Link: A New Workflow for Web Designers'>A New Workflow for Web Designers</a></li><li><a href='http://www.pathf.com/blogs/2008/05/down-with-html/' rel='bookmark' title='Permanent Link: Down with HTML + Code Markup!'>Down with HTML + Code Markup!</a></li><li><a href='http://www.pathf.com/blogs/2006/04/designers_on_jo/' rel='bookmark' title='Permanent Link: Designers on Joel'>Designers on Joel</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2009/08/bridging-the-gap-between-rails-developers-and-html-designers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Mocha for ActiveRecord Partial Mocks with Finders</title>
		<link>http://www.pathf.com/blogs/2009/08/using-mocha-for-activerecord-partial-mocks-with-finders/</link>
		<comments>http://www.pathf.com/blogs/2009/08/using-mocha-for-activerecord-partial-mocks-with-finders/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 16:37:58 +0000</pubDate>
		<dc:creator>Anthony Caliendo</dc:creator>
				<category><![CDATA[Custom Application Development]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Software Development Best Practices]]></category>
		<category><![CDATA[Technologies and Platforms]]></category>
		<category><![CDATA[Web Application Development]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[Mocha]]></category>
		<category><![CDATA[Mock]]></category>
		<category><![CDATA[mocking]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=3756</guid>
		<description><![CDATA[



Mocha on sparklette.net


Mocha is the mocking library used by the Rails team, so it has understandably gained some traction among Rails developers.  I have started using it over flexmock lately, but ran into some problems with partial mocks on ActiveRecord objects.  The problem stemmed from the fact that ActiveRecord instantiates new records when [...]<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/08/using-mocha-for-activerecord-partial-mocks-with-finders/">Using Mocha for ActiveRecord Partial Mocks with Finders</a></p>



Related posts:<ol><li><a href='http://www.pathf.com/blogs/2008/06/how-to-use-will_paginate-with-non-activerecord-collectionarray/' rel='bookmark' title='Permanent Link: How to use will_paginate with non-ActiveRecord collection/array'>How to use will_paginate with non-ActiveRecord collection/array</a></li><li><a href='http://www.pathf.com/blogs/2009/03/activerecord-tests-modify-activerecord-logging-without-tripping-rollback-convenience/' rel='bookmark' title='Permanent Link: activerecord tests: modify activerecord logging without tripping rollback convenience'>activerecord tests: modify activerecord logging without tripping rollback convenience</a></li><li><a href='http://www.pathf.com/blogs/2008/05/using-activerecord-and-metaprogramming-to-define-constants-for-enumerated-types/' rel='bookmark' title='Permanent Link: Using ActiveRecord and Metaprogramming to Define Constants for Enumerated Types'>Using ActiveRecord and Metaprogramming to Define Constants for Enumerated Types</a></li></ol>]]></description>
			<content:encoded><![CDATA[<div class="right">
<img src="http://www.pathf.com/blogs/wp-content/uploads/2009/08/mocha.jpg" alt="mocha" title="mocha" width="225" height="168" class="right" /><br />
<br clear="all"/><br />
<span class="right" style="font-size: smaller"><br />
<a href="http://sparklette.net/archives/529/mocha.jpg" rel="nofollow" >Mocha on sparklette.net</a><br />
</span>
</div>
<p><a href="http://github.com/floehopper/mocha/tree/master" rel="nofollow" >Mocha</a> is the mocking library used by the Rails team, so it has understandably gained some traction among Rails developers.  I have started using it over <a href="http://github.com/jimweirich/flexmock/tree/master" rel="nofollow" >flexmock</a> lately, but ran into some problems with partial mocks on ActiveRecord objects.  The problem stemmed from the fact that ActiveRecord instantiates new records when returning records from finders, which meant that creating partial mocks for a particular record was difficult.</p>
<p>I created a helper method to make this easier, and so far it has cleaned up a bit of my tests.<br />
<span id="more-3756"></span></p>
<p>Using <a href="http://mocha.rubyforge.org/classes/Mocha/ClassMethods.html#M000001" rel="nofollow" >#<code>any_instance</code></a> is not helpful in the cases I ran into, since I wanted to target a specific record for different expectations.</p>
<p>You could mock out the individual #<code>find</code> or #<code>find_by_*</code> methods as needed in each test, but that didn't seem ideal to me.  Instead, I dug a bit into ActiveRecord to find what method was called when it actually instantiated the records after a find.  I discovered that there is an #<code>instantiate</code> method which takes a hash of column=>value pairs from the finder to instantiate those records.</p>
<p>The following is the helper method which I created to do this:</p>
<pre class="ruby">&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> mock_active_records<span style="color:#006600; font-weight:bold;">&#40;</span>*records<span style="color:#006600; font-weight:bold;">&#41;</span>
    records.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> |record|
      record.<span style="color:#9966CC; font-weight:bold;">class</span>.<span style="color:#9900CC;">stubs</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:instantiate</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">with</span><span style="color:#006600; font-weight:bold;">&#40;</span>
        has_entry<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'id'</span>, record.<span style="color:#9900CC;">id</span>.<span style="color:#9900CC;">to_s</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">returns</span><span style="color:#006600; font-weight:bold;">&#40;</span>record<span style="color:#006600; font-weight:bold;">&#41;</span>
      record.<span style="color:#9900CC;">stubs</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:reload</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">returns</span><span style="color:#006600; font-weight:bold;">&#40;</span>record<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>
&nbsp;</pre>
<p>Here is an example test:</p>
<pre class="ruby">&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'test_helper'</span>
<span style="color:#9966CC; font-weight:bold;">class</span> UserTest &lt; <span style="color:#6666ff; font-weight:bold;">ActiveSupport::TestCase</span>
  setup <span style="color:#9966CC; font-weight:bold;">do</span>
    <span style="color:#0066ff; font-weight:bold;">@user</span> = User.<span style="color:#9900CC;">create</span>!
    <span style="color:#0066ff; font-weight:bold;">@non_pending_order</span> = user.<span style="color:#9900CC;">orders</span>.<span style="color:#9900CC;">create</span>!
    <span style="color:#0066ff; font-weight:bold;">@pending_order</span> = user.<span style="color:#9900CC;">orders</span>.<span style="color:#9900CC;">create</span>! <span style="color:#ff3333; font-weight:bold;">:pending</span> =&gt; <span style="color:#0000FF; font-weight:bold;">true</span>
    mock_active_records <span style="color:#0066ff; font-weight:bold;">@non_pending_order</span>, <span style="color:#0066ff; font-weight:bold;">@pending_order</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  test <span style="color:#996600;">'cancels pending orders when deactivating user'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    <span style="color:#0066ff; font-weight:bold;">@non_pending_order</span>.<span style="color:#9900CC;">expects</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:cancel</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">never</span>
    <span style="color:#0066ff; font-weight:bold;">@pending_order</span>.<span style="color:#9900CC;">expects</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:cancel</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">once</span>
&nbsp;
    <span style="color:#0066ff; font-weight:bold;">@user</span>.<span style="color:#9900CC;">deactivate</span>!
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;</pre>
<p>This test makes sure that when I deactivate a user, that I call the cancel method on only the pending order. </p>
<p>Now, you may be asking "why don't I just test the side effects of cancel on the orders?"  Well, I feel that what happens during cancel for an order is outside the scope of a unit test for user.  In this example, cancel can have a multitude of side effects.  In the context of a unit test for a user, I don't care what happens when I cancel an order.  I only care that I do cancel it.<br />
Also, if cancel needed to make an outbound call to another system, I wouldn't want an external system to be a dependency of my unit test.  Mocking out the method removes any external and implementation dependencies in my unit tests (a functional test is a different matter, mind you).</p>
<p>Related Services:  <a href="http://www.pathf.com/services/technology-expertise/ruby-on-rails/" rel="nofollow" >Ruby on Rails Development</a>, <a href="http://www.pathf.com/services" rel="nofollow" >Custom Software Development</a></p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/08/using-mocha-for-activerecord-partial-mocks-with-finders/">Using Mocha for ActiveRecord Partial Mocks with Finders</a></p>


<p>Related posts:<ol><li><a href='http://www.pathf.com/blogs/2008/06/how-to-use-will_paginate-with-non-activerecord-collectionarray/' rel='bookmark' title='Permanent Link: How to use will_paginate with non-ActiveRecord collection/array'>How to use will_paginate with non-ActiveRecord collection/array</a></li><li><a href='http://www.pathf.com/blogs/2009/03/activerecord-tests-modify-activerecord-logging-without-tripping-rollback-convenience/' rel='bookmark' title='Permanent Link: activerecord tests: modify activerecord logging without tripping rollback convenience'>activerecord tests: modify activerecord logging without tripping rollback convenience</a></li><li><a href='http://www.pathf.com/blogs/2008/05/using-activerecord-and-metaprogramming-to-define-constants-for-enumerated-types/' rel='bookmark' title='Permanent Link: Using ActiveRecord and Metaprogramming to Define Constants for Enumerated Types'>Using ActiveRecord and Metaprogramming to Define Constants for Enumerated Types</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2009/08/using-mocha-for-activerecord-partial-mocks-with-finders/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Rails Testing First Look: Blue Ridge</title>
		<link>http://www.pathf.com/blogs/2009/08/rails-testing-first-look-blue-ridge/</link>
		<comments>http://www.pathf.com/blogs/2009/08/rails-testing-first-look-blue-ridge/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 16:26:46 +0000</pubDate>
		<dc:creator>Noel Rappin</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Software Development Best Practices]]></category>
		<category><![CDATA[rails testing]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=3591</guid>
		<description><![CDATA[
Blue Ridge Mountains by eleda 1
So, I tried Blue Ridge for the first time yesterday and I thought I'd write down some quick impressions. Hence, Rails Testing First Look.
Disclaimer: We came into this tool so cold our toes froze. We fumbled, we made mistakes, we probably missed really great ways of doing things. I look [...]<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/08/rails-testing-first-look-blue-ridge/">Rails Testing First Look: Blue Ridge</a></p>



Related posts:<ol><li><a href='http://www.pathf.com/blogs/2009/05/rails-testing-frequently-asked-questions-the-non-code-version/' rel='bookmark' title='Permanent Link: Rails Testing Frequently Asked Questions &#8212; The Non-Code Version'>Rails Testing Frequently Asked Questions &#8212; The Non-Code Version</a></li><li><a href='http://www.pathf.com/blogs/2009/03/rails-test-prescriptions-is-now-on-sale/' rel='bookmark' title='Permanent Link: Rails Test Prescriptions is now on sale'>Rails Test Prescriptions is now on sale</a></li><li><a href='http://www.pathf.com/blogs/2009/01/getting-started-with-rails-testing-guide-now-available/' rel='bookmark' title='Permanent Link: Getting Started With Rails Testing Guide Now Available'>Getting Started With Rails Testing Guide Now Available</a></li></ol>]]></description>
			<content:encoded><![CDATA[<div class="right">
<a href="http://farm3.static.flickr.com/2009/1713780788_6ef00e9f1d_m.jpg" rel="nofollow" ><img src="http://farm3.static.flickr.com/2009/1713780788_6ef00e9f1d_m.jpg" alt="" border="0" width="" height="" class="right"/></a><br clear="all"/><span class="right" style="font-size: smaller"><a href="http://farm3.static.flickr.com/2009/1713780788_6ef00e9f1d_m.jpg" rel="nofollow" >Blue Ridge Mountains by eleda 1</a></span></div>
<p>So, I tried <a href="http://github.com/relevance/blue-ridge/tree/master" rel="nofollow" >Blue Ridge</a> for the first time yesterday and I thought I'd write down some quick impressions. Hence, Rails Testing First Look.</p>
<p>Disclaimer: We came into this tool so cold our toes froze. We fumbled, we made mistakes, we probably missed really great ways of doing things. I look forward to being enlightened.</p>
<p>Let's do this question-and-answer style: <span id="more-3591"></span><strong>What is Blue Ridge?</strong> Glad you asked. It's an framework for testing JavaScript from inside a Rails application. For the most part, it's a cohesive bundle of existing JavaScript test tools, such as <a href="http://github.com/nkallen/screw-unit/tree/master" rel="nofollow" >Screw.Unit</a>. The value-add of Blue Ridge is an easy installation and nice integration with Rails testing tasks.</p>
<p><strong>Why did we start using it?</strong> We had some simple JavaScript stuff to do, and thought it would be a good time to start out with what looks like a solid way to test.</p>
<p><strong>Is it easy to install?</strong> Very. Install as a plugin <code>./script/plugin install git://github.com/relevance/blue-ridge.git</code>, then generate the Blue Ridge files with <code>script/generate blue_ridge</code>. </p>
<p>Blue Ridge will install a <code>test/javascript</code> directory. In that directory will be a sample test file <code>application_spec.js</code>, a helper file, and a fixture directory. Each javascript test file is assumed to have a matching HTML file in the fixture directory which is loaded to provide a sample DOM for test purposes.</p>
<p><strong>Does it make any other assumptions?</strong> BlueRidge assumes you are using jQuery as your library. It's theoretically possible to use Prototype, but we ran into continual difficulties (possibly because we were doing it wrong), and actually wound up switching to jQuery for the project, easy enough to do since we just started.</p>
<p><strong>How do you write tests?</strong> Tests are written using Screw.Unit syntax, and if you are familiar with RSpec, the syntax will look pretty similar. Here's the final draft of the first couple of tests we wrote, for a search box with default text that goes away when focused. The TextMate Screw.Unit bundle was very helpful, but other than that, the tests are pretty straightforward.</p>
<pre style="white-space: pre !important;">
Screw.Unit(function() {
  describe("With my search box and default", function() {
    it("should switch the default", function() {
      search_focus($('#unified_search'));
      expect($('#unified_search').attr('value')).to(equal, '');
    });

    it("should switch a non-default", function() {
      $('#unified_search').addClass('search_entry');
      search_blur($('#unified_search'));
      expect($('#unified_search').attr('value')).to(equal, default_text);
    });

    it("should not switch if there is a value", function() {
      $('#unified_search').attr('value', 'Fred');
      search_blur($('#unified_search'));
      expect($('#unified_search').attr('value')).to(equal, 'Fred');
    });

  });
});
</pre>
<p><strong>How do you run tests?</strong> Two ways. Blue Ridge provides a <code>test:javascripts</code> Rake task that will run all your Javascript tests in the terminal, this is also suitable for including in your continuous integration build, for example. A very nice feature from Screw.Unit is the ability to run tests in browser by simply opening the fixture HTML file in the browser of your choice. As long as your choice isn't Safari, which isn't supported at the moment. The ability to run the tests in console and in browser is very useful.</p>
<p><strong>Any gotchas?</strong> Oy. We had what appeared to be some minor differences between the Rhino implementation that powers the console tests and the browser tests, leading to tests passing in the browser and failing in the console. We weren't quite able to do what amounted to integration tests -- we tried to trigger the JavaScript events so that the jQuery functions tested above were triggered, but couldn't get that to work. You have to be careful that the fixture HTML file actually has all the DOM elements you need, and remember that fixing the actual view doesn't change the fixture. Screw.Unit's error messages on failure aren't as helpful as they might be, there also seemed to be a thing where the fixture DOM wasn't actually being reset between tests, but I'm not 100% sure about that, we wound up working around it.</p>
<p><strong>And in the end?</strong> That said, I did feel better about my JavaScript after having tested it. Fixing the JavaScript code, it was nice to see that other functions hadn't broken. There's a lot to like here, and I'm hoping to get past my initial problems to a tool that will improve the JavaScript parts of my code.</p>
<p>Related Services:  <a href="http://www.pathf.com/services/technology-expertise/ruby-on-rails/" rel="nofollow" >Ruby on Rails Development</a>, <a href="http://www.pathf.com/services" rel="nofollow" >Custom Software Development</a></p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/08/rails-testing-first-look-blue-ridge/">Rails Testing First Look: Blue Ridge</a></p>


<p>Related posts:<ol><li><a href='http://www.pathf.com/blogs/2009/05/rails-testing-frequently-asked-questions-the-non-code-version/' rel='bookmark' title='Permanent Link: Rails Testing Frequently Asked Questions &#8212; The Non-Code Version'>Rails Testing Frequently Asked Questions &#8212; The Non-Code Version</a></li><li><a href='http://www.pathf.com/blogs/2009/03/rails-test-prescriptions-is-now-on-sale/' rel='bookmark' title='Permanent Link: Rails Test Prescriptions is now on sale'>Rails Test Prescriptions is now on sale</a></li><li><a href='http://www.pathf.com/blogs/2009/01/getting-started-with-rails-testing-guide-now-available/' rel='bookmark' title='Permanent Link: Getting Started With Rails Testing Guide Now Available'>Getting Started With Rails Testing Guide Now Available</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2009/08/rails-testing-first-look-blue-ridge/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Rails Test Prescriptions to be Published by Pragmatic</title>
		<link>http://www.pathf.com/blogs/2009/08/rails-test-prescriptions-published-pragmatic/</link>
		<comments>http://www.pathf.com/blogs/2009/08/rails-test-prescriptions-published-pragmatic/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 21:33:15 +0000</pubDate>
		<dc:creator>Bernhard Kappe</dc:creator>
				<category><![CDATA[Pathfinder General]]></category>
		<category><![CDATA[Pathfinder News]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[rails testing]]></category>
		<category><![CDATA[Test]]></category>
		<category><![CDATA[Test Driven Development]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=3550</guid>
		<description><![CDATA[
Rails Test Prescriptions, the eBook put out by Noel Rappin, Director of Rails Development at Pathfinder, has been picked up by Pragmatic.  
Congratulations to Noel - he's done a great job of furthering testing best practices in rails, and this is a great reward.   As he said "I’m very excited by this. [...]<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/08/rails-test-prescriptions-published-pragmatic/">Rails Test Prescriptions to be Published by Pragmatic</a></p>



Related posts:<ol><li><a href='http://www.pathf.com/blogs/2009/07/more-kudos-for-rails-prescriptions/' rel='bookmark' title='Permanent Link: More Kudos for Rails Prescriptions'>More Kudos for Rails Prescriptions</a></li><li><a href='http://www.pathf.com/blogs/2009/03/rails-test-prescriptions-is-now-on-sale/' rel='bookmark' title='Permanent Link: Rails Test Prescriptions is now on sale'>Rails Test Prescriptions is now on sale</a></li><li><a href='http://www.pathf.com/blogs/2008/12/announcing-rails-prescriptions/' rel='bookmark' title='Permanent Link: Announcing Rails Prescriptions'>Announcing Rails Prescriptions</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p><img class="right" src="http://www.pathf.com/blogs/wp-content/uploads/2009/08/pragmatic.png" alt="Pragmatic Programmers" width="290" /></p>
<p>Rails Test Prescriptions, the eBook put out by Noel Rappin, Director of <a href="http://www.pathf.com/services/technology-expertise/ruby-on-rails/" rel="nofollow" >Rails Development</a> at Pathfinder, has been <a href="http://blog.railsprescriptions.com/2009/08/18/rails-test-prescriptions-to-be-published-by-pragmatic" rel="nofollow" >picked up by Pragmatic</a>.  </p>
<p>Congratulations to Noel - he's done a great job of furthering testing best practices in rails, and this is a great reward.   As he said "I’m very excited by this. I’ve wanted to work with Pragmatic for as long as they’ve been publishing books, and I’m thrilled that this particular project will be able to get wider distribution and access to Pragmatic’s editorial expertise and skill."</p>
<p>     * The current free <a href="http://www.railsprescriptions.com/pdf/getting_started.pdf" rel="nofollow" >“Getting Started with Rails Testing”</a> ebook will continue to be available. If, at some time in the future, there’s a better Getting Started tutorial in the Pragmatic book, it may be offered as a replacement.</p>
<p>    * The update site for current Rails Test Prescription owners will continue to be available for the foreseeable future.</p>
<p>    * There will be one more official update to the current Rails Test Prescriptions, probably around the end of August. This will wrap up the chapter or two I’m working on, and tie up some other loose ends.</p>
<p>    * After that, errata and information about changes to test tools will most likely be handled via this blog and an errata page on the rails test prescriptions site.</p>
<p>This is Noel's 4th book with a major publisher, following <a href="http://www.pathf.com/ideas/books/professional-ruby-on-rails/" rel="nofollow" >Professional Ruby on Rails</a>, wxPython in Action and Jython Essentials.  We're happy for Noel and happy to have him at Pathfinder.  </p>
<p>Related Services:  <a href="http://www.pathf.com/services/technology-expertise/ruby-on-rails/" rel="nofollow" >Ruby on Rails Development</a>, <a href="http://www.pathf.com/services" rel="nofollow" >Custom Software Development</a> </p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/08/rails-test-prescriptions-published-pragmatic/">Rails Test Prescriptions to be Published by Pragmatic</a></p>


<p>Related posts:<ol><li><a href='http://www.pathf.com/blogs/2009/07/more-kudos-for-rails-prescriptions/' rel='bookmark' title='Permanent Link: More Kudos for Rails Prescriptions'>More Kudos for Rails Prescriptions</a></li><li><a href='http://www.pathf.com/blogs/2009/03/rails-test-prescriptions-is-now-on-sale/' rel='bookmark' title='Permanent Link: Rails Test Prescriptions is now on sale'>Rails Test Prescriptions is now on sale</a></li><li><a href='http://www.pathf.com/blogs/2008/12/announcing-rails-prescriptions/' rel='bookmark' title='Permanent Link: Announcing Rails Prescriptions'>Announcing Rails Prescriptions</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2009/08/rails-test-prescriptions-published-pragmatic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Development on Windows: Native or Virtualize</title>
		<link>http://www.pathf.com/blogs/2009/08/rails-development-on-windows-native-or-virtualize/</link>
		<comments>http://www.pathf.com/blogs/2009/08/rails-development-on-windows-native-or-virtualize/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 15:03:13 +0000</pubDate>
		<dc:creator>Justin Ficke</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Software Development Best Practices]]></category>
		<category><![CDATA[Web Application Development]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[windows development]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=3471</guid>
		<description><![CDATA[
I have come to the conclusion that doing rails development native in windows is not worth the cost. Things may seem to run smooth initially, but over time problems inevitably come up, and they have become enough of a pain point that i'm moving to a linux virtualization. This for me makes particular sense as [...]<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/08/rails-development-on-windows-native-or-virtualize/">Rails Development on Windows: Native or Virtualize</a></p>



Related posts:<ol><li><a href='http://www.pathf.com/blogs/2008/08/ruby-on-rails-with-windows-how-i-made-it-work/' rel='bookmark' title='Permanent Link: Ruby on Rails with Windows &#8211; How I made it work'>Ruby on Rails with Windows &#8211; How I made it work</a></li><li><a href='http://www.pathf.com/blogs/2008/09/tankengine-new-plugin-for-rails-iphone-development/' rel='bookmark' title='Permanent Link: TankEngine: New plugin for Rails iPhone Development'>TankEngine: New plugin for Rails iPhone Development</a></li><li><a href='http://www.pathf.com/blogs/2008/05/rails-developme/' rel='bookmark' title='Permanent Link: Rails Development for iPhone with rails_iui'>Rails Development for iPhone with rails_iui</a></li></ol>]]></description>
			<content:encoded><![CDATA[<div class="right"><img src="http://www.pathf.com/blogs/wp-content/uploads/2009/08/Vmware_fusion.png" alt="Vmware_fusion" title="Vmware_fusion" width="265" height="265" class="alignright size-full wp-image-4001" /></a></div>
<p>I have come to the conclusion that doing rails development native in windows is not worth the cost. Things may seem to run smooth initially, but over time problems inevitably come up, and they have become enough of a pain point that i'm moving to a linux virtualization. This for me makes particular sense as most of the full time ruby guys in my shop are using macs and are no help when it comes to figuring out windows only issues.</p>
<p>The first lesson usually learned by rails developers using windows is to use cygwin.  I didn't initially, until i need to use capistrano for deployment, and guess what, windows doesn't support ssh from the command line, so time for a second rails installation using cygwin for this support. In general, dealing with any type of issue is more frustrating when using windows because most help on the web is not windows focused. A common disclaimer seen when searching boards for help with RoR issues on windows is, "Well, I'm not that familiar with installing xxx on Windows, but" . It's just going to be much easier to install, say gems for instance, if you can build them in the environment for which they were developed.  In fact, awkward native gem compatibility it probably the single biggest reason not to stay on windows.</p>
<p>Then there are issues that don't have to do with trying to fix something that's broken. Performance for one. As seen <a href="http://jamescrisp.org/2009/02/21/linux-virtualbox-vs-windows-for-rails-dev/" rel="nofollow"  target="_blank">here</a>, certain tasks on windows are much slower than if virtualized, even if the virtualization has inferior resources.  Also, developing on windows makes for a poor example when it comes to deployment and dealing with production issues as Rails apps are rarely run on windows.  If you're not used to a linux OS, you're going to be completely useless when it comes to working on these machines.</p>
<p>What it boils down to is that Rails and everything around Rails is targeted towards linux. The web services, heavy use of git, the framework itself.  Sure, becoming familiar with Linux with have its own set of frustrations and headaches, but those will be useful lessons that will bring you closer to Rails and its community, rather than farther away.  So until i get my mac and can virtualize my windows enviroment (um, hello Dietrich),  rails is going virtual.</p>
<p>Related Services:  <a href="http://www.pathf.com/services/technology-expertise/ruby-on-rails/" rel="nofollow" >Ruby on Rails Development</a>, <a href="http://www.pathf.com/services" rel="nofollow" >Custom Software Development</a> </p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/08/rails-development-on-windows-native-or-virtualize/">Rails Development on Windows: Native or Virtualize</a></p>


<p>Related posts:<ol><li><a href='http://www.pathf.com/blogs/2008/08/ruby-on-rails-with-windows-how-i-made-it-work/' rel='bookmark' title='Permanent Link: Ruby on Rails with Windows &#8211; How I made it work'>Ruby on Rails with Windows &#8211; How I made it work</a></li><li><a href='http://www.pathf.com/blogs/2008/09/tankengine-new-plugin-for-rails-iphone-development/' rel='bookmark' title='Permanent Link: TankEngine: New plugin for Rails iPhone Development'>TankEngine: New plugin for Rails iPhone Development</a></li><li><a href='http://www.pathf.com/blogs/2008/05/rails-developme/' rel='bookmark' title='Permanent Link: Rails Development for iPhone with rails_iui'>Rails Development for iPhone with rails_iui</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2009/08/rails-development-on-windows-native-or-virtualize/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Functional Testing Annoyances, Wapcaplet, And You</title>
		<link>http://www.pathf.com/blogs/2009/08/functional-testing-annoyances-wapcaplet-and-you/</link>
		<comments>http://www.pathf.com/blogs/2009/08/functional-testing-annoyances-wapcaplet-and-you/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 21:45:10 +0000</pubDate>
		<dc:creator>Noel Rappin</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Software Development Best Practices]]></category>
		<category><![CDATA[rails testing]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[Test Driven Development]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[wapcaplet]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=3436</guid>
		<description><![CDATA[Here's a minor thing that bugs me all the time.
I'm writing a functional test:

should "do something functional"
  get :search,  rder_id => @order.id, :user_id => @user.id
  # and so on
end

The get call in that test simulates a browser request. Intuitively, you would (well, I would) expect this request to be identical to a [...]<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/08/functional-testing-annoyances-wapcaplet-and-you/">Functional Testing Annoyances, Wapcaplet, And You</a></p>



Related posts:<ol><li><a href='http://www.pathf.com/blogs/2007/09/rails-ajax-rjs/' rel='bookmark' title='Permanent Link: Rails, Ajax, RJS, and Testing'>Rails, Ajax, RJS, and Testing</a></li><li><a href='http://www.pathf.com/blogs/2009/08/rails-testing-first-look-blue-ridge/' rel='bookmark' title='Permanent Link: Rails Testing First Look: Blue Ridge'>Rails Testing First Look: Blue Ridge</a></li><li><a href='http://www.pathf.com/blogs/2009/07/elements-of-testing-style/' rel='bookmark' title='Permanent Link: Elements of Testing Style'>Elements of Testing Style</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Here's a minor thing that bugs me all the time.</p>
<p>I'm writing a functional test:</p>
<pre style="white-space: pre !important;">
should "do something functional"
  get :search, <img src='http://www.pathf.com/blogs/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> rder_id => @order.id, :user_id => @user.id
  # and so on
end
</pre>
<p>The <code>get</code> call in that test simulates a browser request. Intuitively, you would (well, I would) expect this request to be identical to a request coming from the actual view, via a helper like <code>link_to("search", :action => :search, <img src='http://www.pathf.com/blogs/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> rder_id => @order.id, :user_id => @user.id)</code>. At least, you'd expect that parameters hash in the controller to be the same between the </p>
<p>Makes sense, right? The testing call should set up the same environment as the actual call being tested.<span id="more-3436"></span>Well, if you've gotten this far, read the title that said "Annoyances", or have ever read any blogs, you know that isn't how Rails works. Specifically, the actual browser call has all its arguments converted to strings as part of going through the HTTP wire, but Rails, oddly, does not similarly convert the arguments in the test. </p>
<p>Most of the time it makes no difference -- if you pass the string or the integer directly to an ActiveRecord find method, everything works swimmingly. If you do a direct equality check on the parameter, though, you can get code that passes tests, but fails in the browser because the string value is no longer equal to the integer value.</p>
<p>For some time, I've had this on my list of annoyances that I don't have the energy to fix, right next to the slightly misaligned light over my desk, and the fact that they bought the wrong kind of Kleenex at the office that one time.  </p>
<p>This week, <a href="http://pivotallabs.com/users/amilligan/blog/articles/951-wapcaplet" rel="nofollow" >Adam Milligan at Pivotal Labs</a> tried to do something about it. Specifically, he created a Rails patch, then a plugin, that can raise a warning or an error when a non-string argument is passed to an HTTP method in a functional test.</p>
<p>Adam chose to fail or warn rather than silently convert the parameter because he feels that some arguments that might get placed in an HTTP method don't have clear correct conversions (his example is <code>false</code>), and he's trying to avoid setting up a whole different kind of difficult-to-diagnose test to app misalignments. </p>
<p>As much as I love that Adam did this, I kind of think that it's more consistent with Rails design to silently convert, to make the browser call and the test consistent. Still, having the code warn or fail (your choice) is a pretty good way to get into good habits and avoid having to track down weird test errors. So, thanks, Adam. </p>
<p>Related Services:  <a href="http://www.pathf.com/services/technology-expertise/ruby-on-rails/" rel="nofollow" >Ruby on Rails Development</a>, <a href="http://www.pathf.com/services" rel="nofollow" >Custom Software Development</a></p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/08/functional-testing-annoyances-wapcaplet-and-you/">Functional Testing Annoyances, Wapcaplet, And You</a></p>


<p>Related posts:<ol><li><a href='http://www.pathf.com/blogs/2007/09/rails-ajax-rjs/' rel='bookmark' title='Permanent Link: Rails, Ajax, RJS, and Testing'>Rails, Ajax, RJS, and Testing</a></li><li><a href='http://www.pathf.com/blogs/2009/08/rails-testing-first-look-blue-ridge/' rel='bookmark' title='Permanent Link: Rails Testing First Look: Blue Ridge'>Rails Testing First Look: Blue Ridge</a></li><li><a href='http://www.pathf.com/blogs/2009/07/elements-of-testing-style/' rel='bookmark' title='Permanent Link: Elements of Testing Style'>Elements of Testing Style</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2009/08/functional-testing-annoyances-wapcaplet-and-you/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Help, My Test Is Failing!</title>
		<link>http://www.pathf.com/blogs/2009/07/help-my-test-i-failing/</link>
		<comments>http://www.pathf.com/blogs/2009/07/help-my-test-i-failing/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 17:11:58 +0000</pubDate>
		<dc:creator>Noel Rappin</dc:creator>
				<category><![CDATA[Custom Application Development]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Software Development Best Practices]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[Test]]></category>
		<category><![CDATA[Test Driven Development]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=3399</guid>
		<description><![CDATA[Frustration, the game, photo by unlovalblesteve
Dot, dot, dot, dot, dot -- tests are passing, looks like it's time for lunch -- dot, dot, dot, dot, F. F? F? But the code works. I know it does. I think it does. Why is my test failing?
One of the most frustrating times as a TDD developer is [...]<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/07/help-my-test-i-failing/">Help, My Test Is Failing!</a></p>



Related posts:<ol><li><a href='http://www.pathf.com/blogs/2009/03/rails-test-prescriptions-is-now-on-sale/' rel='bookmark' title='Permanent Link: Rails Test Prescriptions is now on sale'>Rails Test Prescriptions is now on sale</a></li><li><a href='http://www.pathf.com/blogs/2008/02/lesser-known-te/' rel='bookmark' title='Permanent Link: Lesser Known Test Processes'>Lesser Known Test Processes</a></li><li><a href='http://www.pathf.com/blogs/2009/02/again-with-the-test-driven-development/' rel='bookmark' title='Permanent Link: Again With The Test Driven Development'>Again With The Test Driven Development</a></li></ol>]]></description>
			<content:encoded><![CDATA[<div class="right"><a href="http://www.flickr.com/photos/unloveable/2398611730/" rel="nofollow" ><img src="http://farm3.static.flickr.com/2371/2398611730_4d027256e0_m_d.jpg" alt="Frustration, the game" border="0" width="" height="" class="right"/></a><br clear="all"/><span class="right" style="font-size: smaller"><a href="http://www.flickr.com/photos/unloveable/2398611730/" rel="nofollow" >Frustration, the game, photo by unlovalblesteve</a></span></div>
<p>Dot, dot, dot, dot, dot -- tests are passing, looks like it's time for lunch -- dot, dot, dot, dot, F. F? F? But the code works. I know it does. I think it does. Why is my test failing?</p>
<p>One of the most frustrating times as a TDD developer is that moment when a test is failing and you don't know why, as opposed to the more normal case where the test fails as expected. Here's a grab bag of tips, tricks, hints, and thoughts to get us all through that difficult time.</p>
<div style="border: thin solid blue; padding: 5px">
	<strong>Self-promotion alert:</strong> More details about Rails testing can be found at <a href="http://www.railsrx.com" rel="nofollow" >Rails Test Prescriptions</a>, there's a free getting started tutorial which contains an extensive section on Cucumber, and a <a href="http://www.lulu.com/content/e-book/rails_test_prescriptions/6418439" rel="nofollow" >nearly 300 pages and counting full book for $9</a>. Thanks. Also, follow <a href="http://www.twitter.com/railsrx" rel="nofollow" >@railsrx</a> on Twitter for testing tips and updates.
</div>
<p><span id="more-3399"></span><br />
<h3>Something Must Have Changed</h3>
<p>This may be the most obvious piece of advice in the history of ever, but I find it's worth repeating, mantra-like, when confronted with a bad bug:</p>
<p>When a formerly-passing test fails, it means something changed.</p>
<p>It may be in the code, or the system, or the test. But it's probably not sunspots, and it's probably not evil spirits possessing your MacBook. (Unless you are either <a href="http://www.amazon.com/gp/product/0441016685?ie=UTF8&tag=10prinhell-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=0441016685" rel="nofollow" >living in a Charles Stross novel</a> or writing Perl, but I digress...) </p>
<p>Looking through recent changes can help figure out what the cause of the failure is. Git's bisect tool can do this automatically, or you can just look through recent changes in your source control viewer of choice. If the test was passing at one time, there's a good chance the answer is in there somewhere.</p>
<p>This is a great argument in favor of committing to your source control very, very frequently (especially when you are using git and can do local commits), so that your changes are very granular.</p>
<h3>Isolate</h3>
<p>When looking at a small number of failing tests, it's helpful to be able to run just those tests. Autotest is outstanding for this, since it will run the failing tests over and over until they pass. This is especially helpful if you have a number of failing tests that are not in the same test class.</p>
<p><a href="http://gist.github.com/101130" rel="nofollow" >This little code and terminal snippet</a> is very helpful for quickly running one class at a time, which is almost like isolating a failing test, or at least close enough to be useful. Depending on your IDE and test framework of choice, you may also be able to run individual tests from the IDE.</p>
<p>Isolating tests makes the tests run faster when you are focused on just a few tests, and also makes any diagnostics you insert easier to interpret.</p>
<p>Two tips that I've stolen from listening to and reading Kent Beck:</p>
<ul>
<li>Back out your entire most recent change since your last passing test and start over. This works best if you work in very small increments, but it gets you out of the "I know I typed something wrong but I just can't see it" nightmare</li>
<li>Replace all the expressions in the method under test with literals -- if that passes, then put the expressions back one by one until you find the culprit.</li>
</ul>
<h3>Diagnose</h3>
<p>I have to say, I'm not a big fan of using stop-and-step debuggers. I've used them when I've been in an IDE, I've never really used the Rails command line debugger, but mostly I've found that not to be a great experience. </p>
<p>Normally, to diagnose what's going on in a test, I usually either add additional assertions in the test or have the code print information to the console. If I diagnose via assertions, generally I'm testing the values of variables in more detail.</p>
<p>For some reason, I see a lot of people using Ruby's <code>puts</code> method to write to the console -- I recommend <code>p</code>, which calls <code>inspect</code> on the object before printing, and generally results in more informative output. As a matter of course, I put <code>require pp</code>, which allows me to use <code>pp</code> to get pretty-printed output, which is nice for nested data structures. Also, <code>y</code> gives a YAML representation of the output -- very readable for ActiveRecord objects.</p>
<pre style="white-space: pre !important;">
>> x = {1 => ['a', 'b'], 2 => 'c'}
>> puts x
1ab2c

>> p x
{1=>["a", "b"], 2=>"c"}

>> pp x
{1=>["a", "b"], 2=>"c"}

>> y x
---
1:
- a
- b
2: c
</pre>
<p>Especially if I have autotest running just the one test, I've been known to bury print statements all over the place -- controllers, Rails itself (often educational). Just remember to take them out when you are done.</p>
<h3>Clear Your Head</h3>
<p>Take a walk. Force your pair to solve the problem. Get a cup of coffee (actually, I hate coffee, get a Diet Coke). Take a nap. All those silly clear your head things really do work sometimes. </p>
<h3>Band Aids</h3>
<p>It's tempting sometimes to comment out the offending test and then your suite passes and all is well with the world again. That's generally a bad idea (although sometimes a major refactoring can genuinely make tests obsolete. </p>
<p>Hope this helps. What do you do to fix stubborn tests?</p>
<p>Related Services:  <a href="http://www.pathf.com/services/technology-expertise/ruby-on-rails/" rel="nofollow" >Ruby on Rails Development</a>, <a href="http://www.pathf.com/services" rel="nofollow" >Custom Software Development</a></p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/07/help-my-test-i-failing/">Help, My Test Is Failing!</a></p>


<p>Related posts:<ol><li><a href='http://www.pathf.com/blogs/2009/03/rails-test-prescriptions-is-now-on-sale/' rel='bookmark' title='Permanent Link: Rails Test Prescriptions is now on sale'>Rails Test Prescriptions is now on sale</a></li><li><a href='http://www.pathf.com/blogs/2008/02/lesser-known-te/' rel='bookmark' title='Permanent Link: Lesser Known Test Processes'>Lesser Known Test Processes</a></li><li><a href='http://www.pathf.com/blogs/2009/02/again-with-the-test-driven-development/' rel='bookmark' title='Permanent Link: Again With The Test Driven Development'>Again With The Test Driven Development</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2009/07/help-my-test-i-failing/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Real Testing Example, Part Two</title>
		<link>http://www.pathf.com/blogs/2009/07/real-testing-example-part-two/</link>
		<comments>http://www.pathf.com/blogs/2009/07/real-testing-example-part-two/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 16:45:19 +0000</pubDate>
		<dc:creator>Noel Rappin</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Software Development Best Practices]]></category>
		<category><![CDATA[Web Application Development]]></category>
		<category><![CDATA[rails development]]></category>
		<category><![CDATA[rails testing]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[Test Driven Development]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=3356</guid>
		<description><![CDATA[Spam Wall, by freezelight
What with upward of two people saying nice things about last week&#8217;s post, I&#8217;ve decided to keep going with part two of a look at some real testing code.
Most code-heavy tutorials show the code but not the tests &#8212; I&#8217;m doing the opposite here, and showing the tests, but not much of [...]<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/07/real-testing-example-part-two/">Real Testing Example, Part Two</a></p>



Related posts:<ol><li><a href='http://www.pathf.com/blogs/2009/07/a-real-testing-example/' rel='bookmark' title='Permanent Link: A Real Testing Example'>A Real Testing Example</a></li><li><a href='http://www.pathf.com/blogs/2009/07/elements-of-testing-style/' rel='bookmark' title='Permanent Link: Elements of Testing Style'>Elements of Testing Style</a></li><li><a href='http://www.pathf.com/blogs/2009/01/the-testing-interviews/' rel='bookmark' title='Permanent Link: The Testing Interviews'>The Testing Interviews</a></li></ol>]]></description>
			<content:encoded><![CDATA[<div class="right"><a href="http://www.flickr.com/photos/63056612@N00/155554663/" rel="nofollow" ><img src="http://farm1.static.flickr.com/59/155554663_89beb0ac63_m.jpg" alt="" border="0" width="" height="" class="right"/></a><br clear="all"/><span class="right" style="font-size: smaller"><a href="http://www.flickr.com/photos/63056612@N00/155554663/" rel="nofollow" >Spam Wall, by freezelight</a></span></div>
<p>What with upward of two people saying nice things about <a href="http://www.pathf.com/blogs/2009/07/a-real-testing-example/">last week&#8217;s post</a>, I&#8217;ve decided to keep going with part two of a look at some real testing code.</p>
<p>Most code-heavy tutorials show the code but not the tests &#8212; I&#8217;m doing the opposite here, and showing the tests, but not much of the code. Also, although I&#8217;m presenting these tests in chunks, you should realize that there was a lot of back-and-forth from Cucumber to tests to code and some backtracking, most of which I&#8217;ll spare you from having to wade through.</p>
<p>At the end of last week, I had run through the tests for spam-prevention code which worked by limiting the rate at which a user could send messages to other users of a particular social networking site. Cucumber was involved, and I think I went off on a tangent about writing lots of tests.</p>
<div style="border: thin solid blue; padding: 5px">
	<strong>Self-promotion alert:</strong> More details about Rails testing can be found at <a href="http://www.railsrx.com" rel="nofollow" >Rails Test Prescriptions</a>, there's a free getting started tutorial which contains an extensive section on Cucumber, and a <a href="http://www.lulu.com/content/e-book/rails_test_prescriptions/6418439" rel="nofollow" >nearly 300 pages and counting full book for $9</a>. Thanks. Also, follow <a href="http://www.twitter.com/railsrx" rel="nofollow" >@railsrx</a> on Twitter for testing tips and updates.
</div>
<p><span id="more-3356"></span>
<p>Once the basic rate limiting code was in place, the client and I came up with a couple of special cases. The application allows a user to explicitly reply to a specific message sent to them. We agreed that these replies should not count towards the rate limit on the grounds that a reply was, pretty much by definition, not spam. Similarly, we decided that any message between users with a friend relationship on the site also doesn&#8217;t count toward the rate limit. More subtly, we decided that if a user was inadvertently blocked, then reinstated by an administrator, that their rate count should drop back to zero, so the user doesn&#8217;t just get immediately re-blocked.</p>
<p>The Cucumber tests:</p>
<pre><code>Scenario: Reply behavior
  Given I am a user who is not a new member
  When I send 4 messages in a day
  And I reply to a message
  And I send 1 message in a day
  Then 6 messages are sent
  And I am not blocked from sending further messages
  And the administrator does not get an email

Scenario: Friend Behavior
  Given I am a user who is not a new member
  When I send 4 messages in a day
  And I send a message to a friend
  And I send 1 message in a day
  Then 6 messages are sent
  And I am not blocked from sending further messages
  And the administrator does not get an email

Scenario: Unblocked behavior
  Given I am a user who is not a new member
  When I send 6 messages in a day
  Then I am blocked from sending further messages
  When I am unblocked by an administrator
  And I send 5 messages in a day
  Then 5 messages are sent
  And I am not blocked from sending further messages
  And the administrator does not get an email
</code></pre>
<p>These tests are quite similar in structure to the tests I started with last week. I might start thinking about combining some of the steps, but in Cucumber, I bias in favor of having the actual test be as clear and readable as I can get it. I don&#8217;t think these scenarios are so complicated that they require simplification.</p>
<p>Most of these steps have already been defined, here are a couple that aren&#8217;t. The first two steps are slight variants on the message sending step definition:</p>
<pre><code>When /^I reply to a message$/ do
  original_message = Factory.create(:message, :sender =&gt; @recipient,
      :recipient =&gt; @sender)
  message = Factory.attributes_for(:message, :sender =&gt; @user)
  message[:in_reply_to] = original_message.id
  visit(messages_path,
      :post, {:recipient =&gt; @recipient.id, :message =&gt; message})
end

When /^I send a message to a friend$/ do
  @user.become_friends_with(@recipient)
  visit(messages_path,
      :post,
      {:recipient =&gt; @recipient.id,
          :message =&gt; Factory.attributes_for(:message, :sender =&gt; @user)})
end
</code></pre>
<p>One thing that you may have noticed about these step definitions. Despite all my jumping up and down about Cucumber being a black-box system, both of these steps bypass the UI to complete the setup. The first step creates a factory message and the second step creates a friend relationship. In both cases, the actual message send being tested passes through the UI.</p>
<p>There are basically two reasons for bypassing the UI in the setup. One is, of course, that it&#8217;s the setup and not the action being tested, the second is that being a purist all the time is a pain, and it&#8217;s much easier to get the background info out of the way directly.</p>
<p>The final missing step, however, is completely through the UI &#8212; the step logs the user out, logs in as an administrator, navigates to the page, unblocks the user, and then logs the administrator out and the original user back in.</p>
<pre><code>When /^I am unblocked by an administrator$/ do
  @blocked = @user
  visit "/logout"
  Given "I am a logged in administrator"
  visit path_to("the admin messaging page")
  click_link("Unblock")
  @user = @blocked
  visit "/logout"
  Given "I am logged in"
  reset_mailer
end
</code></pre>
<p>A little on the Rube Goldberg side, perhaps, but it works.</p>
<p>With the Cucumber step definitions in place, the question becomes what tests and code need to be written to make these pass. For the first two scenarios that adjust the definition of what makes a message count toward the rate limit, the code change will be in the User and Message models. Since it&#8217;s a thin controller that defers to the models for data, there shouldn&#8217;t be any code change in the controller at all. </p>
<p>Now, that&#8217;s a much easier determination to make in hindsight than up front, and as it happens I did write controller tests for both of those scenarios, largely because they were so similar to the controller context chunks in last week&#8217;s post that it only took about five minutes to set them both up. </p>
<p>The real test action was in the user and message models. I added a database column for messages called <code>counts_toward_spam</code>. The idea is that this would be true for most messages, but false for replies, friend messages, or messages otherwise cleared by the admins. This requires some unit tests in the message class to support it. Again, I&#8217;m using Matchy here, and testing the boolean <code>spam_message?</code>, which is basically an alias for <code>counts_toward_spam</code> that I added for readability. In retrospect, adding the method was probably unnecessary.</p>
<pre><code>context "spam count" do

  setup do
    @sender = Factory.create(:user)
    @recipient = Factory.create(:user)
  end

  should "give an ordinary message a spam count" do
    @message = Message.new_from_params(
        {:subject =&gt; "fred", :body =&gt; "body"}, @sender, @recipient)
    @message.sender_id.should == @sender.id
    @message.recipient_id.should == @recipient.id
    @message.should be_spam_message
  end

  should "not give an ordinary message a spam count if it is a reply" do
    @message = @message = Message.new_from_params(
        {:subject =&gt; "fred", :body =&gt; "body", :in_reply_to =&gt; 11},
        @sender, @recipient)
    @message.should be_reply
    @message.should_not be_spam_message
  end

  should "not make a message between mutual friends a spam count" do
    @sender.become_friends_with(@recipient)
    @message = Message.new_from_params(
        {:subject =&gt; "fred", :body =&gt; "body"}, @sender, @recipient)
    @message.should be_friend_message
    @message.should_not be_spam_message
  end
end
</code></pre>
<p>The message tests simply set up the different classes of message and verify that they are classified appropriately, they are pretty straightforward.</p>
<p>I also added a test to user to verify that the spam count was being used appropriately &#8212; this is part of the same context as last week&#8217;s user tests. The user has already sent four messages in the setup.</p>
<pre><code>should "not count a reply message" do
  message = Factory.create(:message, :sender =&gt; @user,
      :created_at =&gt; 10.minutes.ago)
  message.in_reply_to = 3
  message.update_count_toward_spam
  message.save!
  @user.spam_message_count.should == 4
  @user.update_message_block_status.should be_nil
  @user.should be_able_to_send_messages
end
</code></pre>
<p>It&#8217;s interesting what you see when you go back over a chunk of code to explain it to other people. In this case what I notice is the <code>update_count_toward_spam</code> method, which is part of Message that unsets the  <code>count_toward_spam_</code> field if the message is a reply and is automatically called as part of the controller create message code. However, strictly speaking, it should be tested in the message class rather than here (although, the message controller tests would also exercise it).</p>
<p>That&#8217;s the bulk of the testing for those features &#8212; at the time, I didn&#8217;t think there were any other special cases. </p>
<p>The part about unblocking a user requires controller tests, because the unblock action needs to be written in the controller. I&#8217;m making it part of the message controller, although I know that RESTfully speaking it probably should be a separate resource &#8212; the legacy app is such a REST tangle that it&#8217;s not worth it.</p>
<p>The controller test context looks like this &#8212; the setup creates a blocked user and calls the unblock method.</p>
<pre><code>context "GET unblock" do

  setup do
    ActionMailer::Base.deliveries.clear
    @recipient = Factory.create(:user)
    @user = Factory.create(:user,
      :message_sending_status =&gt; User::BLOCKED_STATUS)
    @user.should_not be_able_to_send_messages
    admin!
    get :unblock, :user_id =&gt; @user.id.to_s
    @user.reload
  end

  expect { @user.should be_able_to_send_messages }
  expect { assert_redirected_to :action =&gt; :admin }

  should "send email to unblocked user" do
    assert_sent_email do |email|
      email.to.first == @user.email &amp;&amp;
      email.from.first == "do_not_reply@singlestravelintl.com"
    end
  end
end
</code></pre>
<p>The assertion tests verify that the user can send messages again, and that the user gets an email from the system to that effect. The associated user model test validates that the user&#8217;s spam message count is reset back to zero, which was the specific point of this round of tests (in the actual application, there were other Cucumber scenarios supporting basic administrative behavior).</p>
<pre><code>context "unblocking a user" do

  setup do
    Message.new_from_params(Factory.attributes_for(:message,
        :created_at =&gt; 10.minutes.ago), @user,
         Factory.create(:user)).save!
    @user.update_message_block_status.should == "blocked"
    @user.should_not be_able_to_send_messages
    @user.unblock_message_status
  end

  expect { @user.should be_able_to_send_messages }
  expect { @user.spam_message_count.should == 0 }

  should "reblock" do
    @user.block_message_status
    @user.should_not be_able_to_send_messages
  end

end
</code></pre>
<p>Anyway, the code that I wrote along side these tests to make them pass seemed to work fine, and we deployed to production.</p>
<p>Shortly thereafter, we got a bug report. I haven&#8217;t stressed it here, but new users were limited to a single message in their earliest time on the system. We heard from a new user who sent a message, received a reply, and then replied back to that message, only to find that he was blocked, even though the reply message shouldn&#8217;t count toward the rate limit.</p>
<p>Interesting. It&#8217;s one of those bugs that almost turns philosophical &#8212; exactly when in this process does a user become blocked? In the code that I originally wrote, a user was blocked as soon as he or she hit the rate limit, and before sending another message. In fact, the code should wait until the user tries to send that next message to consider that user blocked, because a user who is at the rate limit border should still be able to send replies and friend messages without being blocked. </p>
<p>So, bug. Since the bug involves multiple interactions, I started in Cucumber:</p>
<pre><code>Scenario: New User Behavior on reply
  Given I am a new user
  When I send 1 message in a day
  And I reply to a message
  Then 2 messages are sent
  And I am not blocked from sending further messages
</code></pre>
<p>All those step definitions exist, but the last two steps fail without further work. I wasn&#8217;t initially sure whether the code change for this would wind up in the controller or not &#8212; as it happened, it turned out to be a minor controller change and minor model change but it took me a few tries to get it right. </p>
<p>Since I already had a decent controller harness for similar scenarios, it took almost no time to adapt to the new condition:</p>
<pre><code>context "with a borderline new user and a reply" do

  setup do
    reply = Factory.create(:message, :recipient =&gt; @user,
        :sender =&gt; Factory.create(:user))
    flexmock(User).should_receive(:new_user?).and_return(true)
    flexmock(Message).should_receive(
        :toward_spam_in_last_24_hours).and_return(1)
    post :create, :recipient =&gt; @recipient.id,
        :message =&gt; Factory.attributes_for(:message, :sender =&gt; @user,
            :in_reply_to =&gt; reply.id.to_s)
    @user.reload
  end

  expect { @user.messages_sent.size.should == 1 }
  expect { @user.spam_message_count.should == 1 }
  expect { assigns(:message).should_not be_new_record }
  expect { @user.should_not be_message_sending_blocked }
  expect { assert_no_email_to_administrator }
end
</code></pre>
<p>I have to say, in retrospect, that I&#8217;m not 100% sold on the use of the mock package here &#8212; it&#8217;s a clear user of mocking to limit the test&#8217;s exposure to the model layer, but I&#8217;m not convinced it makes the test more clear or readable. This setup and tests is very similar to the other bundles of controller test and makes most of the same assertions.</p>
<p>The main change was in the user method, triggered by the following tests &#8212; one of which tests the positive sequence, one the negative &#8212; and yes, the setups probably should have been combined. </p>
<pre><code>should "move a new user to blocked mode after first message" do
  Timecop.freeze(Date.today)
  new_user = Factory.create(:user, :created_at =&gt; 1.day.ago)
  m = Message.new_from_params(Factory.attributes_for(:message),
      new_user, Factory.create(:user))
  m.created_at = 2.hours.ago
  m.save!
  assert_equal(2.hours.ago, new_user.last_message_sent_time)
  assert_equal("blocked", new_user.update_message_block_status(true))
  assert new_user.message_sending_blocked?
end

should "allow a new user a second message that is a reply" do
  Timecop.freeze(Date.today)
  new_user = Factory.create(:user, :created_at =&gt; 1.day.ago)
  m = Message.new_from_params(Factory.attributes_for(:message),
      new_user, Factory.create(:user))
  m.created_at = 2.hours.ago
  m.save!
  assert_equal(2.hours.ago, new_user.last_message_sent_time)
  assert_nil new_user.update_message_block_status(false)
  assert !new_user.message_sending_blocked?
end
</code></pre>
<p>The key here &#8212; which would be easier to see if the setups were combined &#8212; is the next to last line where <code>update_message_block_status</code> is called. That&#8217;s the method called by the controller when a new message is sent, and the <code>false</code> argument means that the new message does not count toward the rate limit. So in the second test, the user can still send messages, while in the first test, the user does move to a blocked status.</p>
<p>Having the existing suite of tests around the controller and model behaviors was a big relief when fixing this bug &#8212; it&#8217;d be easy to make a fix for this issue that affected one of the other scenarios (I know because I made fixes that broke a lot of tests&#8230;). This was a case where the tests clearly made me more confident in the fix that I made. </p>
<p>Related Services:  <a href="http://www.pathf.com/services/technology-expertise/ruby-on-rails/" rel="nofollow" >Ruby on Rails Development</a>, <a href="http://www.pathf.com/services" rel="nofollow" >Full Life Cycle Software Development</a></p>
<p><hr>
<a href="http://www.pathf.com/">Pathfinder Development - creating innovative software that builds business value. </a>
<br/><br/><a href="http://www.pathf.com/blogs/2009/07/real-testing-example-part-two/">Real Testing Example, Part Two</a></p>


<p>Related posts:<ol><li><a href='http://www.pathf.com/blogs/2009/07/a-real-testing-example/' rel='bookmark' title='Permanent Link: A Real Testing Example'>A Real Testing Example</a></li><li><a href='http://www.pathf.com/blogs/2009/07/elements-of-testing-style/' rel='bookmark' title='Permanent Link: Elements of Testing Style'>Elements of Testing Style</a></li><li><a href='http://www.pathf.com/blogs/2009/01/the-testing-interviews/' rel='bookmark' title='Permanent Link: The Testing Interviews'>The Testing Interviews</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pathf.com/blogs/2009/07/real-testing-example-part-two/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 1.320 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-03-19 22:32:31 -->
