title: RSpec: uninitialized constant ActiveRecord (NameError)
body: <p>When I run <code>rspec</code> from the root of my rails project, I get the following error: </p>
  
  <pre><code>/Users/ysername/code/fsf/app/models/school_application.rb:3:in `&lt;top (required)&gt;': uninitialized constant ActiveRecord (NameError)
  </code></pre>
  
  <p>which is being triggered by the call to <code>require_relative</code> in my <code>spec_helper.rb</code> file</p>
  
  <p>Here is my test: </p>
  
  <pre><code>require 'spec_helper'
  
  describe '#to_xml' do
    it 'returns the xml-ified version of a payment' do
      expect(SchoolApplication.to_xml(XXXXXXXXXXXXXXXX,10, 400, "bob").to eq("&lt;txn&gt;   &lt;ssl_merchant_id&gt;5&lt;/ssl_merchant_id&gt;&lt;ssl_user_id&gt;3&lt;/ssl_user_id&gt;&lt;ssl_test_mode&gt;false&lt;/ssl_test_mode&gt;&lt;ssl_card_number&gt;2443444433334444&lt;/ssl_card_number&gt;&lt;ssl_amount&gt;400&lt;/ssl_amount&gt;&lt;ssl_ssl_cvv2cvc2_indicator&gt;1&lt;/ssl_cvv2cvc2_indicator&gt;&lt;ssl_first_name&gt;'bob'&lt;/ssl_first_name&gt;&lt;/txn&gt;"))
    end
  end
  </code></pre>
  
  <p>Here is my <code>spec_helper.rb</code> file. </p>
  
  <pre><code>require 'rubygems'
  ENV["RAILS_ENV"] ||= 'test'
  require_relative("../app/models/school_application") 
  </code></pre>
  
  <p>FYI when I remove the <code>require_relative</code> statement it no longer knows what <code>SchoolApplication</code> is. 
  Not really sure what is going on here. I have looked at other threads but I am confused about how their solutions/issues coincide with my own (e.g. having another copy of Active_Record in my /lib/ dir???) </p>
  
  <p>Thanks!</p>
  
  <p>Here is the file that is throwing the error, <code>school_application.rb</code></p>
  
  <pre><code>require 'builder'
  
  class SchoolApplication &lt; ActiveRecord::Base
     def self.to_xml(number,expiration,cvv,amount, name)
       xml = ::Builder::XmlMarkup.new
       xml.txn {
         xml.ssl_merchant_id 5
         xml.ssl_user_id 3
         xml.ssl_ssl_pin 1434
         xml.ssl_test_mode false  
         xml.ssl_card_number number
         xml.ssl_amount amount
         xml.ssl_cvv2cvc2_indicator cvv
         xml.ssl_first_name name
       }
       xml
     end
  end
  </code></pre>
  
  <p>P.S. don't worry all of the payment credentials are fabricated. </p>