injectable_dependencies 1.2.0 → 1.2.1

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: b857147762fe7c1b75e3f3c846ab5f8da18b886a
4
- data.tar.gz: 87e79f37b1fa93378f0e2b1e644cb1f9b15ad46f
3
+ metadata.gz: 8e5a62a3f85f8aa713eda4c0931e8f3274b26d92
4
+ data.tar.gz: 86d374a14c54ffd19d55960d03f7949580c78929
5
5
  SHA512:
6
- metadata.gz: f7e4d5496b4b1d32ca814bdbd4f67d599effb397489f8ab761e2a68a22a66a944273b39207a7313dd4242f33bc9eb2e1ab9620f04e9b4f4148ece26833683e6f
7
- data.tar.gz: 43c5bf98e48e7c98c84ac45228083be1dcc7073f106cc5b210d0e31208c106ac3330f150fbdaf63dfeb0d89d3c6e514db1af34433b1bed7ff61fbcff9bba4bc2
6
+ metadata.gz: d9d6040425e5bf06d404b3649fbe8776b5ed21fe5cf17977895723200956cce7bd123c8b2e2aa320162684e55d61cb9fb60ae0dace8761b5e49e1565322a28b1
7
+ data.tar.gz: 76a00acbd1367c1eab96f65e59b00343f472775709b813d5d71dccf4f3239bfa8fc14e6b67effdddeda45f94200634d1968f28113a1826c850a1c5759a4960ca
@@ -43,9 +43,8 @@ module InjectableDependencies
43
43
  end
44
44
 
45
45
  def initialize(opts={})
46
- if opts.has_key?(:dependencies)
47
- initialize_dependencies(opts[:dependencies])
48
- end
46
+ dependencies = opts[:dependencies] || {}
47
+ initialize_dependencies(dependencies)
49
48
  end
50
49
 
51
50
  def initialize_dependencies(overrides = {})
@@ -1,3 +1,3 @@
1
1
  module InjectableDependencies
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -42,6 +42,7 @@ describe InjectableDependencies do
42
42
  it 'provides a default initializer that allows dependency overrides' do
43
43
  dependant = dependent_class_with_default_initializer.new(:dependencies => {:bar => :bar_dependency})
44
44
  expect(dependant.bar).to eq :bar_dependency
45
+ expect(dependant.foo).to be FooDependency
45
46
  end
46
47
 
47
48
  it 'does not persist dependencies between instances' do
@@ -61,20 +62,37 @@ describe InjectableDependencies do
61
62
  end
62
63
 
63
64
  context 'when a dependency is defined without a default implementation' do
64
- let(:dependent_class_with_own_initializer) {
65
- Class.new do
66
- include InjectableDependencies
67
- dependency(:baz)
68
- def initialize(dependencies = {})
69
- initialize_dependencies(dependencies)
65
+ context 'when the dependent class has its own initializer' do
66
+ let(:dependent_class) {
67
+ Class.new do
68
+ include InjectableDependencies
69
+ dependency(:baz)
70
+ def initialize(dependencies = {})
71
+ initialize_dependencies(dependencies)
72
+ end
70
73
  end
74
+ }
75
+
76
+ it 'raises an error if an implementation is not provided during dependency initialization' do
77
+ expect{ dependent_class.new }.to \
78
+ raise_error(InjectableDependencies::MissingImplementationError,
79
+ 'No implementation was provided for dependency #baz')
71
80
  end
72
- }
81
+ end
73
82
 
74
- it 'raises an error if an implementation is not provided during dependency initialization' do
75
- expect{ dependent_class_with_own_initializer.new }.to \
76
- raise_error(InjectableDependencies::MissingImplementationError,
77
- 'No implementation was provided for dependency #baz')
83
+ context 'when the dependent class uses the default initializer' do
84
+ let(:dependent_class) {
85
+ Class.new do
86
+ include InjectableDependencies
87
+ dependency(:baz)
88
+ end
89
+ }
90
+
91
+ it 'raises an error if an implementation is not provided during dependency initialization' do
92
+ expect{ dependent_class.new }.to \
93
+ raise_error(InjectableDependencies::MissingImplementationError,
94
+ 'No implementation was provided for dependency #baz')
95
+ end
78
96
  end
79
97
  end
80
98
  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.2.0
4
+ version: 1.2.1
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-05-27 00:00:00.000000000 Z
11
+ date: 2014-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport