aspect 0.0.2 → 0.0.3
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/VERSION +1 -1
- data/lib/aspect/has_attributes.rb +3 -13
- data/spec/coverage/index.html +1579 -7
- data/spec/lib/aspect/has_attributes_spec.rb +0 -168
- metadata +2 -2
@@ -57,58 +57,6 @@ describe Aspect::HasAttributes do
|
|
57
57
|
it "should define the getter" do
|
58
58
|
expect(instance.name).to eq("foobar")
|
59
59
|
end
|
60
|
-
|
61
|
-
context "and it's a Hash" do
|
62
|
-
context "and the :method option is passed" do
|
63
|
-
let(:instance) do
|
64
|
-
instance_class = Class.new(TestObject) do
|
65
|
-
attribute(:name, getter: { method: :capitalize })
|
66
|
-
end
|
67
|
-
|
68
|
-
instance_class.new
|
69
|
-
end
|
70
|
-
|
71
|
-
it "define the getter which calls the given method on the instance variable" do
|
72
|
-
expect(instance.name).to eq("Foobar")
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
context "and the :instance_method option is passed" do
|
77
|
-
let(:instance) do
|
78
|
-
instance_class = Class.new(TestObject) do
|
79
|
-
attribute(:name, getter: { instance_method: :reversitalize })
|
80
|
-
|
81
|
-
def reversitalize(value)
|
82
|
-
value.reverse.capitalize
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
instance_class.new
|
87
|
-
end
|
88
|
-
|
89
|
-
it "define the getter which calls the given instance method, passing the instance variable as the argument" do
|
90
|
-
expect(instance.name).to eq("Raboof")
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
context "and both the :method and :instance_method options are passed" do
|
95
|
-
let(:instance) do
|
96
|
-
instance_class = Class.new(TestObject) do
|
97
|
-
attribute(:name, getter: { method: :capitalize, instance_method: :exclamationize })
|
98
|
-
|
99
|
-
def exclamationize(value)
|
100
|
-
"#{value}!"
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
instance_class.new
|
105
|
-
end
|
106
|
-
|
107
|
-
it "define the getter which calls the given instance method, passing the result of the method called on the instance variable as the argument" do
|
108
|
-
expect(instance.name).to eq("Foobar!")
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
60
|
end
|
113
61
|
|
114
62
|
context "and it's falsey" do
|
@@ -142,64 +90,6 @@ describe Aspect::HasAttributes do
|
|
142
90
|
instance.name = "foobar"
|
143
91
|
expect(instance.name).to eq("foobar")
|
144
92
|
end
|
145
|
-
|
146
|
-
context "and it's a Hash" do
|
147
|
-
context "and the :method option is passed" do
|
148
|
-
let(:instance) do
|
149
|
-
instance_class = Class.new(TestObject) do
|
150
|
-
attribute(:name, setter: { method: :capitalize })
|
151
|
-
end
|
152
|
-
|
153
|
-
instance_class.new
|
154
|
-
end
|
155
|
-
|
156
|
-
it "should define the setter which calls the given method on the instance variable" do
|
157
|
-
expect(instance.name).to eq("foobar")
|
158
|
-
instance.name = "foobar"
|
159
|
-
expect(instance.name).to eq("Foobar")
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
context "and the :instance_method option is passed" do
|
164
|
-
let(:instance) do
|
165
|
-
instance_class = Class.new(TestObject) do
|
166
|
-
attribute(:name, setter: { instance_method: :reversitalize })
|
167
|
-
|
168
|
-
def reversitalize(value)
|
169
|
-
value.reverse.capitalize
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
instance_class.new
|
174
|
-
end
|
175
|
-
|
176
|
-
it "should define the setter which calls the given instance method, passing the instance variable as the argument" do
|
177
|
-
expect(instance.name).to eq("foobar")
|
178
|
-
instance.name = "foobar"
|
179
|
-
expect(instance.name).to eq("Raboof")
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
context "and both the :method and :instance_method options are passed" do
|
184
|
-
let(:instance) do
|
185
|
-
instance_class = Class.new(TestObject) do
|
186
|
-
attribute(:name, setter: { method: :capitalize, instance_method: :exclamationize })
|
187
|
-
|
188
|
-
def exclamationize(value)
|
189
|
-
"#{value}!"
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
instance_class.new
|
194
|
-
end
|
195
|
-
|
196
|
-
it "define the setter which calls the given instance method, passing the result of the method called on the instance variable as the argument" do
|
197
|
-
expect(instance.name).to eq("foobar")
|
198
|
-
instance.name = "foobar"
|
199
|
-
expect(instance.name).to eq("Foobar!")
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
203
93
|
end
|
204
94
|
|
205
95
|
context "and it's falsey" do
|
@@ -233,64 +123,6 @@ describe Aspect::HasAttributes do
|
|
233
123
|
instance.name = "foobar"
|
234
124
|
expect(instance.name).to eq("raboof")
|
235
125
|
end
|
236
|
-
|
237
|
-
context "and it's a Hash" do
|
238
|
-
context "and the :method option is passed" do
|
239
|
-
let(:instance) do
|
240
|
-
instance_class = Class.new(TestObject) do
|
241
|
-
attribute(:name, setter: { method: :capitalize })
|
242
|
-
end
|
243
|
-
|
244
|
-
instance_class.new
|
245
|
-
end
|
246
|
-
|
247
|
-
it "should define the setter which calls the given method on the instance variable" do
|
248
|
-
expect(instance.name).to eq("foobar")
|
249
|
-
instance.name = "foobar"
|
250
|
-
expect(instance.name).to eq("Foobar")
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
context "and the :instance_method option is passed" do
|
255
|
-
let(:instance) do
|
256
|
-
instance_class = Class.new(TestObject) do
|
257
|
-
attribute(:name, setter: { instance_method: :reversitalize })
|
258
|
-
|
259
|
-
def reversitalize(value)
|
260
|
-
value.reverse.capitalize
|
261
|
-
end
|
262
|
-
end
|
263
|
-
|
264
|
-
instance_class.new
|
265
|
-
end
|
266
|
-
|
267
|
-
it "should define the setter which calls the given instance method, passing the instance variable as the argument" do
|
268
|
-
expect(instance.name).to eq("foobar")
|
269
|
-
instance.name = "foobar"
|
270
|
-
expect(instance.name).to eq("Raboof")
|
271
|
-
end
|
272
|
-
end
|
273
|
-
|
274
|
-
context "and both the :method and :instance_method options are passed" do
|
275
|
-
let(:instance) do
|
276
|
-
instance_class = Class.new(TestObject) do
|
277
|
-
attribute(:name, setter: { method: :capitalize, instance_method: :exclamationize })
|
278
|
-
|
279
|
-
def exclamationize(value)
|
280
|
-
"#{value}!"
|
281
|
-
end
|
282
|
-
end
|
283
|
-
|
284
|
-
instance_class.new
|
285
|
-
end
|
286
|
-
|
287
|
-
it "define the setter which calls the given instance method, passing the result of the method called on the instance variable as the argument" do
|
288
|
-
expect(instance.name).to eq("foobar")
|
289
|
-
instance.name = "foobar"
|
290
|
-
expect(instance.name).to eq("Foobar!")
|
291
|
-
end
|
292
|
-
end
|
293
|
-
end
|
294
126
|
end
|
295
127
|
|
296
128
|
context "and it's falsey" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aspect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Scott Lewis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A small collection of useful classes, modules, and mixins for plain old
|
14
14
|
Ruby objects.
|