Sha256: c5969a42617b788afccff243942f834904be6d9a664d775a8f6b7ed7600f9404
Contents?: true
Size: 853 Bytes
Versions: 1
Compression:
Stored size: 853 Bytes
Contents
require "mock5/version" require "mock5/api" require "set" module Mock5 extend self def mounted_apis @_mounted_apis ||= Set.new end def mock(*args, &block) Api.new(*args, &block) end def mount(*apis) (apis.to_set - mounted_apis).each do |api| mounted_apis.add api registry.register_request_stub api.request_stub end end def unmount(*apis) (mounted_apis & apis).each do |api| mounted_apis.delete api registry.remove_request_stub api.request_stub end end def mounted?(*apis) apis.to_set.subset?(mounted_apis) end def with_mounted(*apis) mounted = mount(*apis) yield ensure unmount *mounted end def unmount_all! unmount *mounted_apis end alias_method :reset!, :unmount_all! private def registry WebMock::StubRegistry.instance end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mock5-1.0.3 | lib/mock5.rb |