injectable_dependencies 1.1.0 → 1.2.0

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: 061ab1c3ffd232aff0541defb77b8491d670421b
4
- data.tar.gz: 1be76a0ab83cf9a50690543c85780e9309d30591
3
+ metadata.gz: b857147762fe7c1b75e3f3c846ab5f8da18b886a
4
+ data.tar.gz: 87e79f37b1fa93378f0e2b1e644cb1f9b15ad46f
5
5
  SHA512:
6
- metadata.gz: cc5a0a1b6aa5eaf381d56dfd50e6fb540ff65e5a407fe5209f652db692ecaf73d00fe3dc8fb2159da1066ef23d76a705a3d31fb7df15ab92040d06cff5448b80
7
- data.tar.gz: 680bc81279cd67075c31de0beb357d2ec802a7430442fee92ade32f92ddb525d4eabdad7c6cc76e75458221097d6bb08e70a60626e2915af3e3708159e8f1990
6
+ metadata.gz: f7e4d5496b4b1d32ca814bdbd4f67d599effb397489f8ab761e2a68a22a66a944273b39207a7313dd4242f33bc9eb2e1ab9620f04e9b4f4148ece26833683e6f
7
+ data.tar.gz: 43c5bf98e48e7c98c84ac45228083be1dcc7073f106cc5b210d0e31208c106ac3330f150fbdaf63dfeb0d89d3c6e514db1af34433b1bed7ff61fbcff9bba4bc2
@@ -1,3 +1,3 @@
1
1
  module InjectableDependencies
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -42,6 +42,12 @@ module InjectableDependencies
42
42
  end
43
43
  end
44
44
 
45
+ def initialize(opts={})
46
+ if opts.has_key?(:dependencies)
47
+ initialize_dependencies(opts[:dependencies])
48
+ end
49
+ end
50
+
45
51
  def initialize_dependencies(overrides = {})
46
52
  return unless overrides
47
53
  self.class.send(:no_default_dependencies).each do |name|
@@ -14,6 +14,14 @@ describe InjectableDependencies do
14
14
  end
15
15
  }
16
16
 
17
+ let(:dependent_class_with_default_initializer) {
18
+ Class.new do
19
+ include InjectableDependencies
20
+ dependency(:foo) { FooDependency }
21
+ dependency(:bar) { IfThisConstantIsEverDefinedSomeoneIsGettingFiredAndItWontBeMe }
22
+ end
23
+ }
24
+
17
25
  let(:dependant) {
18
26
  dependant_class.new
19
27
  }
@@ -31,6 +39,11 @@ describe InjectableDependencies do
31
39
  expect(dependant.bar).to eq :bar_dependency
32
40
  end
33
41
 
42
+ it 'provides a default initializer that allows dependency overrides' do
43
+ dependant = dependent_class_with_default_initializer.new(:dependencies => {:bar => :bar_dependency})
44
+ expect(dependant.bar).to eq :bar_dependency
45
+ end
46
+
34
47
  it 'does not persist dependencies between instances' do
35
48
  s0 = dependant_class.new
36
49
  s1 = dependant_class.new(:dependencies => { :foo => :s1_dep })
@@ -48,7 +61,7 @@ describe InjectableDependencies do
48
61
  end
49
62
 
50
63
  context 'when a dependency is defined without a default implementation' do
51
- let(:dependent_class) {
64
+ let(:dependent_class_with_own_initializer) {
52
65
  Class.new do
53
66
  include InjectableDependencies
54
67
  dependency(:baz)
@@ -59,7 +72,7 @@ describe InjectableDependencies do
59
72
  }
60
73
 
61
74
  it 'raises an error if an implementation is not provided during dependency initialization' do
62
- expect{ dependent_class.new }.to \
75
+ expect{ dependent_class_with_own_initializer.new }.to \
63
76
  raise_error(InjectableDependencies::MissingImplementationError,
64
77
  'No implementation was provided for dependency #baz')
65
78
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: injectable_dependencies
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Wilger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-08 00:00:00.000000000 Z
11
+ date: 2014-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  version: '0'
103
103
  requirements: []
104
104
  rubyforge_project:
105
- rubygems_version: 2.0.3
105
+ rubygems_version: 2.0.14
106
106
  signing_key:
107
107
  specification_version: 4
108
108
  summary: Make your object's collaborators injectable so you can test them.