<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -15,7 +15,7 @@ class BrainBuster &lt; ActiveRecord::Base
   end
 
   def self.find_random_or_previous(id = nil)
-    id.nil? ? find_random : find_specific_or_fallback
+    id ? find_specific_or_fallback(id) : find_random
   end
 
   def self.random_function
@@ -31,7 +31,7 @@ class BrainBuster &lt; ActiveRecord::Base
     find(:first, :order =&gt; random_function) 
   end
   
-  def self.find_specific_or_fallback
+  def self.find_specific_or_fallback(id)
     find(id)
   rescue ActiveRecord::RecordNotFound
     find_random</diff>
      <filename>lib/brain_buster.rb</filename>
    </modified>
    <modified>
      <diff>@@ -52,6 +52,7 @@ describe &quot;BrainBuster&quot; do
   describe &quot;with real db&quot; do
     include SpecHelper
     before { setup_database }
+    after  { teardown_database }
     
     it &quot;finds random&quot; do
       brain_buster = BrainBuster.create!(:question =&gt; &quot;What is best in life?&quot;, 
@@ -62,9 +63,9 @@ describe &quot;BrainBuster&quot; do
     it &quot;finds specific record by id if provided&quot; do
       brain_buster_1 = BrainBuster.create!(:question =&gt; &quot;What is best in life?&quot;, 
         :answer =&gt; &quot;To crush your enemies, see them driven before you, and to hear the lamentation of the women.&quot;)
-      brain_buster_2 = BrainBuster.create!(:question =&gt; &quot;What is 2+2?&quot;, :answer =&gt; &quot;4&quot;)
+      brain_buster_2 = BrainBuster.create!(:question =&gt; &quot;What is 2+2?&quot;, :answer =&gt; &quot;4&quot;).reload
       
-      BrainBuster.find_random_or_previous(brain_buster_2.id).should == brain_buster_2.reload
+      BrainBuster.find_random_or_previous(brain_buster_2.id).should == brain_buster_2
     end
     
     it &quot;falls back to a different record if a specific brain_buster was delete&quot; do</diff>
      <filename>spec/brain_buster_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -26,6 +26,7 @@ require File.dirname(__FILE__) + '/../init'
 
 module SpecHelper
   LOG_FILE_NAME = File.expand_path(File.join(File.dirname(__FILE__), &quot;tmp&quot;, &quot;test.log&quot;))
+  DATABASE = File.expand_path(File.join(File.dirname(__FILE__), &quot;tmp&quot;, &quot;brain_buster.sqlite3&quot;))
    
   def logger
     @logger ||= Logger.new(LOG_FILE_NAME)
@@ -53,7 +54,7 @@ module SpecHelper
     gem 'sqlite3-ruby'
 
     ActiveRecord::Base.logger = Logger.new(LOG_FILE_NAME)
-    ActiveRecord::Base.establish_connection(:adapter =&gt; 'sqlite3', :database =&gt; '/tmp/brain_buster.sqlite')
+    ActiveRecord::Base.establish_connection(:adapter =&gt; 'sqlite3', :database =&gt; DATABASE)
     ActiveRecord::Migration.verbose = false
 
     ActiveRecord::Schema.define do
@@ -62,7 +63,10 @@ module SpecHelper
         t.column :answer, :string
       end
     end
-    
+  end
+  
+  def teardown_database
+    FileUtils.rm DATABASE
   end
   
 end
\ No newline at end of file</diff>
      <filename>spec/spec_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>497fedf6e9615aca4c265b242db4d5e0918f83d8</id>
    </parent>
  </parents>
  <author>
    <name>Rob Sanheim</name>
    <email>rsanheim@gmail.com</email>
  </author>
  <url>http://github.com/rsanheim/brain_buster/commit/635afdff067a7d0efa2051d7b305c9066f989e30</url>
  <id>635afdff067a7d0efa2051d7b305c9066f989e30</id>
  <committed-date>2009-01-09T11:44:17-08:00</committed-date>
  <authored-date>2009-01-09T11:44:17-08:00</authored-date>
  <message>oops, fix a the find when we have an id...clean up the database while we are at it...</message>
  <tree>1c82eefedcebf3543ec367e5ecef069f4b113398</tree>
  <committer>
    <name>Rob Sanheim</name>
    <email>rsanheim@gmail.com</email>
  </committer>
</commit>
