receptacle 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -2
- data/.travis.yml +9 -1
- data/CHANGELOG.md +6 -0
- data/README.md +19 -4
- data/lib/receptacle/test_support.rb +13 -2
- data/lib/receptacle/version.rb +1 -1
- data/performance/profile.rb +1 -1
- data/receptacle.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 55b12e62420e5bd820d909846002084c473572d8
|
|
4
|
+
data.tar.gz: 60385bc42c56b0770b22e7703232686fcc6a150f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 24ea362cfb9be687030b24877c04895f5901bb29534ed6a7d86c611d2c41c901fb62d9e56563beed50e098a44726abcfb23b2231c904cb770e14b5c030af1688
|
|
7
|
+
data.tar.gz: 5532b99a99c6d49ca06c4f4e423ff2f9a4b75a092fe1775590a6b812967b0c7d056de0bbae5e0bc7a4270b8c9f1c53c66b10e69506a8eecf846bb88e77cac458
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
language: ruby
|
|
2
2
|
cache: bundler
|
|
3
3
|
rvm:
|
|
4
|
+
- 2.1.10
|
|
5
|
+
- 2.2.6
|
|
4
6
|
- 2.3.3
|
|
5
7
|
- 2.4.0
|
|
6
8
|
- jruby-9.1.7.0
|
|
7
9
|
jdk:
|
|
8
10
|
- oraclejdk8
|
|
9
|
-
# - openjdk7
|
|
10
11
|
env:
|
|
11
12
|
- "JRUBY_OPTS='--dev'"
|
|
12
13
|
- "JRUBY_OPTS='-Xcompile.invokedynamic=true'"
|
|
13
14
|
matrix:
|
|
14
15
|
exclude:
|
|
16
|
+
- rvm: 2.1.10
|
|
17
|
+
jdk: oraclejdk8
|
|
18
|
+
env: "JRUBY_OPTS='-Xcompile.invokedynamic=true'"
|
|
19
|
+
- rvm: 2.2.6
|
|
20
|
+
jdk: oraclejdk8
|
|
21
|
+
env: "JRUBY_OPTS='-Xcompile.invokedynamic=true'"
|
|
15
22
|
- rvm: 2.3.3
|
|
16
23
|
jdk: oraclejdk8
|
|
17
24
|
env: "JRUBY_OPTS='-Xcompile.invokedynamic=true'"
|
|
@@ -22,6 +29,7 @@ matrix:
|
|
|
22
29
|
- rvm: jruby-9.1.7.0
|
|
23
30
|
jdk: oraclejdk8
|
|
24
31
|
env: "JRUBY_OPTS='-Xcompile.invokedynamic=true'"
|
|
32
|
+
|
|
25
33
|
before_install:
|
|
26
34
|
- gem update --system
|
|
27
35
|
- gem install bundler -v 1.14.3
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Receptacle
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
[](https://badge.fury.io/rb/receptacle)
|
|
4
|
+
[](https://rubygems.org/gems/receptacle)
|
|
5
5
|
[](https://travis-ci.org/andreaseger/receptacle)
|
|
6
6
|
[](https://codecov.io/gh/andreaseger/receptacle)
|
|
7
7
|
|
|
@@ -272,14 +272,21 @@ implemented in this way:
|
|
|
272
272
|
|
|
273
273
|
```ruby
|
|
274
274
|
class MemoryStore
|
|
275
|
-
class << self
|
|
275
|
+
class << self
|
|
276
|
+
def store
|
|
277
|
+
@store || clear
|
|
278
|
+
end
|
|
279
|
+
def clear
|
|
280
|
+
@store = {}
|
|
281
|
+
end
|
|
282
|
+
end
|
|
276
283
|
|
|
277
284
|
def clear
|
|
278
|
-
self.class.
|
|
285
|
+
self.class.clear
|
|
279
286
|
end
|
|
280
287
|
|
|
281
288
|
private def store
|
|
282
|
-
self.class.store
|
|
289
|
+
self.class.store
|
|
283
290
|
end
|
|
284
291
|
end
|
|
285
292
|
```
|
|
@@ -314,6 +321,14 @@ useful if you're not yet sure this is the correct or best possible gem,
|
|
|
314
321
|
the [faraday](https://github.com/lostisland/faraday) gem is essentially doing
|
|
315
322
|
this by giving all the different http libraries a common interface).
|
|
316
323
|
|
|
324
|
+
## Testing
|
|
325
|
+
|
|
326
|
+
A module called `TestSupport` can be found
|
|
327
|
+
[here](https://github.com/andreaseger/receptacle/blob/master/lib/receptacle/test_support.rb).
|
|
328
|
+
Right now it provides 2 helper methods `with_strategy` to easily toggle
|
|
329
|
+
temporarily to another strategy and `ensure_method_delegators` to solve issues
|
|
330
|
+
caused by Rspec when attempting to stub a repository method. Both methods and
|
|
331
|
+
how to use them is described in more detail in the inline documentation.
|
|
317
332
|
|
|
318
333
|
## Goals of this implementation
|
|
319
334
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
module Receptacle
|
|
3
3
|
module TestSupport
|
|
4
|
+
# with_strategy
|
|
5
|
+
#
|
|
4
6
|
# provides helpful method to toggle strategies during testing
|
|
5
7
|
#
|
|
6
8
|
# can be used in rspec like this
|
|
@@ -41,11 +43,20 @@ module Receptacle
|
|
|
41
43
|
original_strategy = repo.strategy
|
|
42
44
|
repo.strategy strategy
|
|
43
45
|
yield
|
|
46
|
+
ensure
|
|
44
47
|
repo.strategy original_strategy
|
|
45
48
|
end
|
|
46
49
|
|
|
47
|
-
#
|
|
48
|
-
#
|
|
50
|
+
# ensure_method_delegators
|
|
51
|
+
#
|
|
52
|
+
# When using something like `allow(SomeRepo).to receive(:find)` (where find
|
|
53
|
+
# is a mediated method) before the method was called the first time Rspec
|
|
54
|
+
# would stub the method with the wrong arity of 0 when also using jruby.
|
|
55
|
+
# This seems to be caused by the lazily defined methods. Simply calling the
|
|
56
|
+
# following method in a before hook when method stubbing is need solves this
|
|
57
|
+
# issue. As it's a problem which only affects mocking libraries it's
|
|
58
|
+
# currently not planned to change this behavior.
|
|
59
|
+
#
|
|
49
60
|
def ensure_method_delegators(repo)
|
|
50
61
|
Receptacle::Registration.repositories[repo].methods.each do |method_name|
|
|
51
62
|
repo.__build_method(method_name)
|
data/lib/receptacle/version.rb
CHANGED
data/performance/profile.rb
CHANGED
data/receptacle.gemspec
CHANGED
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
|
15
15
|
spec.homepage = 'https://github.com/andreaseger/receptacle'
|
|
16
16
|
spec.license = 'MIT'
|
|
17
17
|
|
|
18
|
-
spec.required_ruby_version = '~> 2.
|
|
18
|
+
spec.required_ruby_version = '~> 2.1'
|
|
19
19
|
|
|
20
20
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
21
21
|
f.match(%r{^(test|spec|features)/})
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: receptacle
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andreas Eger
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-02-
|
|
11
|
+
date: 2017-02-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -209,7 +209,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
209
209
|
requirements:
|
|
210
210
|
- - "~>"
|
|
211
211
|
- !ruby/object:Gem::Version
|
|
212
|
-
version: '2.
|
|
212
|
+
version: '2.1'
|
|
213
213
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
214
|
requirements:
|
|
215
215
|
- - ">="
|