decorum 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3 -0
- data/decorum.gemspec +1 -1
- data/lib/decorum/version.rb +1 -1
- data/spec/unit/callable_decorator_spec.rb +1 -1
- data/spec/unit/decorated_state_spec.rb +1 -1
- data/spec/unit/decorations_spec.rb +22 -22
- data/spec/unit/decorator_namespace_spec.rb +1 -1
- data/spec/unit/decorator_spec.rb +10 -10
- metadata +15 -23
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7bfa93fae71415540de7bd2671d54885520c7c02
|
4
|
+
data.tar.gz: 3bfbf59a7418f85ab8c8127abf392b4ca05b1a3b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0ab83066bd10977de6e9490d94f0fe8f7c68300d5b67a200a239b15b3d1d5c7072f6b6767566ca2109ebd295ac96a59ff6833d86b67edfbb85ee2945e367c08a
|
7
|
+
data.tar.gz: 8f269196ea075f3fbe8fdf780f0c21441de56a65be5d18e9520bf0082b18a4dbed6df5b80d8e28a1ef3307942ce39933be8384f09f00c0d2b47f49a2900816a5
|
data/CHANGELOG.md
CHANGED
data/decorum.gemspec
CHANGED
data/lib/decorum/version.rb
CHANGED
@@ -16,7 +16,7 @@ describe Decorum::CallableDecorator do
|
|
16
16
|
context "testing assumptions" do
|
17
17
|
# just make sure we did this right...
|
18
18
|
it "is a Decorator" do
|
19
|
-
expect(decorator.is_a?(Decorum::CallableDecorator)).to
|
19
|
+
expect(decorator.is_a?(Decorum::CallableDecorator)).to be true
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -17,18 +17,18 @@ describe Decorum::Decorations do
|
|
17
17
|
|
18
18
|
describe '.decorators' do
|
19
19
|
it 'stores decorators in own state correctly' do
|
20
|
-
expect(klass.decorators.map { |d| d[0].ancestors.include?(Decorum::Decorator) }.inject(:&)).to
|
20
|
+
expect(klass.decorators.map { |d| d[0].ancestors.include?(Decorum::Decorator) }.inject(:&)).to be true
|
21
21
|
end
|
22
22
|
|
23
23
|
# the instance method #load_decorators_from_class will insert them in the order given:
|
24
24
|
|
25
25
|
it 'normally gives first priority to last listed' do
|
26
|
-
expect(klass.decorators.map { |d| d[1] } == [{ passed_option: "one" }, { passed_option: "two" }]).to
|
26
|
+
expect(klass.decorators.map { |d| d[1] } == [{ passed_option: "one" }, { passed_option: "two" }]).to be true
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'reverses order for first-specfied priority' do
|
30
30
|
klass.decorators :reverse
|
31
|
-
expect(klass.decorators.map { |d| d[1] } == [{ passed_option: "two" }, { passed_option: "one" }]).to
|
31
|
+
expect(klass.decorators.map { |d| d[1] } == [{ passed_option: "two" }, { passed_option: "one" }]).to be true
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'rejects malformed options' do
|
@@ -41,15 +41,15 @@ describe Decorum::Decorations do
|
|
41
41
|
let(:obj) { klass.new.load_decorators_from_class }
|
42
42
|
it 'returns self' do
|
43
43
|
# sort of
|
44
|
-
expect(obj.is_a?(klass)).to
|
44
|
+
expect(obj.is_a?(klass)).to be true
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'loads all decorators given by .decorators' do
|
48
|
-
expect(obj.one == "one" && obj.two == "two").to
|
48
|
+
expect(obj.one == "one" && obj.two == "two").to be true
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'loads decorators in the order given by .decorators' do
|
52
|
-
expect(obj.passed_option == "two").to
|
52
|
+
expect(obj.passed_option == "two").to be true
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -58,32 +58,32 @@ describe Decorum::Decorations do
|
|
58
58
|
context 'as-yet-undecorated' do
|
59
59
|
# assert some basic assumptions
|
60
60
|
it 'is decoratable' do
|
61
|
-
expect(decorated.is_a?(Decorum::Decorations)).to
|
61
|
+
expect(decorated.is_a?(Decorum::Decorations)).to be true
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'does not respond to first decorator test method' do
|
65
|
-
expect(decorated.respond_to?(:first_decorator_method)).to
|
65
|
+
expect(decorated.respond_to?(:first_decorator_method)).to be false
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'responds to its own methods' do
|
69
|
-
expect(decorated.undecorated_method).to
|
69
|
+
expect(decorated.undecorated_method).to be true
|
70
70
|
end
|
71
71
|
|
72
72
|
describe '#is_decorated?' do
|
73
73
|
it 'is false' do
|
74
|
-
expect(decorated.is_decorated?).to
|
74
|
+
expect(decorated.is_decorated?).to be false
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
78
|
describe '#decorated_state' do
|
79
79
|
it 'returns a hash' do
|
80
80
|
blank_state = decorated.decorated_state
|
81
|
-
expect(blank_state.is_a?(Hash)).to
|
81
|
+
expect(blank_state.is_a?(Hash)).to be true
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'returns an empty hash' do
|
85
85
|
blank_state = decorated.decorated_state
|
86
|
-
expect(blank_state.empty?).to
|
86
|
+
expect(blank_state.empty?).to be true
|
87
87
|
end
|
88
88
|
|
89
89
|
it 'returns nil given an argument' do
|
@@ -128,26 +128,26 @@ describe Decorum::Decorations do
|
|
128
128
|
|
129
129
|
describe '#is_decorated?' do
|
130
130
|
it 'returns true' do
|
131
|
-
expect(decorated.is_decorated?).to
|
131
|
+
expect(decorated.is_decorated?).to be true
|
132
132
|
end
|
133
133
|
|
134
134
|
it 'returns false after unloading' do
|
135
135
|
decorated.undecorate(decorated.decorators.first)
|
136
|
-
expect(decorated.is_decorated?).to
|
136
|
+
expect(decorated.is_decorated?).to be false
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
140
|
it 'installs intercept' do
|
141
|
-
expect(decorated.is_a?(Decorum::Decorations::Intercept)).to
|
141
|
+
expect(decorated.is_a?(Decorum::Decorations::Intercept)).to be true
|
142
142
|
end
|
143
143
|
|
144
144
|
it 'sets internal state' do
|
145
145
|
internal_state = decorated.instance_variable_get(:@_decorator_chain)
|
146
|
-
expect(internal_state.is_a?(deco_class_1)).to
|
146
|
+
expect(internal_state.is_a?(deco_class_1)).to be true
|
147
147
|
end
|
148
148
|
|
149
149
|
it 'does not lose its own methods' do
|
150
|
-
expect(decorated.respect_previously_defined_methods?).to
|
150
|
+
expect(decorated.respect_previously_defined_methods?).to be true
|
151
151
|
end
|
152
152
|
|
153
153
|
it 'gains the methods of the decorator' do
|
@@ -210,15 +210,15 @@ describe Decorum::Decorations do
|
|
210
210
|
before(:each) { decorated.decorate(deco_class_1) }
|
211
211
|
|
212
212
|
it 'returns true for decorated methods' do
|
213
|
-
expect(decorated.respond_to?(:first_decorator_method)).to
|
213
|
+
expect(decorated.respond_to?(:first_decorator_method)).to be true
|
214
214
|
end
|
215
215
|
|
216
216
|
it 'returns true for undecorated methods' do
|
217
|
-
expect(decorated.respond_to?(:undecorated_method)).to
|
217
|
+
expect(decorated.respond_to?(:undecorated_method)).to be true
|
218
218
|
end
|
219
219
|
|
220
220
|
it 'returns false for undefined method' do
|
221
|
-
expect(decorated.respond_to?(:nonexistent_method)).to
|
221
|
+
expect(decorated.respond_to?(:nonexistent_method)).to be false
|
222
222
|
end
|
223
223
|
end
|
224
224
|
|
@@ -277,11 +277,11 @@ describe Decorum::Decorations do
|
|
277
277
|
before(:each) { decorated.undecorate(@undec) }
|
278
278
|
|
279
279
|
it 'no longer responds to removed decorated method' do
|
280
|
-
expect(decorated.respond_to?(:second_decorator_method)).to
|
280
|
+
expect(decorated.respond_to?(:second_decorator_method)).to be false
|
281
281
|
end
|
282
282
|
|
283
283
|
it 'still responds to other decorated methods' do
|
284
|
-
expect(decorated.respond_to?(:third_decorator_method)).to
|
284
|
+
expect(decorated.respond_to?(:third_decorator_method)).to be true
|
285
285
|
end
|
286
286
|
|
287
287
|
it 'doesn\'t mind if we check one just to be sure' do
|
data/spec/unit/decorator_spec.rb
CHANGED
@@ -9,32 +9,32 @@ describe Decorum::Decorator do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'responds to .share' do
|
12
|
-
expect(Decorum::Decorator.respond_to?(:share)).to
|
12
|
+
expect(Decorum::Decorator.respond_to?(:share)).to be true
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'responds to .accumulator' do
|
16
|
-
expect(Decorum::Decorator.respond_to?(:accumulator)).to
|
16
|
+
expect(Decorum::Decorator.respond_to?(:accumulator)).to be true
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'responds to .default_attributes' do
|
20
|
-
expect(Decorum::Decorator.respond_to?(:default_attributes)).to
|
20
|
+
expect(Decorum::Decorator.respond_to?(:default_attributes)).to be true
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'responds to .get_default_attributes' do
|
24
|
-
expect(Decorum::Decorator.respond_to?(:get_default_attributes)).to
|
24
|
+
expect(Decorum::Decorator.respond_to?(:get_default_attributes)).to be true
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'responds to .immediate' do
|
28
|
-
expect(Decorum::Decorator.respond_to?(:immediate)).to
|
28
|
+
expect(Decorum::Decorator.respond_to?(:immediate)).to be true
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'responds to .immediate_methods' do
|
32
|
-
expect(Decorum::Decorator.respond_to?(:immediate_methods)).to
|
32
|
+
expect(Decorum::Decorator.respond_to?(:immediate_methods)).to be true
|
33
33
|
end
|
34
34
|
|
35
35
|
describe '#decorated_state' do
|
36
36
|
it 'defers to the root object' do
|
37
|
-
expect(decorator.decorated_state.reaching_its_destination?).to
|
37
|
+
expect(decorator.decorated_state.reaching_its_destination?).to be true
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -169,7 +169,7 @@ describe Decorum::Decorator do
|
|
169
169
|
|
170
170
|
context 'when calling decorator methods' do
|
171
171
|
it 'picks up methods it has' do
|
172
|
-
expect(decorator.basic_decorator_method).to
|
172
|
+
expect(decorator.basic_decorator_method).to be true
|
173
173
|
end
|
174
174
|
|
175
175
|
it 'defers methods it doesn\'t have' do
|
@@ -182,7 +182,7 @@ describe Decorum::Decorator do
|
|
182
182
|
|
183
183
|
context 'when methods are declared immediate' do
|
184
184
|
it 'includes them in @immediate_methods' do
|
185
|
-
expect(Decorum::Examples::StrongWilledDecorator.immediate_methods.include?(:method_in_question)).to
|
185
|
+
expect(Decorum::Examples::StrongWilledDecorator.immediate_methods.include?(:method_in_question)).to be true
|
186
186
|
end
|
187
187
|
|
188
188
|
it 'respects various forms of declaration' do
|
@@ -195,7 +195,7 @@ describe Decorum::Decorator do
|
|
195
195
|
end
|
196
196
|
|
197
197
|
got_em = methods.map { |m| Decorum::Examples::StrongWilledDecorator.immediate_methods.include?(m) }.inject(:&)
|
198
|
-
expect(got_em).to
|
198
|
+
expect(got_em).to be true
|
199
199
|
end
|
200
200
|
|
201
201
|
context 'with no arguments' do
|
metadata
CHANGED
@@ -1,62 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decorum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
5
|
-
prerelease:
|
4
|
+
version: 0.4.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Erik Cameron
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-04-24 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '1.3'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '1.3'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rspec
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- - ~>
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '2.14'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- - ~>
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '2.14'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rake
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - "~>"
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
description: Tasteful decorators for Ruby. Use it wherever.
|
@@ -66,8 +59,8 @@ executables: []
|
|
66
59
|
extensions: []
|
67
60
|
extra_rdoc_files: []
|
68
61
|
files:
|
69
|
-
- .gitignore
|
70
|
-
- .travis.yml
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
71
64
|
- CHANGELOG.md
|
72
65
|
- Gemfile
|
73
66
|
- LICENSE.txt
|
@@ -116,27 +109,26 @@ files:
|
|
116
109
|
homepage: http://erikcameron.github.io/
|
117
110
|
licenses:
|
118
111
|
- MIT
|
112
|
+
metadata: {}
|
119
113
|
post_install_message:
|
120
114
|
rdoc_options: []
|
121
115
|
require_paths:
|
122
116
|
- lib
|
123
117
|
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
-
none: false
|
125
118
|
requirements:
|
126
|
-
- -
|
119
|
+
- - ">="
|
127
120
|
- !ruby/object:Gem::Version
|
128
121
|
version: '0'
|
129
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
-
none: false
|
131
123
|
requirements:
|
132
|
-
- -
|
124
|
+
- - ">="
|
133
125
|
- !ruby/object:Gem::Version
|
134
126
|
version: '0'
|
135
127
|
requirements: []
|
136
128
|
rubyforge_project:
|
137
|
-
rubygems_version:
|
129
|
+
rubygems_version: 2.4.5
|
138
130
|
signing_key:
|
139
|
-
specification_version:
|
131
|
+
specification_version: 4
|
140
132
|
summary: Decorum implements the Decorator pattern (more or less) in a fairly unobtrusive
|
141
133
|
way.
|
142
134
|
test_files:
|