mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Adding a method to unmock Fog. Addresses issue #594
This commit is contained in:
parent
cb3942d633
commit
eb86ba780b
2 changed files with 64 additions and 0 deletions
|
@ -6,6 +6,10 @@ module Fog
|
|||
@mocking = true
|
||||
end
|
||||
|
||||
def self.unmock!
|
||||
@mocking = false
|
||||
end
|
||||
|
||||
def self.mock?
|
||||
@mocking
|
||||
end
|
||||
|
|
60
tests/core/mocking_tests.rb
Normal file
60
tests/core/mocking_tests.rb
Normal file
|
@ -0,0 +1,60 @@
|
|||
Shindo.tests('Fog mocking', 'core') do
|
||||
before do
|
||||
@fog_was_mocked = Fog.mock?
|
||||
Fog.unmock! if @fog_was_mocked
|
||||
end
|
||||
|
||||
after do
|
||||
Fog.mock! if @fog_was_mocked
|
||||
end
|
||||
|
||||
tests('Fog.mock!') do
|
||||
tests('Fog.mock!').returns(true) do
|
||||
Fog.mock!
|
||||
end
|
||||
|
||||
tests('Fog.mock? without Fog.mock!').returns(false) do
|
||||
Fog.mock?
|
||||
end
|
||||
|
||||
tests('Fog.mock? with Fog.mock!').returns(true) do
|
||||
Fog.mock!
|
||||
Fog.mock?
|
||||
end
|
||||
|
||||
tests('Fog.mocking? without Fog.mock!').returns(false) do
|
||||
Fog.mocking?
|
||||
end
|
||||
|
||||
tests('Fog.mocking? with Fog.mock!').returns(true) do
|
||||
Fog.mock!
|
||||
Fog.mocking?
|
||||
end
|
||||
end
|
||||
|
||||
tests('Fog::Mock.delay') do
|
||||
tests('Fog::Mock.delay').returns(1, "defaults to 1") do
|
||||
Fog::Mock.delay
|
||||
end
|
||||
|
||||
tests('Fog::Mock.delay = 2').returns(2, "changes Fog::Mock.delay to 2") do
|
||||
Fog::Mock.delay = 2
|
||||
Fog::Mock.delay
|
||||
end
|
||||
|
||||
tests('Fog::Mock.delay = 0').returns(0, "changes Fog::Mock.delay to 0") do
|
||||
Fog::Mock.delay = 0
|
||||
Fog::Mock.delay
|
||||
end
|
||||
|
||||
tests('Fog::Mock.delay = -1').raises(ArgumentError) do
|
||||
Fog::Mock.delay = -1
|
||||
end
|
||||
end
|
||||
|
||||
tests('Fog::Mock.not_implemented').raises(Fog::Errors::MockNotImplemented) do
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
|
||||
end
|
Loading…
Reference in a new issue