I have the following code in my controller that exports a csv file
...
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
...
And I have the following in my spec
it "should only return active users"
get :export, :format => :csv
# i want to check that my mocked users_controller#export is only returning the active users and not the inactive ones
end
response.body
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.
Thanks for any help you can provide.