title: Rspec test can not locate method in model file
body: <p>My rspec test vote__spec.rb is stating that my up_votes method is undefined but it is listed within the votes.rb file listed below. Can anyone guide me on why its stating it is undefined?</p>
  
  <p><strong>Rspec error</strong></p>
  
  <pre><code>2) Vote validations value validation only allows -1 or 1 as values
   Failure/Error: expect(@votes.up_votes).where(value: [1,-1])
   NoMethodError:
     undefined method `up_votes' for nil:NilClass
   # ./spec/models/vote_spec.rb:5:in `block (4 levels) in &lt;top    (required)&gt;'
  </code></pre>
  
  <p><strong>Vote Rspec</strong></p>
  
  <pre><code>describe Vote do
   describe "validations" do
    describe "value validation" do
      it "only allows -1 or 1 as values" do
      expect(@post.up_votes).where(value: [1,-1]) 
    end
   end
  end
  end
  </code></pre>
  
  <p><strong>Vote.rb file</strong></p>
  
  <pre><code>class Vote &lt; ActiveRecord::Base
   belongs_to :user
   belongs_to :post
  
    def up_votes
     votes.where(value: 1).count
    end
  
  end
  </code></pre>