我在插入外部api时遇到问题,以下是示例
require 'rspec'
require 'google/apis/storage_v1'
module Google
class Storage
def upload file
puts '#' * 90
puts "File #{file} is uploaded to google cloud"
end
end
end
class UploadWorker
include Sidekiq::Worker
def perform
Google::Storage.new.upload 'test.txt'
end
end
RSpec.describe UploadWorker do
it 'uploads to google cloud' do
google_cloud_instance = double(Google::Storage, insert_object: nil)
expect(google_cloud_instance).to receive(:upload)
worker = UploadWorker.new
worker.perform
end
end
Run Code Online (Sandbox Code Playgroud)
我正在尝试存根Google :: Storage类。此类在被测试的对象内实例化。如何验证此实例上的消息期望?
当我在上面的示例中运行时,我得到以下输出,这似乎合乎逻辑,我的double未被测试对象使用
(Double Google::Storage).upload(*(any args))
expected: 1 time with any arguments
received: 0 times with any arguments
Run Code Online (Sandbox Code Playgroud)
我是Rspec的新手,在此方面遇到困难,我们将不胜感激。
谢谢!
我正在使用Swagger/Swashbuckle 5.6版为我的ASP.Net Web API 2项目生成文档.
默认情况下,可以通过URL http:// localhost:56081/swagger/ui/index访问API文档
但是,我希望它应该在http:// localhost:56081/apihelp /
我搜索了很多,尝试更改SwaggerConfig.cs文件中的设置,但似乎没有任何东西使这个工作.
那么,这甚至可能吗?如果是的话,任何人都可以帮助我吗?