0
我有一个简单的测试来获取一个Facebook对象。我正在使用Curl来处理请求。录像机没有录制成功的请求盒式磁带,只有在失败的录制
it "gets an object from Facebook" do
VCR.use_cassette('facebook') do
url = "https://graph.facebook.com/<ID>?access_token=#{@access_token}&#{query_string}"
curl = Curl::Easy.perform(url)
expect(curl.body_str).to eql('<my object>')
end
end
我的VCR CONFIGS是:
VCR.configure do |c|
c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
c.hook_into :webmock
end
当我运行测试,它通过和以下记录:
[Cassette: 'facebook'] Initialized with options: {:record=>:once, :match_requests_on=>[:method, :uri], :allow_unused_http_interactions=>true, :serialize_with=>:yaml, :persist_with=>:file_system}
[webmock] Handling request: [get https://graph.facebook.com/<ID>?access_token=<TOKEN>&fields=%5B%22id%22,%22account_id%22,%22name%22,%22campaign_group_status%22,%22objective%22%5D] (disabled: false)
[Cassette: 'facebook'] Initialized HTTPInteractionList with request matchers [:method, :uri] and 0 interaction(s): { }
[webmock] Identified request type (recordable) for [get https://graph.facebook.com/<ID>?access_token=<TOKEN>&fields=%5B%22id%22,%22account_id%22,%22name%22,%22campaign_group_status%22,%22objective%22%5D]
但是磁带没有被记录和DIR是空的。我试过:record => :all
达到相同的结果。
通常,人们在使用不兼容的钩子时遇到此错误,但事实并非如此。我使用webmock和遏制。
奇怪的是,当请求发生故障时,例如令牌已过期,磁带会被记录下来。当它被修复时,我删除了文件,它不会再被记录。
有没有人有同样的问题?
这听起来像是一个webmock(库VCR用来与Curb接口)的bug。当用户使用公共Curb API时,它不应该干扰VCR使用WebMock拦截HTTP调用,但似乎这些回调有这种效果。我鼓励你将这个报告给github上的WebMock问题跟踪器。 – 2014-10-15 00:28:58