mock5 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/lib/mock5.rb +8 -10
- data/lib/mock5/version.rb +1 -1
- data/spec/mock5_spec.rb +21 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76be219294f80c132aa6185e6968ada828583e65
|
4
|
+
data.tar.gz: 57a45abc38b9aeda5e26ca5dba4b7bd574ce527f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f03b77ad3a4b76c135eaf5a0b138099350861a8340d59b465d84e869bb07f9fd0925955b1aa98a4a76fdba5ee9937641237972980b5fd7f2d121b8257514b43
|
7
|
+
data.tar.gz: 4b2548315b2f6f24e71a15f8c39f0c3052fe4ade33c26d8d92a80a5088c46f33b78b3e28ff99c320b168d5d554fc16e29a4a2a5cf6fcfe0194f17fbcfdf4577d
|
data/Gemfile
CHANGED
data/lib/mock5.rb
CHANGED
@@ -14,18 +14,16 @@ module Mock5
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def mount(*apis)
|
17
|
-
apis.each do |api|
|
18
|
-
|
19
|
-
|
20
|
-
end
|
17
|
+
(apis.to_set - mounted_apis).each do |api|
|
18
|
+
mounted_apis.add api
|
19
|
+
registry.register_request_stub api.request_stub
|
21
20
|
end
|
22
21
|
end
|
23
22
|
|
24
23
|
def unmount(*apis)
|
25
|
-
apis.each do |api|
|
26
|
-
|
27
|
-
|
28
|
-
end
|
24
|
+
(mounted_apis & apis).each do |api|
|
25
|
+
mounted_apis.delete api
|
26
|
+
registry.remove_request_stub api.request_stub
|
29
27
|
end
|
30
28
|
end
|
31
29
|
|
@@ -34,10 +32,10 @@ module Mock5
|
|
34
32
|
end
|
35
33
|
|
36
34
|
def with_mounted(*apis)
|
37
|
-
mount
|
35
|
+
mounted = mount(*apis)
|
38
36
|
yield
|
39
37
|
ensure
|
40
|
-
unmount *
|
38
|
+
unmount *mounted
|
41
39
|
end
|
42
40
|
|
43
41
|
def unmount_all!
|
data/lib/mock5/version.rb
CHANGED
data/spec/mock5_spec.rb
CHANGED
@@ -43,6 +43,11 @@ describe Mock5 do
|
|
43
43
|
expect(mounted_apis).to include(api)
|
44
44
|
expect(mounted_apis).to include(another_api)
|
45
45
|
end
|
46
|
+
|
47
|
+
it "returns the list of mounted apis" do
|
48
|
+
expect(described_class.mount(api)).to eq([api].to_set)
|
49
|
+
expect(described_class.mount(api, another_api)).to eq([another_api].to_set)
|
50
|
+
end
|
46
51
|
end
|
47
52
|
|
48
53
|
describe ".unmount" do
|
@@ -70,6 +75,11 @@ describe Mock5 do
|
|
70
75
|
described_class.unmount api
|
71
76
|
expect(mounted_apis).to include(another_api)
|
72
77
|
end
|
78
|
+
|
79
|
+
it "returns the list of unmounted apis" do
|
80
|
+
expect(described_class.unmount(another_api)).to be_empty
|
81
|
+
expect(described_class.unmount(api, another_api)).to eq([api].to_set)
|
82
|
+
end
|
73
83
|
end
|
74
84
|
|
75
85
|
describe ".unmount_all!" do
|
@@ -119,6 +129,17 @@ describe Mock5 do
|
|
119
129
|
expect(mounted_apis).to be_empty
|
120
130
|
expect(&action).not_to change(mounted_apis, :empty?)
|
121
131
|
end
|
132
|
+
|
133
|
+
it "doesn't unmount api, that was mounted before" do
|
134
|
+
described_class.mount api
|
135
|
+
|
136
|
+
described_class.with_mounted api, another_api do
|
137
|
+
expect(mounted_apis).to include(another_api)
|
138
|
+
end
|
139
|
+
|
140
|
+
expect(mounted_apis).to include(api)
|
141
|
+
expect(mounted_apis).not_to include(another_api)
|
142
|
+
end
|
122
143
|
end
|
123
144
|
|
124
145
|
describe "stubbing" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mock5
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Pravosud
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: webmock
|