I have this sinatra app test where I downloaded a file by hand from
the app and stored it in the test area. I then have my test program
download the same file, save it and compare the two.
The test seems to fail because the one downloaded by hand has
newlines of the form
“\r\n” whereas the one that the test program downloads using rack/test
has newlines of the form
“\r\r\n”
Any obvious insights from my test code below ?
Thanks …
require ‘fileutils’
require ‘test/unit’
require ‘rack/test’
class MyAppTest < Test::Unit::TestCase
include Rack::Test::Methods
def app
Sinatra::Application
end
def test_recreate_csv
csv_path = File.dirname(FILE) + ‘/csv_files/web_test_file.csv’
csf = File.open(csv_path,‘w’){|f| f.write(last_response.body)}
downloaded_csv_path = File.dirname(__FILE__) + '/csv_files/
downloaded_file.csv’
assert FileUtils.identical?(csv_path, downloaded_csv_path)
end
end