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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da624cffc46d03de23ffd9e33419c6dbe501d44c
4
- data.tar.gz: 5b492f7e62385283c2bd3f81ba215ea648c321f9
3
+ metadata.gz: 76be219294f80c132aa6185e6968ada828583e65
4
+ data.tar.gz: 57a45abc38b9aeda5e26ca5dba4b7bd574ce527f
5
5
  SHA512:
6
- metadata.gz: b901a32c3b8272e1fd29380a7efa3bb24dbebde8370047d7b6434e826db92c8534124e8d06c0cb4a9b16cf4dd3c453d59aa658a838a60ee12b0aa52d1f5d5619
7
- data.tar.gz: b04f2a98b53adaf67262eb5e079c5e61fa247376388e29dc16c731770f14d78f2d43664628a76f0f51c204b7a8a6608d0e6afc9d17b71552be04699a670c0406
6
+ metadata.gz: 9f03b77ad3a4b76c135eaf5a0b138099350861a8340d59b465d84e869bb07f9fd0925955b1aa98a4a76fdba5ee9937641237972980b5fd7f2d121b8257514b43
7
+ data.tar.gz: 4b2548315b2f6f24e71a15f8c39f0c3052fe4ade33c26d8d92a80a5088c46f33b78b3e28ff99c320b168d5d554fc16e29a4a2a5cf6fcfe0194f17fbcfdf4577d
data/Gemfile CHANGED
@@ -6,3 +6,5 @@ gemspec
6
6
  gem "bundler", "~> 1.5"
7
7
  gem "rspec", "~> 2.14"
8
8
  gem "rake", "~> 10.1"
9
+
10
+ gem "pry-debugger"
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
- if mounted_apis.add?(api)
19
- registry.register_request_stub api.request_stub
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
- if mounted_apis.delete?(api)
27
- registry.remove_request_stub api.request_stub
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 *apis
35
+ mounted = mount(*apis)
38
36
  yield
39
37
  ensure
40
- unmount *apis
38
+ unmount *mounted
41
39
  end
42
40
 
43
41
  def unmount_all!
data/lib/mock5/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mock5
2
- VERSION = "1.0.2".freeze
2
+ VERSION = "1.0.3".freeze
3
3
  end
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.2
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-12 00:00:00.000000000 Z
11
+ date: 2014-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: webmock