如何在RSpec中模拟此调用? require 'open-uri'
class FileFoo < ActiveRecord::Base
def download image_url
open("tmp/#{file}", 'wb') do |file|
file << open(image_url).read
end
end
end
与开放:URI,我可以做到以下几点: require 'open-uri'
#check status
open('http://google.com').status
#get entire html
open('http://google.com').read
是否有可能得到一个请求的HTTP头这样的事情可以调试,像卷发curl -I http://google.com? $ cu