根據我在讀什麼在這裏:https://relishapp.com/vcr/vcr/v/1-11-3/docs/configuration/filter-sensitive-data,過濾用VCR敏感數據後,重新運行規範失敗,壞的URI錯誤
When the interactions are replayed, the sensitive text will replace the substitution string so that the interaction will be identical to what was originally recorded.
我vcr_setup.rb文件看起來像這樣:
require 'vcr'
VCR.config do |c|
c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
c.stub_with :fakeweb
c.default_cassette_options = { :record => :once }
c.filter_sensitive_data("<DOMAIN>") do |interaction|
interaction.request.uri.split(":")[1][2..-1]
end
c.filter_sensitive_data("<PASSWORD>") do |interaction|
interaction.request.uri.split(":")[2].split("@")[0]
end
end
interaction.request.uri看起來像這樣(取代他們的是敏感的信息):
"https://<my_secret_domain>:<my_secret_password>@services.someprovider.com:443/enterprise/composite/some_api_call"
我跑我的RSpec的測試後的第一時間,磁帶正確地顯示這一點:
uri: https://<DOMAIN>:<PASSWORD>@services.someprovider.com:443/enterprise/composite/some_api_call
然而,當我嘗試再次運行測試,我得到這個錯誤:
Failure/Error: VCR.use_cassette("#{provider_name}_mail_dispatcher_points_already_awarded", record: :all) do
URI::InvalidURIError:
bad URI(is not URI?): https://<DOMAIN>:<PASSWORD>@services.someprovider.com:443/enterprise/composite/some_api_call
# ./spec/models/mail_dispatcher_spec.rb:130:in `block (3 levels) in <top (required)>'
這有悖於以上段落來自文檔。我究竟做錯了什麼?
在此先感謝您的幫助。
路易絲