jackbox 0.9.6.2
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 +7 -0
- data/.yardopts +5 -0
- data/CHANGES.txt +108 -0
- data/LICENSE.lic +0 -0
- data/LICENSE.txt +13 -0
- data/README.md +1395 -0
- data/Rakefile +6 -0
- data/bin/jackup +248 -0
- data/jackbox.gemspec +27 -0
- data/jackbox.jpg +0 -0
- data/lib/.document +0 -0
- data/lib/jackbox.rb +2 -0
- data/lib/jackbox/examples/dir.rb +80 -0
- data/lib/jackbox/examples/dx.rb +182 -0
- data/lib/jackbox/examples/transformers.rb +101 -0
- data/lib/jackbox/injectors.rb +2 -0
- data/lib/jackbox/rake.rb +2 -0
- data/lib/jackbox/tools/prefs.rb +2 -0
- data/lib/jackbox/version.rb +4 -0
- data/rgloader/loader.rb +23 -0
- data/rgloader/rgloader.darwin.bundle +0 -0
- data/rgloader/rgloader.freebsd.so +0 -0
- data/rgloader/rgloader.freebsd.x86_64.so +0 -0
- data/rgloader/rgloader.linux.so +0 -0
- data/rgloader/rgloader.linux.x86_64.so +0 -0
- data/rgloader/rgloader.mingw.so +0 -0
- data/rgloader/rgloader19.darwin.bundle +0 -0
- data/rgloader/rgloader19.freebsd.so +0 -0
- data/rgloader/rgloader19.freebsd.x86_64.so +0 -0
- data/rgloader/rgloader19.linux.so +0 -0
- data/rgloader/rgloader19.linux.x86_64.so +0 -0
- data/rgloader/rgloader19.mingw.so +0 -0
- data/rgloader/rgloader191.mingw.so +0 -0
- data/rgloader/rgloader192.darwin.bundle +0 -0
- data/rgloader/rgloader192.freebsd.so +0 -0
- data/rgloader/rgloader192.freebsd.x86_64.so +0 -0
- data/rgloader/rgloader192.linux.so +0 -0
- data/rgloader/rgloader192.linux.x86_64.so +0 -0
- data/rgloader/rgloader192.mingw.so +0 -0
- data/rgloader/rgloader193.darwin.bundle +0 -0
- data/rgloader/rgloader193.freebsd.so +0 -0
- data/rgloader/rgloader193.freebsd.x86_64.so +0 -0
- data/rgloader/rgloader193.linux.so +0 -0
- data/rgloader/rgloader193.linux.x86_64.so +0 -0
- data/rgloader/rgloader193.mingw.so +0 -0
- data/rgloader/rgloader20.darwin.bundle +0 -0
- data/rgloader/rgloader20.freebsd.so +0 -0
- data/rgloader/rgloader20.freebsd.x86_64.so +0 -0
- data/rgloader/rgloader20.linux.so +0 -0
- data/rgloader/rgloader20.linux.x86_64.so +0 -0
- data/rgloader/rgloader20.mingw.so +0 -0
- data/rgloader/rgloader20.mingw.x64.so +0 -0
- data/rgloader/rgloader21.darwin.bundle +0 -0
- data/rgloader/rgloader21.freebsd.so +0 -0
- data/rgloader/rgloader21.freebsd.x86_64.so +0 -0
- data/rgloader/rgloader21.linux.so +0 -0
- data/rgloader/rgloader21.linux.x86_64.so +0 -0
- data/rgloader/rgloader21.mingw.so +0 -0
- data/rgloader/rgloader21.mingw.x64.so +0 -0
- data/rgloader/rgloader22.darwin.bundle +0 -0
- data/rgloader/rgloader22.freebsd.so +0 -0
- data/rgloader/rgloader22.linux.so +0 -0
- data/rgloader/rgloader22.linux.x86_64.so +0 -0
- data/rgloader/rgloader22.mingw.so +0 -0
- data/rgloader/rgloader22.mingw.x64.so +0 -0
- data/spec/bin/jackup_cmd_shared.rb +176 -0
- data/spec/bin/jackup_cmd_spec.rb +292 -0
- data/spec/lib/abtract_spec.rb +56 -0
- data/spec/lib/jackbox/examples/dir_spec.rb +112 -0
- data/spec/lib/jackbox/examples/dx_spec.rb +346 -0
- data/spec/lib/jackbox/examples/result.xml +15 -0
- data/spec/lib/jackbox/examples/source1.xml +11 -0
- data/spec/lib/jackbox/examples/source2.xml +15 -0
- data/spec/lib/jackbox/examples/source3.xml +11 -0
- data/spec/lib/jackbox/examples/trasnformers_spec.rb +35 -0
- data/spec/lib/jackbox/injector_composition_spec.rb +950 -0
- data/spec/lib/jackbox/injector_directives_spec.rb +266 -0
- data/spec/lib/jackbox/injector_inheritance_spec.rb +799 -0
- data/spec/lib/jackbox/injector_introspection_spec.rb +614 -0
- data/spec/lib/jackbox/injector_namespacing_spec.rb +345 -0
- data/spec/lib/jackbox/injector_spec.rb +847 -0
- data/spec/lib/jackbox/injector_versioning_spec.rb +334 -0
- data/spec/lib/jackbox/patterns_spec.rb +410 -0
- data/spec/lib/jackbox/prefs_spec.rb +212 -0
- data/spec/lib/jackbox/reclassing_spec.rb +394 -0
- data/spec/lib/jackbox_spec.rb +595 -0
- data/spec/spec_helper.rb +139 -0
- metadata +218 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
=begin rdoc
|
3
|
+
abstract_spec
|
4
|
+
author: Lou Henry
|
5
|
+
:nodoc:all
|
6
|
+
=end
|
7
|
+
|
8
|
+
|
9
|
+
class Object
|
10
|
+
include Meta
|
11
|
+
end
|
12
|
+
|
13
|
+
describe Abstract do
|
14
|
+
it 'introduces module Abtract' do
|
15
|
+
Abstract.should be
|
16
|
+
end
|
17
|
+
# using public include now
|
18
|
+
describe Abstract, 'abstract class quality' do
|
19
|
+
a 'use case scenario' do
|
20
|
+
class Vector
|
21
|
+
extend Abstract
|
22
|
+
def speed
|
23
|
+
0
|
24
|
+
end
|
25
|
+
def direction
|
26
|
+
end
|
27
|
+
end
|
28
|
+
expect{Vector.new}.to raise_error(NoMethodError)
|
29
|
+
class Velocity < Vector
|
30
|
+
def speed
|
31
|
+
super + 35
|
32
|
+
end
|
33
|
+
def direction
|
34
|
+
:north
|
35
|
+
end
|
36
|
+
end
|
37
|
+
expect{Velocity.new}.to_not raise_error
|
38
|
+
Velocity.new.speed.should == 35
|
39
|
+
|
40
|
+
end #describe Abstract
|
41
|
+
it 'should not afect later descendants' do
|
42
|
+
class First
|
43
|
+
extend Abstract
|
44
|
+
end
|
45
|
+
expect{First.new}.to raise_error(NoMethodError)
|
46
|
+
class Second < First
|
47
|
+
end
|
48
|
+
expect{Second.new}.to_not raise_error
|
49
|
+
class Third < Second
|
50
|
+
end
|
51
|
+
expect{Third.new}.to_not raise_error
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
=begin rdoc
|
3
|
+
dir_spec
|
4
|
+
author: Lou Henry
|
5
|
+
:nodoc:all
|
6
|
+
=end
|
7
|
+
|
8
|
+
describe Dir do
|
9
|
+
|
10
|
+
#####
|
11
|
+
# Dir class tools
|
12
|
+
|
13
|
+
it 'modifies Dir class to include additional methods' do
|
14
|
+
Dir.should respond_to(:exists?)
|
15
|
+
Dir.should respond_to(:gem?)
|
16
|
+
Dir.should respond_to(:empty?)
|
17
|
+
Dir.should respond_to(:clear?)
|
18
|
+
Dir.should respond_to(:ls)
|
19
|
+
Dir.should respond_to(:la)
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "Dir.gem?" do
|
23
|
+
def gem_structure
|
24
|
+
File.open File.basename(Dir.pwd) + '-0.0.1.gemspec', 'w' do |file| end
|
25
|
+
File.open 'Rakefile', 'w' do |file|; end
|
26
|
+
FileUtils.mkpath File.join('lib', File.basename(Dir.pwd))
|
27
|
+
File.open File.join('lib', File.basename(Dir.pwd) + '.rb'), 'w' do |file| end
|
28
|
+
File.open File.join('lib', File.basename(Dir.pwd), 'version.rb'), 'w' do |file|; end
|
29
|
+
end
|
30
|
+
def rem_structure
|
31
|
+
(dir = Dir['*']).each { |d| FileUtils.rm_rf d }
|
32
|
+
end
|
33
|
+
|
34
|
+
specify 'Dir.gem? should be true if directory has a gem strucure' do
|
35
|
+
gem_structure
|
36
|
+
Dir.should be_gem
|
37
|
+
end
|
38
|
+
|
39
|
+
specify 'Dir.empty? should be true if dir is empty' do
|
40
|
+
rem_structure
|
41
|
+
Dir.should be_empty
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "Dir.empty?, Dir.clear?" do
|
46
|
+
def rfile
|
47
|
+
(1..8).map { |c| ('a'..'z').to_a.sample }.join
|
48
|
+
end
|
49
|
+
|
50
|
+
before :each do
|
51
|
+
FileUtils.rm_rf '.'
|
52
|
+
end
|
53
|
+
|
54
|
+
specify 'if files are present' do
|
55
|
+
FileUtils.touch rfile
|
56
|
+
Dir.should_not be_empty
|
57
|
+
Dir.should_not be_clear
|
58
|
+
end
|
59
|
+
|
60
|
+
specify 'if NO files are present' do
|
61
|
+
Dir.should be_empty
|
62
|
+
Dir.should be_clear
|
63
|
+
end
|
64
|
+
|
65
|
+
specify 'empty but not clear/clear is also empty' do
|
66
|
+
# add a couple of files
|
67
|
+
FileUtils.touch('.tester')
|
68
|
+
FileUtils.touch('mester')
|
69
|
+
#test for empty
|
70
|
+
Dir.should_not be_empty
|
71
|
+
Dir.should_not be_clear
|
72
|
+
File.delete('mester')
|
73
|
+
Dir.should be_empty
|
74
|
+
# test for clear of . files
|
75
|
+
Dir.should_not be_clear
|
76
|
+
File.delete('.tester')
|
77
|
+
Dir.should be_empty
|
78
|
+
Dir.should be_clear
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe 'Dir.new' do
|
83
|
+
before do
|
84
|
+
FileUtils.rm_rf '.'
|
85
|
+
end
|
86
|
+
it 'should have a somedir directory' do
|
87
|
+
# add directory
|
88
|
+
somedir = Dir.new 'somedir'
|
89
|
+
# test dir conditions
|
90
|
+
somedir.should be_instance_of(Dir)
|
91
|
+
Dir.should_not be_empty
|
92
|
+
Dir.ls.grep(/somedir/).should_not be_empty
|
93
|
+
File.should be_directory('somedir')
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe 'Dir.entries' do
|
98
|
+
before do
|
99
|
+
FileUtils.rm_rf '.'
|
100
|
+
end
|
101
|
+
it 'returns a list of members in dir' do
|
102
|
+
# add a couple of files
|
103
|
+
FileUtils.touch('.tester')
|
104
|
+
FileUtils.touch('mester')
|
105
|
+
# add a directory
|
106
|
+
somedir = Dir.new 'somedir'
|
107
|
+
# test for conditions
|
108
|
+
Dir.entries.should == ['.', '..', '.tester', 'mester', 'somedir']
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
@@ -0,0 +1,346 @@
|
|
1
|
+
# require "spec_helper"
|
2
|
+
# =begin rdoc
|
3
|
+
#
|
4
|
+
# #####
|
5
|
+
# # eXtra Dude: Debugger Helper specification
|
6
|
+
#
|
7
|
+
# Current Practice is:
|
8
|
+
# .
|
9
|
+
# .
|
10
|
+
# log or puts (some_variable)
|
11
|
+
# or
|
12
|
+
# open(some_file) do |file| ... or Logger.new()
|
13
|
+
# file.puts(some_variable) ... log.debug(some_variable)
|
14
|
+
# end
|
15
|
+
# ... later in the program life, these statements must be commented out
|
16
|
+
#
|
17
|
+
# We want a methodology to load some very basic debugging help over and beyond the trickery of puts statements
|
18
|
+
# in current use or that somehow crystalizes those current practices and enhances them with some helpful
|
19
|
+
# additions like loging program state info and line number. We also want the ability to call on the debugger at any
|
20
|
+
# point without much a-do, or to even automatically break into the debugger on Exception or other condition, and it has
|
21
|
+
# to be system independent, working with all versions of ruby.
|
22
|
+
#
|
23
|
+
# =end
|
24
|
+
#
|
25
|
+
#
|
26
|
+
# describe DX, :dx do
|
27
|
+
#
|
28
|
+
# before do
|
29
|
+
# tmpdir = rfolder()
|
30
|
+
# FileUtils.mkpath tmpdir
|
31
|
+
# Dir.chdir tmpdir
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# describe 'ability to break into debugger' do
|
35
|
+
#
|
36
|
+
# it 'has a method to break into debugger mode' do
|
37
|
+
# DX.should_receive :debug
|
38
|
+
# DX.debug
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# it 'can break into the debugger on exception' do
|
42
|
+
# DX.seize TypeError
|
43
|
+
# DX.should_receive :debug
|
44
|
+
# expect{String.new 3}.to raise_error
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# end
|
48
|
+
#
|
49
|
+
#
|
50
|
+
# # #####
|
51
|
+
# # # Enhanced Practice should be:
|
52
|
+
# #
|
53
|
+
# # it should automatically knows where to output with only minor options
|
54
|
+
# # it should automatically output program state at point of call
|
55
|
+
# # it should not need removal in production adding to the program function
|
56
|
+
# describe 'enhancing current debugging practice' do
|
57
|
+
#
|
58
|
+
# describe 'automatically know where to output program state with only minor options' do
|
59
|
+
#
|
60
|
+
# let!(:program){
|
61
|
+
# open 'tester', 'w+' do |file|
|
62
|
+
# file.puts %{
|
63
|
+
#
|
64
|
+
# require 'jackbox'
|
65
|
+
# require 'jackbox/examples/dx'
|
66
|
+
# some_variable = 'crap'
|
67
|
+
# def program tester
|
68
|
+
# DX.log 'this is a test'
|
69
|
+
# end
|
70
|
+
# program 'play'
|
71
|
+
#
|
72
|
+
# }
|
73
|
+
# end
|
74
|
+
# }
|
75
|
+
#
|
76
|
+
# describe 'know where to ouput' do
|
77
|
+
#
|
78
|
+
# it 'outputs to file named after the program in $0' do
|
79
|
+
# File.should exist('tester')
|
80
|
+
# launch 'tester'
|
81
|
+
# File.should exist('tester.log')
|
82
|
+
# open 'tester.log', 'r' do |f|
|
83
|
+
# f.readlines.grep(/this is a test/).should_not be_empty
|
84
|
+
# end
|
85
|
+
# end
|
86
|
+
#
|
87
|
+
# it 'creates output file in the location of the user' do
|
88
|
+
# File.should exist('tester')
|
89
|
+
# FileUtils.mkpath 'folder'
|
90
|
+
# Dir.chdir 'folder'
|
91
|
+
# launch '../tester'
|
92
|
+
# File.should exist('tester.log')
|
93
|
+
# open 'tester.log', 'r' do |f|
|
94
|
+
# f.readlines.grep(/this is a test/).should_not be_empty
|
95
|
+
# end
|
96
|
+
# end
|
97
|
+
#
|
98
|
+
# end
|
99
|
+
#
|
100
|
+
# describe 'options' do
|
101
|
+
#
|
102
|
+
# it 'has an option to output to terminal standard out' do
|
103
|
+
# DX.logger :active
|
104
|
+
# $stdout.should_receive(:write).with(/This is a screen test/)
|
105
|
+
# DX.log false, 'This is a screen test'
|
106
|
+
# end
|
107
|
+
#
|
108
|
+
# it 'has an option to output to system logs' do
|
109
|
+
# DX.syslog 'a test message for syslog'
|
110
|
+
# sleep 0.2
|
111
|
+
# if !OS.windows?
|
112
|
+
# open "/var/log/system.log", 'r' do |file|
|
113
|
+
# file.readlines.to_a[-5, 5].grep(%r{a test message for syslog}).should_not be_empty
|
114
|
+
# end
|
115
|
+
# end
|
116
|
+
# end
|
117
|
+
#
|
118
|
+
# end
|
119
|
+
#
|
120
|
+
# end
|
121
|
+
#
|
122
|
+
#
|
123
|
+
# describe 'automatically output program state at point of call. #log, #syslog, and #seize calls not only output
|
124
|
+
# the given msg but also extra program information at the point of call. If complete class DX injection is
|
125
|
+
# used then even more info is available. See below.' do
|
126
|
+
#
|
127
|
+
#
|
128
|
+
# let!(:program){
|
129
|
+
# open 'tester', 'w+' do |file|
|
130
|
+
# file.puts %{
|
131
|
+
#
|
132
|
+
# require 'jackbox'
|
133
|
+
# require 'jackbox/examples/dx'
|
134
|
+
# some_variable = 'crap'
|
135
|
+
# def program tester
|
136
|
+
# DX.log 'some programmer non-sense'
|
137
|
+
# end
|
138
|
+
# program 'play'
|
139
|
+
#
|
140
|
+
# DX.syslog 'a load of crap'
|
141
|
+
#
|
142
|
+
# }
|
143
|
+
# end
|
144
|
+
# }
|
145
|
+
#
|
146
|
+
# describe 'DX.log and DX.syslog calls' do
|
147
|
+
#
|
148
|
+
# the 'DX.log call' do
|
149
|
+
# File.should exist('tester')
|
150
|
+
# launch 'tester'
|
151
|
+
# File.should exist('tester.log')
|
152
|
+
# open 'tester.log', 'r' do |f| # in this case rspec is in $0
|
153
|
+
# lines = f.readlines
|
154
|
+
# lines.grep(/programmer non-sense/).should_not be_empty # programmer's message
|
155
|
+
# lines.grep(/tester:tester:\d+:in/).should_not be_empty # program name and file/caller info is part of the log from above
|
156
|
+
# end
|
157
|
+
# end
|
158
|
+
#
|
159
|
+
# the 'DX.syslog call' do
|
160
|
+
# File.should exist('tester')
|
161
|
+
# launch 'tester'
|
162
|
+
# File.should exist('tester.log')
|
163
|
+
# if !OS.windows?
|
164
|
+
# open "/var/log/system.log", 'r' do |f|
|
165
|
+
# lines = f.readlines
|
166
|
+
# lines[-5, 5].grep(%r{a load of crap}).should_not be_empty # programmer's message
|
167
|
+
# lines[-5, 5].grep(/tester:tester:\d+:in/).should_not be_empty # program name and file/caller info is part of the log from above
|
168
|
+
# end
|
169
|
+
# end
|
170
|
+
# end
|
171
|
+
#
|
172
|
+
# end
|
173
|
+
#
|
174
|
+
#
|
175
|
+
# describe 'DX.seize call: logging Exception information' do
|
176
|
+
#
|
177
|
+
# it 'allows system Exception info to be logged instead of stopping the program' do
|
178
|
+
# DX.logger :active
|
179
|
+
# DX.splatter :active
|
180
|
+
# DX.seize true, TypeError
|
181
|
+
# DX.should_receive :debug
|
182
|
+
# expect{String.new 3}.to raise_error
|
183
|
+
# sleep 0.2
|
184
|
+
# if !OS.windows?
|
185
|
+
# open('/var/log/system.log', 'r') do |file| # named 'rspec.log' because rspec is $0
|
186
|
+
# lines = file.readlines[-10, 10]
|
187
|
+
# lines.grep(/TypeError/).should_not be_empty
|
188
|
+
# lines.grep(/rspec/).should_not be_empty
|
189
|
+
# end
|
190
|
+
# end
|
191
|
+
# end
|
192
|
+
#
|
193
|
+
# end
|
194
|
+
# end
|
195
|
+
#
|
196
|
+
#
|
197
|
+
# describe 'no need for removal of each and every individual call in production having an
|
198
|
+
# option to "turn-off" all calls on a per module/injector basis' do
|
199
|
+
#
|
200
|
+
# the 'logger goes silent if collapse is called' do
|
201
|
+
# # call collapse on logger
|
202
|
+
# DX.logger :collapse
|
203
|
+
# DX.assert_loaded.should == nil
|
204
|
+
# DX.syslog('baa').should == nil
|
205
|
+
# end
|
206
|
+
#
|
207
|
+
# the 'debugger goes silent if collapse is called' do
|
208
|
+
# # collapse debugger
|
209
|
+
# DX.splatter :collapse
|
210
|
+
# DX.debug # nothing happens even without expectacion
|
211
|
+
# end
|
212
|
+
#
|
213
|
+
# end
|
214
|
+
#
|
215
|
+
# describe 'rebuilding the modules' do
|
216
|
+
#
|
217
|
+
# this 'is logger rebuilding' do
|
218
|
+
# DX.logger :collapse
|
219
|
+
# DX.assert_loaded('something').should == nil
|
220
|
+
# DX.syslog('boo').should be_nil
|
221
|
+
# # ...
|
222
|
+
# DX.logger :rebuild
|
223
|
+
# DX.assert_loaded('something').should_not == nil
|
224
|
+
# $stdout.should_receive(:write).with(/The hot thing/)
|
225
|
+
# DX.syslog false, 'The hot thing'
|
226
|
+
# sleep 0.2
|
227
|
+
# if !OS.windows?
|
228
|
+
# open '/var/log/system.log', 'r' do |file|
|
229
|
+
# lines = file.readlines
|
230
|
+
# lines.grep(/The hot thing/).should_not be_empty
|
231
|
+
# end
|
232
|
+
# end
|
233
|
+
# end
|
234
|
+
#
|
235
|
+
# this 'example shows splatter rebuilding' do
|
236
|
+
# DX.splatter :collapse
|
237
|
+
# DX.debug.should be_nil
|
238
|
+
# # ...
|
239
|
+
# DX.splatter :rebuild
|
240
|
+
# DX.should_receive :debug
|
241
|
+
# DX.debug
|
242
|
+
#
|
243
|
+
# # DX.seize NameError
|
244
|
+
# # DX.should_receive :debug
|
245
|
+
# # expect{eval('while crap do end')}.to raise_error
|
246
|
+
# end
|
247
|
+
#
|
248
|
+
# end
|
249
|
+
# end
|
250
|
+
#
|
251
|
+
#
|
252
|
+
# describe 'the case with complete class DX module injection to automatically output
|
253
|
+
# greater program state at point of call by creating a tracer. However and can
|
254
|
+
# slow down your times depending on context' do
|
255
|
+
#
|
256
|
+
# subject {
|
257
|
+
#
|
258
|
+
# # DX.splatter :rebuild
|
259
|
+
# # DX.logger :rebuild
|
260
|
+
#
|
261
|
+
# class Animal
|
262
|
+
# inject DX
|
263
|
+
#
|
264
|
+
# def initialize(var)
|
265
|
+
# @var = var
|
266
|
+
# end
|
267
|
+
# def crawl arg1, *args
|
268
|
+
# val = arg1
|
269
|
+
# h = args
|
270
|
+
# something = 'nothing'
|
271
|
+
# syslog 'We are in a crawl'
|
272
|
+
# self
|
273
|
+
# end
|
274
|
+
# def annomaly
|
275
|
+
# debug
|
276
|
+
# end
|
277
|
+
# self
|
278
|
+
# end
|
279
|
+
#
|
280
|
+
# }
|
281
|
+
#
|
282
|
+
# it 'outputs caller info' do
|
283
|
+
# subject.new("snail").crawl("in dirt", "slowly")
|
284
|
+
# sleep 0.2
|
285
|
+
# if !OS.windows?
|
286
|
+
# open('/var/log/system.log', 'r') do |file| # naned 'rspec.log' because rspec is $0
|
287
|
+
# lines = file.readlines[-10, 10]
|
288
|
+
# lines.grep(/We are in a crawl/).should_not be_empty
|
289
|
+
# lines.grep(/@var\W+snail/).should_not be_empty
|
290
|
+
# lines.grep(/arg1\W+in dirt/).should_not be_empty
|
291
|
+
# lines.grep(/args\W+slowly/).should_not be_empty
|
292
|
+
# lines.grep(/something\W+nothing/).should_not be_empty
|
293
|
+
# end
|
294
|
+
# end
|
295
|
+
# end
|
296
|
+
#
|
297
|
+
# the 'same goes from the #seize call' do
|
298
|
+
# class Animal
|
299
|
+
# inject DX
|
300
|
+
#
|
301
|
+
# def disease
|
302
|
+
# seize false, TypeError
|
303
|
+
# String.new 3
|
304
|
+
# end
|
305
|
+
# end
|
306
|
+
# dog = subject.new('dog')
|
307
|
+
# DX.should_receive :debug
|
308
|
+
# expect{dog.disease}.to raise_error
|
309
|
+
# end
|
310
|
+
#
|
311
|
+
# it 'is also possible to log from the seize call' do
|
312
|
+
# class Animal
|
313
|
+
# inject DX
|
314
|
+
#
|
315
|
+
# def secret
|
316
|
+
# seize true, ZeroDivisionError # break false turns into a log entry
|
317
|
+
# var = 1/0
|
318
|
+
# end
|
319
|
+
# end
|
320
|
+
# emu = subject.new('emu')
|
321
|
+
# DX.should_receive :debug
|
322
|
+
# expect{emu.secret}.to raise_error
|
323
|
+
# sleep 0.2
|
324
|
+
# if !OS.windows?
|
325
|
+
# open('/var/log/system.log', 'r') do |file| # naned 'rspec.log' because rspec is $0
|
326
|
+
# lines = file.readlines[-10, 10]
|
327
|
+
# lines.grep(/ZeroDivisionError/).should_not be_empty
|
328
|
+
# lines.grep(/rspec.+?dx_spec.rb/).should_not be_empty
|
329
|
+
# end
|
330
|
+
# end
|
331
|
+
# end
|
332
|
+
#
|
333
|
+
# it 'still allows program stops for debug' do
|
334
|
+
# weirdo = subject.new('cat-dog')
|
335
|
+
# weirdo.should_receive :debug
|
336
|
+
# weirdo.annomaly
|
337
|
+
# end
|
338
|
+
#
|
339
|
+
# # it 'is not posible to include DX at the top level' do
|
340
|
+
# # expect{Object.inject DX}.to raise_error
|
341
|
+
# # end
|
342
|
+
#
|
343
|
+
# end
|
344
|
+
#
|
345
|
+
# end
|
346
|
+
#
|