title: TDD FIRST principle
body: <p>I am not understanding how the <a href="http://agileinaflash.blogspot.de/2009/02/first.html" rel="noreferrer">TDD FIRST principle</a> isn't being adhered to in the following code.</p>
  
  <p>These are my notes about the FIRST principle:</p>
  
  <blockquote>
    <ul>
    <li><strong>Fast</strong>: run (subset of) tests quickly (since you'll be running them all the time)</li>
    <li><strong>Independent</strong>: no tests depend on others, so can run any subset in any order</li>
    <li><strong>Repeatable</strong>: run N times, get same result (to help isolate bugs and enable automation)</li>
    <li><strong>Self-checking</strong>: test can automatically detect if passed (no human checking of output)</li>
    <li><strong>Timely</strong>: written about the same time as code under test (with TDD, written first!)</li>
    </ul>
  </blockquote>
  
  <p>The quiz question:</p>
  
  <blockquote>
    <p>Sally wants her website to have a special layout on the first Tuesday of every month. She has the following controller and test code:</p>
  
  <pre><code># HomeController
   def index
     if Time.now.tuesday?
       render 'special_index'
     else
       render 'index'
     end
   end
  
   # HomeControllerSpec
   it "should render special template on Tuesdays" do
     get 'index'
     if Time.now.tuesday?
       response.should render_template('special_index')
     else
       response.should render_template('index')
     end
   end
  </code></pre>
    
    <p>What FIRST principle is not being followed?</p>
    
    <ol>
    <li>Fast</li>
    <li>Independent</li>
    <li>Repeatable</li>
    <li>Self-checking</li>
    <li>Timely</li>
    </ol>
  </blockquote>
  
  <p>I'm not sure which FIRST principle  is not being adhered to:</p>
  
  <ul>
  <li><strong>Fast</strong>: The code seems to be fast because there is nothing complex about its tests.</li>
  <li><strong>Independent</strong>: The test doesn't depend on other tests.</li>
  <li><strong>Repeatable</strong>: The test will get the same result every time. <code>'special_index'</code> if it's Tuesday and <code>'index'</code> if it's not Tuesday.</li>
  <li><strong>Self-checking</strong>: The test can automatically detect if it's passed.</li>
  <li><strong>Timely</strong>: Both the code and the test code are presented here at the same time.</li>
  </ul>
  
  <p>I chose <strong>Timely</strong> on the quiz because the test code was presented after the controller code. But I got the question wrong, and in retrospect, this wasn't a good choice. I'm not sure which FIRST principle isn't being followed here.</p>