skn_utils 5.4.0 → 5.8.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 +5 -5
- data/.rspec +2 -0
- data/README.md +223 -72
- data/_config.yml +4 -4
- data/bin/concurrent_test_block +54 -0
- data/bin/concurrent_test_grouped +45 -0
- data/bin/concurrent_test_procs +45 -0
- data/bin/concurrent_test_wrapped +49 -0
- data/lib/skn_container.rb +2 -1
- data/lib/skn_failure.rb +2 -0
- data/lib/skn_hash.rb +2 -0
- data/lib/skn_registry.rb +25 -5
- data/lib/skn_settings.rb +2 -0
- data/lib/skn_success.rb +2 -0
- data/lib/skn_utils.rb +13 -2
- data/lib/skn_utils/concurrent_jobs.rb +117 -0
- data/lib/skn_utils/configurable.rb +55 -6
- data/lib/skn_utils/configuration.rb +2 -0
- data/lib/skn_utils/core_extensions.rb +29 -0
- data/lib/skn_utils/dotted_hash.rb +1 -0
- data/lib/skn_utils/env_string_handler.rb +2 -0
- data/lib/skn_utils/http_processor.rb +34 -0
- data/lib/skn_utils/job_commands.rb +247 -0
- data/lib/skn_utils/nested_result.rb +2 -0
- data/lib/skn_utils/notifier_base.rb +2 -0
- data/lib/skn_utils/null_object.rb +2 -0
- data/lib/skn_utils/page_controls.rb +2 -0
- data/lib/skn_utils/result_bean.rb +2 -0
- data/lib/skn_utils/version.rb +3 -1
- data/lib/skn_utils/wrappable.rb +32 -0
- data/skn_utils.gemspec +27 -22
- data/spec/lib/skn_utils/concurrent_jobs_spec.rb +279 -0
- data/spec/lib/skn_utils/configurable_spec.rb +23 -36
- data/spec/lib/skn_utils/registry_spec.rb +22 -0
- data/spec/lib/skn_utils/wrappers_spec.rb +80 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/support/configurables.rb +36 -0
- data/spec/support/xml_matchers.rb +121 -0
- metadata +71 -24
- data/README.rdoc +0 -379
@@ -0,0 +1,279 @@
|
|
1
|
+
##
|
2
|
+
# spec/lib/skn_utils/as_human_size_spec.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
|
6
|
+
describe SknUtils::ConcurrentJobs, 'Run Multiple Jobs' do
|
7
|
+
|
8
|
+
let(:commands) {
|
9
|
+
[
|
10
|
+
SknUtils::CommandJSONPost.call(full_url: "http://example.com/posts", payload: {one: 1}, headers: {'my-header'=> "header-value"}),
|
11
|
+
SknUtils::CommandFORMPost.call(full_url: "http://example.com/posts", payload: {one: 1}),
|
12
|
+
SknUtils::CommandJSONGet.call(full_url: "http://example.com/posts/1"),
|
13
|
+
SknUtils::CommandJSONPut.call(full_url: "http://example.com/posts", payload: {one: 1}),
|
14
|
+
SknUtils::CommandFORMDelete.call(full_url: "http://example.com/posts/1")
|
15
|
+
]
|
16
|
+
}
|
17
|
+
|
18
|
+
let(:test_proc) {
|
19
|
+
->(cmd) { SknSuccess.(cmd.uri.request_uri, "Ok") }
|
20
|
+
}
|
21
|
+
|
22
|
+
let(:inline_failure_proc) {
|
23
|
+
->(cmd) { SknFailure.(cmd.uri.request_uri, "Failure") }
|
24
|
+
}
|
25
|
+
|
26
|
+
let(:catastrophic_proc) {
|
27
|
+
->(cmd) { SomeUnkownThing.(cmd.uri.request_uri, "Catastrophic") }
|
28
|
+
}
|
29
|
+
|
30
|
+
context "HTTP Requests " do
|
31
|
+
it "Job Commands will provide a valid http request object" do
|
32
|
+
expect(commands.any?(&:request)).to be true
|
33
|
+
end
|
34
|
+
|
35
|
+
it "Performs Http Post Requests" do
|
36
|
+
test_url = "http://jsonplaceholder.typicode.com/users"
|
37
|
+
stub_request(:post, test_url).
|
38
|
+
to_return(status: 200, body: "{\"message\":\"me\"}", headers: {})
|
39
|
+
|
40
|
+
cmd = SknUtils::CommandJSONPost.call(full_url: test_url, payload: {"one" => 1})
|
41
|
+
|
42
|
+
provider = SknUtils::ConcurrentJobs.call
|
43
|
+
provider.register_job do
|
44
|
+
SknUtils::JobWrapper.call(cmd, SknUtils::HttpProcessor)
|
45
|
+
end
|
46
|
+
result = provider.render_jobs
|
47
|
+
|
48
|
+
expect(result).to be_a(SknUtils::Result)
|
49
|
+
expect(result.success?).to be true
|
50
|
+
expect(result.values.size).to eq(1)
|
51
|
+
expect(result.values[0]).to be_a(SknSuccess)
|
52
|
+
expect(result.values[0].value).to be_a(Hash)
|
53
|
+
expect(result.values[0].value["message"]).to eq("me")
|
54
|
+
end
|
55
|
+
|
56
|
+
it "Performs Http Form Post Requests" do
|
57
|
+
test_url = "http://jsonplaceholder.typicode.com/users"
|
58
|
+
stub_request(:post, test_url).
|
59
|
+
to_return(status: 200, body: "message=me", headers: {})
|
60
|
+
|
61
|
+
cmd = SknUtils::CommandFORMPost.call(full_url: test_url, payload: {"one" => 1})
|
62
|
+
|
63
|
+
provider = SknUtils::ConcurrentJobs.call
|
64
|
+
provider.register_job do
|
65
|
+
SknUtils::JobWrapper.call(cmd, SknUtils::HttpProcessor)
|
66
|
+
end
|
67
|
+
result = provider.render_jobs
|
68
|
+
|
69
|
+
expect(result).to be_a(SknUtils::Result)
|
70
|
+
expect(result.success?).to be true
|
71
|
+
expect(result.values.size).to eq(1)
|
72
|
+
expect(result.values[0]).to be_a(SknSuccess)
|
73
|
+
expect(result.values[0].value).to be_a(String)
|
74
|
+
expect(result.values[0].value).to eq("message=me")
|
75
|
+
end
|
76
|
+
|
77
|
+
it "Performs Http Get Requests" do
|
78
|
+
test_url = "http://jsonplaceholder.typicode.com/users"
|
79
|
+
stub_request(:get, test_url).
|
80
|
+
to_return(status: 200, body: "{\"message\":\"me\"}", headers: {})
|
81
|
+
|
82
|
+
cmd = SknUtils::CommandJSONGet.call(full_url: test_url)
|
83
|
+
|
84
|
+
provider = SknUtils::ConcurrentJobs.call
|
85
|
+
provider.register_job do
|
86
|
+
SknUtils::JobWrapper.call(cmd, SknUtils::HttpProcessor)
|
87
|
+
end
|
88
|
+
result = provider.render_jobs
|
89
|
+
|
90
|
+
expect(result).to be_a(SknUtils::Result)
|
91
|
+
expect(result.success?).to be true
|
92
|
+
expect(result.values.size).to eq(1)
|
93
|
+
expect(result.values[0]).to be_a(SknSuccess)
|
94
|
+
expect(result.values[0].value).to be_a(Hash)
|
95
|
+
expect(result.values[0].value["message"]).to eq("me")
|
96
|
+
end
|
97
|
+
|
98
|
+
it "Performs Http Put Requests" do
|
99
|
+
test_url = "http://jsonplaceholder.typicode.com/users"
|
100
|
+
stub_request(:put, test_url).
|
101
|
+
to_return(status: 200, body: "{\"message\":\"me\"}", headers: {})
|
102
|
+
|
103
|
+
cmd = SknUtils::CommandJSONPut.call(full_url: test_url, payload: {"one" => 1})
|
104
|
+
|
105
|
+
provider = SknUtils::ConcurrentJobs.call
|
106
|
+
provider.register_job do
|
107
|
+
SknUtils::JobWrapper.call(cmd, SknUtils::HttpProcessor)
|
108
|
+
end
|
109
|
+
result = provider.render_jobs
|
110
|
+
|
111
|
+
expect(result).to be_a(SknUtils::Result)
|
112
|
+
expect(result.success?).to be true
|
113
|
+
expect(result.values.size).to eq(1)
|
114
|
+
expect(result.values[0]).to be_a(SknSuccess)
|
115
|
+
expect(result.values[0].value).to be_a(Hash)
|
116
|
+
expect(result.values[0].value["message"]).to eq("me")
|
117
|
+
end
|
118
|
+
|
119
|
+
it "Performs Http Form Delete Requests" do
|
120
|
+
test_url = "http://jsonplaceholder.typicode.com/users"
|
121
|
+
stub_request(:delete, test_url).
|
122
|
+
to_return(status: 200, body: "message=me", headers: {})
|
123
|
+
|
124
|
+
cmd = SknUtils::CommandFORMDelete.call(full_url: test_url, payload: {"one" => 1})
|
125
|
+
|
126
|
+
provider = SknUtils::ConcurrentJobs.call
|
127
|
+
provider.register_job do
|
128
|
+
SknUtils::JobWrapper.call(cmd, SknUtils::HttpProcessor)
|
129
|
+
end
|
130
|
+
result = provider.render_jobs
|
131
|
+
|
132
|
+
expect(result).to be_a(SknUtils::Result)
|
133
|
+
expect(result.success?).to be true
|
134
|
+
expect(result.values.size).to eq(1)
|
135
|
+
expect(result.values[0]).to be_a(SknSuccess)
|
136
|
+
expect(result.values[0].value).to be_a(String)
|
137
|
+
expect(result.values[0].value).to eq("message=me")
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
context "Asynchronous" do
|
142
|
+
it "Runs Jobs" do
|
143
|
+
provider = SknUtils::ConcurrentJobs.call
|
144
|
+
provider.register_jobs(commands, test_proc)
|
145
|
+
result = provider.render_jobs
|
146
|
+
|
147
|
+
expect(result).to be_a(SknUtils::Result)
|
148
|
+
expect(result.success?).to be true
|
149
|
+
expect(result.values.size).to eq(commands.size)
|
150
|
+
expect(result.values[0]).to be_a(SknSuccess)
|
151
|
+
end
|
152
|
+
it "Runs Jobs and handles inline failures" do
|
153
|
+
provider = SknUtils::ConcurrentJobs.call
|
154
|
+
|
155
|
+
provider.register_job do
|
156
|
+
SknUtils::JobWrapper.call(commands[0], test_proc)
|
157
|
+
end
|
158
|
+
provider.register_job do
|
159
|
+
SknUtils::JobWrapper.call(commands[1], inline_failure_proc)
|
160
|
+
end
|
161
|
+
provider.register_job do
|
162
|
+
SknUtils::JobWrapper.call(commands[2], inline_failure_proc)
|
163
|
+
end
|
164
|
+
provider.register_job do
|
165
|
+
SknUtils::JobWrapper.call(commands[3], inline_failure_proc)
|
166
|
+
end
|
167
|
+
provider.register_job do
|
168
|
+
SknUtils::JobWrapper.call(commands[4], test_proc)
|
169
|
+
end
|
170
|
+
|
171
|
+
result = provider.render_jobs
|
172
|
+
|
173
|
+
expect(result).to be_a(SknUtils::Result)
|
174
|
+
expect(result.success?).to be false
|
175
|
+
expect(result.values.size).to eq(commands.size)
|
176
|
+
expect(result.values[1]).to be_a(SknFailure)
|
177
|
+
expect(result.values[1].message).to eq("Failure")
|
178
|
+
end
|
179
|
+
it "Runs Jobs and handles catastrophic failures" do
|
180
|
+
provider = SknUtils::ConcurrentJobs.call
|
181
|
+
provider.register_job do
|
182
|
+
SknUtils::JobWrapper.call(command[0], test_proc)
|
183
|
+
end
|
184
|
+
provider.register_job do # notice `command` vs `commands`
|
185
|
+
SknUtils::JobWrapper.call(command[1], inline_failure_proc)
|
186
|
+
end
|
187
|
+
provider.register_job do
|
188
|
+
SknUtils::JobWrapper.call(command[2], catastrophic_proc)
|
189
|
+
end
|
190
|
+
provider.register_job do
|
191
|
+
SknUtils::JobWrapper.call(commands[3], catastrophic_proc)
|
192
|
+
end
|
193
|
+
provider.register_job do
|
194
|
+
SknUtils::JobWrapper.call(commands[4], test_proc)
|
195
|
+
end
|
196
|
+
|
197
|
+
result = provider.render_jobs
|
198
|
+
|
199
|
+
expect(result).to be_a(SknUtils::Result)
|
200
|
+
expect(result.success?).to be false
|
201
|
+
expect(result.values.size).to eq(commands.size)
|
202
|
+
expect(result.values.last).to be_a(SknSuccess)
|
203
|
+
expect(result.values[3].value).to eq("NameError")
|
204
|
+
expect(result.values[2]).to be_a(SknFailure)
|
205
|
+
expect(result.values[1]).to be_a(SknFailure)
|
206
|
+
expect(result.values[0]).to be_a(SknFailure)
|
207
|
+
expect(result.values[0].value).to eq("Unknown")
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
context "Synchronous" do
|
212
|
+
it "Runs Jobs" do
|
213
|
+
provider = SknUtils::ConcurrentJobs.call(async: false)
|
214
|
+
provider.register_jobs(commands, test_proc)
|
215
|
+
result = provider.render_jobs
|
216
|
+
|
217
|
+
expect(result).to be_a(SknUtils::Result)
|
218
|
+
expect(result.success?).to be true
|
219
|
+
expect(result.values.size).to eq(commands.size)
|
220
|
+
expect(result.values[0]).to be_a(SknSuccess)
|
221
|
+
end
|
222
|
+
it "Runs Jobs and handles inline failures" do
|
223
|
+
provider = SknUtils::ConcurrentJobs.call
|
224
|
+
|
225
|
+
provider.register_job do
|
226
|
+
SknUtils::JobWrapper.call(commands[0], test_proc)
|
227
|
+
end
|
228
|
+
provider.register_job do
|
229
|
+
SknUtils::JobWrapper.call(commands[1], inline_failure_proc)
|
230
|
+
end
|
231
|
+
provider.register_job do
|
232
|
+
SknUtils::JobWrapper.call(commands[2], inline_failure_proc)
|
233
|
+
end
|
234
|
+
provider.register_job do
|
235
|
+
SknUtils::JobWrapper.call(commands[3], inline_failure_proc)
|
236
|
+
end
|
237
|
+
provider.register_job do
|
238
|
+
SknUtils::JobWrapper.call(commands[4], test_proc)
|
239
|
+
end
|
240
|
+
|
241
|
+
result = provider.render_jobs
|
242
|
+
|
243
|
+
expect(result).to be_a(SknUtils::Result)
|
244
|
+
expect(result.success?).to be false
|
245
|
+
expect(result.values.size).to eq(commands.size)
|
246
|
+
expect(result.values[1]).to be_a(SknFailure)
|
247
|
+
expect(result.values[1].message).to eq("Failure")
|
248
|
+
end
|
249
|
+
it "Runs Jobs and handles catastrophic failures" do
|
250
|
+
provider = SknUtils::ConcurrentJobs.call
|
251
|
+
provider.register_job do
|
252
|
+
SknUtils::JobWrapper.call(commands[0], test_proc)
|
253
|
+
end
|
254
|
+
provider.register_job do
|
255
|
+
SknUtils::JobWrapper.call(commands[1], inline_failure_proc)
|
256
|
+
end
|
257
|
+
provider.register_job do
|
258
|
+
SknUtils::JobWrapper.call(commands[2], catastrophic_proc)
|
259
|
+
end
|
260
|
+
provider.register_job do
|
261
|
+
SknUtils::JobWrapper.call(commands[3], catastrophic_proc)
|
262
|
+
end
|
263
|
+
provider.register_job do
|
264
|
+
SknUtils::JobWrapper.call(commands[4], test_proc)
|
265
|
+
end
|
266
|
+
|
267
|
+
result = provider.render_jobs
|
268
|
+
|
269
|
+
expect(result).to be_a(SknUtils::Result)
|
270
|
+
expect(result.success?).to be false
|
271
|
+
expect(result.values.size).to eq(commands.size)
|
272
|
+
expect(result.values[3].value).to eq("NameError")
|
273
|
+
expect(result.values[2]).to be_a(SknFailure)
|
274
|
+
expect(result.values[1]).to be_a(SknFailure)
|
275
|
+
expect(result.values[0]).to be_a(SknSuccess)
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
end
|
@@ -2,51 +2,20 @@
|
|
2
2
|
# spec/lib/skn_utils/configurable_spec.rb
|
3
3
|
#
|
4
4
|
|
5
|
-
|
6
|
-
include SknUtils::Configurable.with( :app_id, :title, :cookie_name, enable_root: true) # No options hash defaults to true
|
7
|
-
# - and accept defaults for #env=, #root=, #registry=, and #logger=
|
8
|
-
|
9
|
-
# notice: self.logger=, the self is required when assigning values
|
10
|
-
self.logger = Object.new
|
11
|
-
self.registry = Object.new
|
12
|
-
|
13
|
-
configure do
|
14
|
-
app_id 'some app'
|
15
|
-
title 'My Title'
|
16
|
-
cookie_name 'Chocolate'
|
17
|
-
end
|
18
|
-
|
19
|
-
def null_value
|
20
|
-
@app_id.dup
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
module MyMod
|
25
|
-
include SknUtils::Configurable.with(:app_id, :title, :cookie_name, enable_root: false)
|
26
|
-
|
27
|
-
def self.null_value
|
28
|
-
@app_id.dup
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
MyMod.configure do
|
33
|
-
app_id 'some module'
|
34
|
-
title 'Some Title'
|
35
|
-
cookie_name 'Caramel'
|
36
|
-
end
|
5
|
+
require "support/configurables"
|
37
6
|
|
38
7
|
|
39
8
|
describe SknUtils::Configurable, "Gem Configuration module." do
|
40
9
|
|
41
10
|
let(:my_app) { MyApp.new }
|
42
11
|
|
43
|
-
context "Top Level AppClass Extra Operational Features. " do
|
12
|
+
context "MyApp: Top Level AppClass Extra Operational Features. " do
|
44
13
|
|
45
14
|
it "MyApp.env.test? returns expected value. " do
|
46
15
|
expect( MyApp.env.test? ).to be true
|
47
16
|
end
|
48
17
|
it "MyApp.root returns expected value. " do
|
49
|
-
expect( MyApp.root
|
18
|
+
expect( MyApp.root ).to eq( Dir.pwd )
|
50
19
|
end
|
51
20
|
it "MyApp.logger returns expected value. " do
|
52
21
|
expect( MyApp.logger ).to be_instance_of(Object) # eq('No Logger Assigned.')
|
@@ -60,9 +29,11 @@ describe SknUtils::Configurable, "Gem Configuration module." do
|
|
60
29
|
|
61
30
|
it "my_app#config.title returns expected value. " do
|
62
31
|
expect( MyApp.config.title ).to eq( "My Title" )
|
32
|
+
expect( MyApp.config[:title] ).to eq( "My Title" )
|
63
33
|
end
|
64
|
-
it "my_app#config
|
65
|
-
expect( MyApp.config
|
34
|
+
it "my_app#config[:value] accepts and returns expected value. " do
|
35
|
+
expect( MyApp.config[:value]="New Attribute" ).to eq( "New Attribute" )
|
36
|
+
expect( MyApp.config[:value] ).to eq( "New Attribute" )
|
66
37
|
end
|
67
38
|
|
68
39
|
it "MyMod#config.app_id returns expected value. " do
|
@@ -70,6 +41,11 @@ describe SknUtils::Configurable, "Gem Configuration module." do
|
|
70
41
|
end
|
71
42
|
it "MyMod#config.cookie_name returns expected value. " do
|
72
43
|
expect( MyMod.config.cookie_name ).to eq( 'Caramel' )
|
44
|
+
expect( MyMod.config[:cookie_name] ).to eq( 'Caramel' )
|
45
|
+
end
|
46
|
+
it "MyMod#config[:value] accepts and returns expected value. " do
|
47
|
+
expect( MyMod.config[:value]="New Attribute" ).to eq( "New Attribute" )
|
48
|
+
expect( MyMod.config[:value] ).to eq( "New Attribute" )
|
73
49
|
end
|
74
50
|
|
75
51
|
it "MyMod#logger raises NoMethodError as expected. " do
|
@@ -78,4 +54,15 @@ describe SknUtils::Configurable, "Gem Configuration module." do
|
|
78
54
|
|
79
55
|
end
|
80
56
|
|
57
|
+
context "#config instance vars are accessable as expected. " do
|
58
|
+
|
59
|
+
it "MyApp#null_value to return expected value" do
|
60
|
+
expect(my_app.null_value).to eq "some app"
|
61
|
+
expect{ MyApp.null_value }.to raise_error(NoMethodError)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "MyMod#null_value to return expected value" do
|
65
|
+
expect( MyMod.null_value ).to eq "some module"
|
66
|
+
end
|
67
|
+
end
|
81
68
|
end
|
@@ -127,4 +127,26 @@ describe SknRegistry, "IoC Lite Container class." do
|
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
|
+
|
131
|
+
context "When used for testing " do
|
132
|
+
|
133
|
+
it "#register_mock Registers a temporary mock." do
|
134
|
+
services.register_mock(:service_c, "Testing" )
|
135
|
+
|
136
|
+
expect(services.resolve(:service_c)).to eq "Testing"
|
137
|
+
services.restore!
|
138
|
+
end
|
139
|
+
|
140
|
+
it "#unregister_mocks! Remove all mocks and restores previous entries if present." do
|
141
|
+
original = services.resolve(:service_c)
|
142
|
+
services.substitute(:service_c, "Testing")
|
143
|
+
expect(services.resolve(:service_c)).to eq "Testing"
|
144
|
+
|
145
|
+
services.unregister_mocks!
|
146
|
+
|
147
|
+
services.resolve(:service_c)
|
148
|
+
expect(services.resolve(:service_c)).to eq original
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
130
152
|
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# ##
|
2
|
+
#
|
3
|
+
|
4
|
+
module Powered
|
5
|
+
def make_noise
|
6
|
+
puts "Powering up"
|
7
|
+
super
|
8
|
+
puts "Shutting down"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Machine
|
13
|
+
extend SknUtils::Wrappable
|
14
|
+
|
15
|
+
wrap Powered
|
16
|
+
|
17
|
+
def make_noise
|
18
|
+
puts "Buzzzzzz"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
module Logging
|
24
|
+
def make_noise
|
25
|
+
puts "Started making noise"
|
26
|
+
super
|
27
|
+
puts "Finished making noise"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Bird
|
32
|
+
extend SknUtils::Wrappable
|
33
|
+
|
34
|
+
wrap Logging
|
35
|
+
|
36
|
+
def make_noise
|
37
|
+
puts "Chirp, chirp!"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
module Flying
|
43
|
+
def make_noise
|
44
|
+
super
|
45
|
+
puts "Is flying away"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class Pigeon < Bird
|
50
|
+
wrap Flying
|
51
|
+
|
52
|
+
def make_noise
|
53
|
+
puts "Coo!"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe 'SknUtils::Wrappable Module Handles Inheritance properly ' do
|
58
|
+
|
59
|
+
it '#make_noise handles Bird module. ' do
|
60
|
+
expect do
|
61
|
+
obj = Bird.new
|
62
|
+
obj.make_noise
|
63
|
+
end.to output("Started making noise\nChirp, chirp!\nFinished making noise\n").to_stdout
|
64
|
+
end
|
65
|
+
|
66
|
+
it '#make_noise handles Pigeon module. ' do
|
67
|
+
expect do
|
68
|
+
obj = Pigeon.new
|
69
|
+
obj.make_noise
|
70
|
+
end.to output("Started making noise\nCoo!\nFinished making noise\nIs flying away\n").to_stdout
|
71
|
+
end
|
72
|
+
|
73
|
+
it '#make_noise handles Machine module. ' do
|
74
|
+
expect do
|
75
|
+
obj = Machine.new
|
76
|
+
obj.make_noise
|
77
|
+
end.to output("Powering up\nBuzzzzzz\nShutting down\n").to_stdout
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|