title: Test contents of file in rspec from respond_to format.csv
body: <p>I have the following code in my controller that exports a csv file</p>
  
  <pre><code>...
    def export
      @filename = 'users.csv'
      @output_encoding = 'UTF-8'
      @users = User.active_users #not the actual scope but this only returns active
      respond_to do |format|
        format.csv
      end
    end
  ...
  </code></pre>
  
  <p>And I have the following in my spec</p>
  
  <pre><code>it "should only return active users"
    get :export, :format =&gt; :csv
    # i want to check that my mocked users_controller#export is only returning the active users and not the inactive ones  
  end
  </code></pre>
  
  <p><code>response.body</code> is empty in this test when i check it. How would I go about getting the csv file in the spec that is downloaded when this action is hit in a browser so that i can check the result? I've hit a bit of a wall trying to figure this out.</p>
  
  <p>Thanks for any help you can provide.</p>