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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7cf73a17e7eb57b985f1b21d82784a2387ed5edc
4
- data.tar.gz: 6964567a2581f9cb0d4e6be72ee52ac312a44fff
3
+ metadata.gz: 55b12e62420e5bd820d909846002084c473572d8
4
+ data.tar.gz: 60385bc42c56b0770b22e7703232686fcc6a150f
5
5
  SHA512:
6
- metadata.gz: 3720c2ae69bc18032ef7b48663496559a83f0826afa81c12f58a60fbcf124fccd94960f6754131ab11be5368da06cf571aac9ee64808d9dd0e181528b3d5959e
7
- data.tar.gz: 34f4e120c2c0d807dd65b9dc1772bfbad020dc010c43715214e931916ec873bb11b5b76180ca1694dcd5a1eac0aaaded4bff199d86fe1e0f5118897a5b376c10
6
+ metadata.gz: 24ea362cfb9be687030b24877c04895f5901bb29534ed6a7d86c611d2c41c901fb62d9e56563beed50e098a44726abcfb23b2231c904cb770e14b5c030af1688
7
+ data.tar.gz: 5532b99a99c6d49ca06c4f4e423ff2f9a4b75a092fe1775590a6b812967b0c7d056de0bbae5e0bc7a4270b8c9f1c53c66b10e69506a8eecf846bb88e77cac458
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.3
2
+ TargetRubyVersion: 2.1
3
3
 
4
4
  Metrics/LineLength:
5
5
  Max: 99
@@ -22,6 +22,5 @@ Metrics/MethodLength:
22
22
  Exclude:
23
23
  - test/*
24
24
 
25
-
26
25
  Style/Documentation:
27
26
  Enabled: false
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
@@ -4,6 +4,12 @@ Changelog
4
4
  master
5
5
  ---
6
6
 
7
+ 0.2.0
8
+ ---
9
+
10
+ - update documentation
11
+ - enable ruby 2.1+
12
+
7
13
  0.1.1
8
14
  ---
9
15
 
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Receptacle
2
2
 
3
-
4
3
  [![Gem Version](https://badge.fury.io/rb/receptacle.svg)](https://badge.fury.io/rb/receptacle)
4
+ [![Gem Downloads](https://img.shields.io/gem/dt/receptacle.svg)](https://rubygems.org/gems/receptacle)
5
5
  [![Build Status](https://travis-ci.org/andreaseger/receptacle.svg?branch=master)](https://travis-ci.org/andreaseger/receptacle)
6
6
  [![codecov](https://codecov.io/gh/andreaseger/receptacle/branch/master/graph/badge.svg)](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; attr_accessor :store end
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.store = []
285
+ self.class.clear
279
286
  end
280
287
 
281
288
  private def store
282
- self.class.store || clear
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
- # rspec mocks/stubs don't like the lazy defined delegate methods use this to
48
- # make sure the methods are already defined
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)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Receptacle
3
- VERSION = '0.1.1'
3
+ VERSION = "0.2.0".freeze
4
4
  end
@@ -3,7 +3,7 @@
3
3
  # run with --profile.api in JRUBY_OPTS
4
4
  require 'bundler/inline'
5
5
  require 'jruby/profiler'
6
- PROFILE_NAME = 'receptacle'
6
+ PROFILE_NAME = 'receptacle'.freeze
7
7
 
8
8
  gemfile false do
9
9
  source 'https://rubygems.org'
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.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.1.1
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-02 00:00:00.000000000 Z
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.2'
212
+ version: '2.1'
213
213
  required_rubygems_version: !ruby/object:Gem::Requirement
214
214
  requirements:
215
215
  - - ">="