title: undefined local variable or method `request'
body: <p>I am new to ruby on rails. I am getting an undefined method error when I run rspec on comment_spec.rb</p>
  
  <pre><code>1) after_save calls 'Post#update_rank' after save
       Failure/Error: request.env["HTTP_REFERER"] = '/'
       NameError:
         undefined local variable or method `request' for #&lt;RSpec::ExampleGroups::AfterSave:0x007fa866ead8d0&gt;
       # ./spec/models/vote_spec.rb:45:in `block (2 levels) in &lt;top (required)&gt;'
  </code></pre>
  
  <p>This is my spec:</p>
  
  <pre><code>require 'rails_helper'
  
  describe Vote do
  
      ....
  
      describe 'after_save' do
          it "calls 'Post#update_rank' after save" do
              request.env["HTTP_REFERER"] = '/'
              @user = create(:user)
              @post = create(:post, user: @user)
              sign_in @user
  
              vote = Vote.new(value:1, post: post)
              expect(post). to receive(:update_rank)
                  vote.save
          end
      end
  </code></pre>
  
  <p>Any help that you would have would be greatly appreciated...</p>