rhodes-framework 1.0.10 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (198) hide show
  1. data/Manifest.txt +159 -30
  2. data/Rakefile +3 -19
  3. data/lib/erb.rb +1 -1
  4. data/lib/rho/rho.rb +94 -107
  5. data/lib/rho/rhofsconnector.rb +4 -0
  6. data/lib/rho/rhoutils.rb +26 -0
  7. data/lib/rho/rhoviewhelpers.rb +1 -1
  8. data/lib/rhodes.rb +2 -2
  9. data/lib/rhoframework.rb +9 -9
  10. data/lib/rhom/rhom.rb +1 -1
  11. data/lib/rhom/rhom_db_adapter.rb +36 -15
  12. data/lib/rhom/rhom_db_adapterME.rb +2 -3
  13. data/lib/rhom/rhom_object.rb +14 -2
  14. data/lib/rhom/rhom_object_factory.rb +42 -11
  15. data/lib/version.rb +2 -2
  16. data/spec/README +1 -0
  17. data/spec/Rakefile +1 -0
  18. data/spec/{configs/account.rb → app/Account/config.rb} +0 -0
  19. data/spec/{configs/case.rb → app/Case/config.rb} +0 -0
  20. data/spec/app/Question/config.rb +3 -0
  21. data/spec/app/Settings/controller.rb +10 -0
  22. data/spec/app/Settings/index.erb +11 -0
  23. data/spec/app/SpecRunner/controller.rb +15 -0
  24. data/spec/app/SpecRunner/index.erb +14 -0
  25. data/spec/app/application.rb +4 -0
  26. data/spec/app/index.erb +17 -0
  27. data/spec/app/layout.erb +27 -0
  28. data/spec/app/loading.html +11 -0
  29. data/spec/app/mspec.rb +11 -0
  30. data/spec/app/mspec/expectations.rb +2 -0
  31. data/spec/app/mspec/expectations/expectations.rb +17 -0
  32. data/spec/app/mspec/expectations/should.rb +25 -0
  33. data/spec/app/mspec/fileutils.rb +1590 -0
  34. data/spec/app/mspec/guards.rb +16 -0
  35. data/spec/app/mspec/guards/background.rb +21 -0
  36. data/spec/app/mspec/guards/bug.rb +24 -0
  37. data/spec/app/mspec/guards/compliance.rb +37 -0
  38. data/spec/app/mspec/guards/conflict.rb +18 -0
  39. data/spec/app/mspec/guards/endian.rb +44 -0
  40. data/spec/app/mspec/guards/extensions.rb +20 -0
  41. data/spec/app/mspec/guards/guard.rb +166 -0
  42. data/spec/app/mspec/guards/noncompliance.rb +20 -0
  43. data/spec/app/mspec/guards/platform.rb +43 -0
  44. data/spec/app/mspec/guards/quarantine.rb +17 -0
  45. data/spec/app/mspec/guards/runner.rb +34 -0
  46. data/spec/app/mspec/guards/superuser.rb +17 -0
  47. data/spec/app/mspec/guards/support.rb +20 -0
  48. data/spec/app/mspec/guards/tty.rb +20 -0
  49. data/spec/app/mspec/guards/version.rb +38 -0
  50. data/spec/app/mspec/helpers.rb +11 -0
  51. data/spec/app/mspec/helpers/argv.rb +43 -0
  52. data/spec/app/mspec/helpers/bignum.rb +5 -0
  53. data/spec/app/mspec/helpers/const_lookup.rb +9 -0
  54. data/spec/app/mspec/helpers/environment.rb +23 -0
  55. data/spec/app/mspec/helpers/fixture.rb +20 -0
  56. data/spec/app/mspec/helpers/flunk.rb +5 -0
  57. data/spec/app/mspec/helpers/io.rb +17 -0
  58. data/spec/app/mspec/helpers/language_version.rb +20 -0
  59. data/spec/app/mspec/helpers/ruby_exe.rb +123 -0
  60. data/spec/app/mspec/helpers/scratch.rb +17 -0
  61. data/spec/app/mspec/helpers/tmp.rb +32 -0
  62. data/spec/app/mspec/matchers.rb +23 -0
  63. data/spec/app/mspec/matchers/base.rb +95 -0
  64. data/spec/app/mspec/matchers/be_an_instance_of.rb +26 -0
  65. data/spec/app/mspec/matchers/be_ancestor_of.rb +24 -0
  66. data/spec/app/mspec/matchers/be_close.rb +27 -0
  67. data/spec/app/mspec/matchers/be_empty.rb +20 -0
  68. data/spec/app/mspec/matchers/be_false.rb +20 -0
  69. data/spec/app/mspec/matchers/be_kind_of.rb +24 -0
  70. data/spec/app/mspec/matchers/be_nil.rb +20 -0
  71. data/spec/app/mspec/matchers/be_true.rb +20 -0
  72. data/spec/app/mspec/matchers/complain.rb +56 -0
  73. data/spec/app/mspec/matchers/eql.rb +26 -0
  74. data/spec/app/mspec/matchers/equal.rb +26 -0
  75. data/spec/app/mspec/matchers/equal_element.rb +78 -0
  76. data/spec/app/mspec/matchers/equal_utf16.rb +34 -0
  77. data/spec/app/mspec/matchers/have_constant.rb +30 -0
  78. data/spec/app/mspec/matchers/have_instance_method.rb +24 -0
  79. data/spec/app/mspec/matchers/have_method.rb +24 -0
  80. data/spec/app/mspec/matchers/have_private_instance_method.rb +24 -0
  81. data/spec/app/mspec/matchers/include.rb +32 -0
  82. data/spec/app/mspec/matchers/match_yaml.rb +47 -0
  83. data/spec/app/mspec/matchers/method.rb +14 -0
  84. data/spec/app/mspec/matchers/output.rb +67 -0
  85. data/spec/app/mspec/matchers/output_to_fd.rb +71 -0
  86. data/spec/app/mspec/matchers/raise_error.rb +48 -0
  87. data/spec/app/mspec/matchers/respond_to.rb +24 -0
  88. data/spec/app/mspec/matchers/stringsymboladapter.rb +8 -0
  89. data/spec/app/mspec/mocks.rb +3 -0
  90. data/spec/app/mspec/mocks/mock.rb +159 -0
  91. data/spec/app/mspec/mocks/object.rb +20 -0
  92. data/spec/app/mspec/mocks/proxy.rb +136 -0
  93. data/spec/app/mspec/pp.rb +893 -0
  94. data/spec/app/mspec/runner.rb +15 -0
  95. data/spec/app/mspec/runner/actions.rb +8 -0
  96. data/spec/app/mspec/runner/actions/debug.rb +17 -0
  97. data/spec/app/mspec/runner/actions/filter.rb +40 -0
  98. data/spec/app/mspec/runner/actions/gdb.rb +17 -0
  99. data/spec/app/mspec/runner/actions/tag.rb +133 -0
  100. data/spec/app/mspec/runner/actions/taglist.rb +56 -0
  101. data/spec/app/mspec/runner/actions/tagpurge.rb +56 -0
  102. data/spec/app/mspec/runner/actions/tally.rb +116 -0
  103. data/spec/app/mspec/runner/actions/timer.rb +22 -0
  104. data/spec/app/mspec/runner/context.rb +188 -0
  105. data/spec/app/mspec/runner/example.rb +34 -0
  106. data/spec/app/mspec/runner/exception.rb +43 -0
  107. data/spec/app/mspec/runner/filters.rb +4 -0
  108. data/spec/app/mspec/runner/filters/match.rb +22 -0
  109. data/spec/app/mspec/runner/filters/profile.rb +54 -0
  110. data/spec/app/mspec/runner/filters/regexp.rb +7 -0
  111. data/spec/app/mspec/runner/filters/tag.rb +29 -0
  112. data/spec/app/mspec/runner/formatters.rb +10 -0
  113. data/spec/app/mspec/runner/formatters/describe.rb +24 -0
  114. data/spec/app/mspec/runner/formatters/dotted.rb +98 -0
  115. data/spec/app/mspec/runner/formatters/file.rb +19 -0
  116. data/spec/app/mspec/runner/formatters/html.rb +81 -0
  117. data/spec/app/mspec/runner/formatters/method.rb +93 -0
  118. data/spec/app/mspec/runner/formatters/specdoc.rb +41 -0
  119. data/spec/app/mspec/runner/formatters/spinner.rb +99 -0
  120. data/spec/app/mspec/runner/formatters/summary.rb +11 -0
  121. data/spec/app/mspec/runner/formatters/unit.rb +21 -0
  122. data/spec/app/mspec/runner/formatters/yaml.rb +44 -0
  123. data/spec/app/mspec/runner/mspec.rb +361 -0
  124. data/spec/app/mspec/runner/object.rb +24 -0
  125. data/spec/app/mspec/runner/shared.rb +12 -0
  126. data/spec/app/mspec/runner/tag.rb +32 -0
  127. data/spec/app/mspec/utils/name_map.rb +129 -0
  128. data/spec/app/mspec/utils/options.rb +441 -0
  129. data/spec/app/mspec/utils/ruby_name.rb +8 -0
  130. data/spec/app/mspec/utils/script.rb +220 -0
  131. data/spec/app/mspec/utils/version.rb +53 -0
  132. data/spec/app/mspec/version.rb +5 -0
  133. data/spec/app/spec/fixtures/client_info.txt +2 -0
  134. data/spec/app/spec/fixtures/object_values.txt +90 -0
  135. data/spec/{rho_controller_spec.rb → app/spec/rho_controller_spec.rb} +4 -7
  136. data/spec/{rho_spec.rb → app/spec/rho_spec.rb} +15 -36
  137. data/spec/{rhom_object_factory_spec.rb → app/spec/rhom_object_factory_spec.rb} +108 -72
  138. data/spec/{rhom_spec.rb → app/spec/rhom_spec.rb} +8 -4
  139. data/spec/app/spec/spec_helper.rb +15 -0
  140. data/spec/app/spec/webview_spec.rb +27 -0
  141. data/spec/app/spec_runner.rb +26 -0
  142. data/spec/build.yml +28 -0
  143. data/spec/public/css/base.css +39 -0
  144. data/spec/public/css/blackberry.css +99 -0
  145. data/spec/public/css/iphone.css +392 -0
  146. data/spec/public/css/rho.css +3 -0
  147. data/spec/public/css/xhtml.css +114 -0
  148. data/spec/public/images/IUI_LICENSE.txt +21 -0
  149. data/spec/public/images/backButton.png +0 -0
  150. data/spec/public/images/blueButton.png +0 -0
  151. data/spec/public/images/cancel.png +0 -0
  152. data/spec/public/images/grayButton.png +0 -0
  153. data/spec/public/images/iui-logo-touch-icon.png +0 -0
  154. data/spec/public/images/listArrow.png +0 -0
  155. data/spec/public/images/listArrowSel.png +0 -0
  156. data/spec/public/images/listGroup.png +0 -0
  157. data/spec/public/images/loading.gif +0 -0
  158. data/spec/public/images/pinstripes.png +0 -0
  159. data/spec/public/images/right_button.png +0 -0
  160. data/spec/public/images/selection.png +0 -0
  161. data/spec/public/images/thumb.png +0 -0
  162. data/spec/public/images/toggle.png +0 -0
  163. data/spec/public/images/toggleOn.png +0 -0
  164. data/spec/public/images/toolButton.png +0 -0
  165. data/spec/public/images/toolButton_new.png +0 -0
  166. data/spec/public/images/toolbar.png +0 -0
  167. data/spec/public/images/whiteButton.png +0 -0
  168. data/spec/public/js/application.js +1 -0
  169. data/spec/public/js/jquery-1.2.6.min.js +32 -0
  170. data/spec/public/js/rho.js +4 -0
  171. data/spec/public/js/rhogeolocation-wm.js +59 -0
  172. data/spec/public/js/rhogeolocation.js +11 -0
  173. data/spec/rhoconfig.txt +19 -0
  174. metadata +169 -39
  175. data/History.txt +0 -37
  176. data/README.rdoc +0 -2
  177. data/lib/TestServe.rb +0 -9
  178. data/res/sqlite3/constants.rb +0 -49
  179. data/res/sqlite3/database.rb +0 -715
  180. data/res/sqlite3/driver/dl/api.rb +0 -154
  181. data/res/sqlite3/driver/dl/driver.rb +0 -307
  182. data/res/sqlite3/driver/native/driver.rb +0 -257
  183. data/res/sqlite3/errors.rb +0 -68
  184. data/res/sqlite3/pragmas.rb +0 -271
  185. data/res/sqlite3/resultset.rb +0 -176
  186. data/res/sqlite3/sqlite3_api.rb +0 -0
  187. data/res/sqlite3/statement.rb +0 -230
  188. data/res/sqlite3/translator.rb +0 -109
  189. data/res/sqlite3/value.rb +0 -57
  190. data/res/sqlite3/version.rb +0 -14
  191. data/rhodes.gemspec +0 -18
  192. data/spec/app_manifest.txt +0 -4
  193. data/spec/configs/contact.rb +0 -3
  194. data/spec/configs/employee.rb +0 -3
  195. data/spec/spec.opts +0 -1
  196. data/spec/spec_helper.rb +0 -49
  197. data/spec/stubs.rb +0 -39
  198. data/spec/syncdbtest.sqlite +0 -0
@@ -0,0 +1,21 @@
1
+ require 'mspec/expectations/expectations'
2
+ require 'mspec/runner/formatters/dotted'
3
+
4
+ class UnitdiffFormatter < DottedFormatter
5
+ def finish
6
+ print "\n\n#{@timer.format}\n"
7
+ count = 0
8
+ @exceptions.each do |exc|
9
+ outcome = exc.failure? ? "FAILED" : "ERROR"
10
+ print "\n#{count += 1})\n#{exc.description} #{outcome}\n"
11
+ print exc.message, ": \n"
12
+ print exc.backtrace, "\n"
13
+ end
14
+ print "\n#{@tally.format}\n"
15
+ end
16
+
17
+ def backtrace(exc)
18
+ exc.backtrace && exc.backtrace.join("\n")
19
+ end
20
+ private :backtrace
21
+ end
@@ -0,0 +1,44 @@
1
+ require 'mspec/expectations/expectations'
2
+ require 'mspec/runner/formatters/dotted'
3
+
4
+ class YamlFormatter < DottedFormatter
5
+ def initialize(out=nil)
6
+ @exception = @failure = false
7
+ @exceptions = []
8
+ @count = 0
9
+ @out = $stdout
10
+
11
+ if out.nil?
12
+ @finish = $stdout
13
+ else
14
+ @finish = File.open out, "w"
15
+ end
16
+ end
17
+
18
+ def switch
19
+ @out = @finish
20
+ end
21
+
22
+ def after(state)
23
+ end
24
+
25
+ def finish
26
+ switch
27
+
28
+ print "---\n"
29
+ print "exceptions:\n"
30
+ @exceptions.each do |exc|
31
+ outcome = exc.failure? ? "FAILED" : "ERROR"
32
+ str = "#{exc.description} #{outcome}\n"
33
+ str << exc.message << "\n" << exc.backtrace
34
+ print "- ", str.inspect, "\n"
35
+ end
36
+
37
+ print "time: ", @timer.elapsed, "\n"
38
+ print "files: ", @tally.counter.files, "\n"
39
+ print "examples: ", @tally.counter.examples, "\n"
40
+ print "expectations: ", @tally.counter.expectations, "\n"
41
+ print "failures: ", @tally.counter.failures, "\n"
42
+ print "errors: ", @tally.counter.errors, "\n"
43
+ end
44
+ end
@@ -0,0 +1,361 @@
1
+ require 'mspec/runner/context'
2
+ require 'mspec/runner/exception'
3
+ require 'mspec/runner/tag'
4
+ require 'mspec/fileutils'
5
+ require 'mspec/pp'
6
+
7
+ module MSpec
8
+ @count = 0
9
+ @exc_count = 0
10
+
11
+ @exit = nil
12
+ @start = nil
13
+ @enter = nil
14
+ @before = nil
15
+ @after = nil
16
+ @leave = nil
17
+ @finish = nil
18
+ @exclude = nil
19
+ @include = nil
20
+ @leave = nil
21
+ @load = nil
22
+ @unload = nil
23
+ @current = nil
24
+ @modes = []
25
+ @shared = {}
26
+ @guarded = []
27
+ @exception = nil
28
+ @randomize = nil
29
+ @expectation = nil
30
+ @expectations = false
31
+ @backtrace = false
32
+ @file_count = 0
33
+
34
+ def self.exc_count
35
+ @exc_count
36
+ end
37
+
38
+ def self.count
39
+ @count
40
+ end
41
+
42
+ def self.file_count
43
+ @file_count
44
+ end
45
+
46
+ def self.backtrace=(backtrace)
47
+ @backtrace = backtrace
48
+ end
49
+
50
+ def self.describe(mod, options=nil, &block)
51
+ state = ContextState.new mod, options
52
+ state.parent = current
53
+
54
+ MSpec.register_current state
55
+ state.describe(&block)
56
+ @count+=state.examples.length
57
+ state.process unless state.shared? or current
58
+ end
59
+
60
+ def self.process
61
+ actions :start
62
+ files
63
+ actions :finish
64
+ end
65
+
66
+ def self.files
67
+ return unless files = retrieve(:files)
68
+
69
+ shuffle files if randomize?
70
+ files.each do |file|
71
+ @env = Object.new
72
+ @env.extend MSpec
73
+
74
+ store :file, file
75
+ actions :load
76
+ protect("loading #{file}") { Kernel.load file }
77
+ actions :unload
78
+ end
79
+ end
80
+
81
+ def self.actions(action, *args)
82
+ actions = retrieve(action)
83
+ actions.each { |obj| obj.send action, *args } if actions
84
+ end
85
+
86
+ def self.protect(location, &block)
87
+ begin
88
+ @env.instance_eval(&block)
89
+ return true
90
+ rescue SystemExit
91
+ raise
92
+ rescue Exception => exc
93
+ puts "FAIL: #{current} - #{exc.message}\n" + (@backtrace ? exc.backtrace.join("\n") : "")
94
+ @exc_count+=1
95
+ register_exit 1
96
+ actions :exception, ExceptionState.new(current && current.state, location, exc)
97
+ return false
98
+ end
99
+ end
100
+
101
+ # Guards can be nested, so a stack is necessary to know when we have
102
+ # exited the toplevel guard.
103
+ def self.guard
104
+ @guarded << true
105
+ end
106
+
107
+ def self.unguard
108
+ @guarded.pop
109
+ end
110
+
111
+ def self.guarded?
112
+ not @guarded.empty?
113
+ end
114
+
115
+ # Sets the toplevel ContextState to +state+.
116
+ def self.register_current(state)
117
+ store :current, state
118
+ end
119
+
120
+ # Sets the toplevel ContextState to +nil+.
121
+ def self.clear_current
122
+ store :current, nil
123
+ end
124
+
125
+ # Returns the toplevel ContextState.
126
+ def self.current
127
+ retrieve :current
128
+ end
129
+
130
+ # Stores the shared ContextState keyed by description.
131
+ def self.register_shared(state)
132
+ @shared[state.to_s] = state
133
+ end
134
+
135
+ # Returns the shared ContextState matching description.
136
+ def self.retrieve_shared(desc)
137
+ @shared[desc.to_s]
138
+ end
139
+
140
+ # Stores the exit code used by the runner scripts.
141
+ def self.register_exit(code)
142
+ store :exit, code
143
+ end
144
+
145
+ # Retrieves the stored exit code.
146
+ def self.exit_code
147
+ retrieve(:exit).to_i
148
+ end
149
+
150
+ # Stores the list of files to be evaluated.
151
+ def self.register_files(files)
152
+ @file_count = files.length if files
153
+ store :files, files
154
+ end
155
+
156
+ # Stores one or more substitution patterns for transforming
157
+ # a spec filename into a tags filename, where each pattern
158
+ # has the form:
159
+ #
160
+ # [Regexp, String]
161
+ #
162
+ # See also +tags_file+.
163
+ def self.register_tags_patterns(patterns)
164
+ store :tags_patterns, patterns
165
+ end
166
+
167
+ # Registers an operating mode. Modes recognized by MSpec:
168
+ #
169
+ # :pretend - actions execute but specs are not run
170
+ # :verify - specs are run despite guards and the result is
171
+ # verified to match the expectation of the guard
172
+ # :report - specs that are guarded are reported
173
+ # :unguarded - all guards are forced off
174
+ def self.register_mode(mode)
175
+ modes = retrieve :modes
176
+ modes << mode unless modes.include? mode
177
+ end
178
+
179
+ # Clears all registered modes.
180
+ def self.clear_modes
181
+ store :modes, []
182
+ end
183
+
184
+ # Returns +true+ if +mode+ is registered.
185
+ def self.mode?(mode)
186
+ retrieve(:modes).include? mode
187
+ end
188
+
189
+ def self.retrieve(symbol)
190
+ instance_variable_get :"@#{symbol}"
191
+ end
192
+
193
+ def self.store(symbol, value)
194
+ instance_variable_set :"@#{symbol}", value
195
+ end
196
+
197
+ # This method is used for registering actions that are
198
+ # run at particular points in the spec cycle:
199
+ # :start before any specs are run
200
+ # :load before a spec file is loaded
201
+ # :enter before a describe block is run
202
+ # :before before a single spec is run
203
+ # :add while a describe block is adding examples to run later
204
+ # :expectation before a 'should', 'should_receive', etc.
205
+ # :example after an example block is run, passed the block
206
+ # :exception after an exception is rescued
207
+ # :after after a single spec is run
208
+ # :leave after a describe block is run
209
+ # :unload after a spec file is run
210
+ # :finish after all specs are run
211
+ #
212
+ # Objects registered as actions above should respond to
213
+ # a method of the same name. For example, if an object
214
+ # is registered as a :start action, it should respond to
215
+ # a #start method call.
216
+ #
217
+ # Additionally, there are two "action" lists for
218
+ # filtering specs:
219
+ # :include return true if the spec should be run
220
+ # :exclude return true if the spec should NOT be run
221
+ #
222
+ def self.register(symbol, action)
223
+ unless value = retrieve(symbol)
224
+ value = store symbol, []
225
+ end
226
+ value << action unless value.include? action
227
+ end
228
+
229
+ def self.unregister(symbol, action)
230
+ if value = retrieve(symbol)
231
+ value.delete action
232
+ end
233
+ end
234
+
235
+ def self.randomize(flag=true)
236
+ @randomize = flag
237
+ end
238
+
239
+ def self.randomize?
240
+ @randomize == true
241
+ end
242
+
243
+ def self.shuffle(ary)
244
+ return if ary.empty?
245
+
246
+ size = ary.size
247
+ size.times do |i|
248
+ r = rand(size - i - 1)
249
+ ary[i], ary[r] = ary[r], ary[i]
250
+ end
251
+ end
252
+
253
+ # Records that an expectation has been encountered in an example.
254
+ def self.expectation
255
+ store :expectations, true
256
+ end
257
+
258
+ # Returns true if an expectation has been encountered
259
+ def self.expectation?
260
+ retrieve :expectations
261
+ end
262
+
263
+ # Resets the flag that an expectation has been encountered in an example.
264
+ def self.clear_expectations
265
+ store :expectations, false
266
+ end
267
+
268
+ # Transforms a spec filename into a tags filename by applying each
269
+ # substitution pattern in :tags_pattern. The default patterns are:
270
+ #
271
+ # [%r(/spec/), '/spec/tags/'], [/_spec.rb$/, '_tags.txt']
272
+ #
273
+ # which will perform the following transformation:
274
+ #
275
+ # path/to/spec/class/method_spec.rb => path/to/spec/tags/class/method_tags.txt
276
+ #
277
+ # See also +register_tags_patterns+.
278
+ def self.tags_file
279
+ patterns = retrieve(:tags_patterns) ||
280
+ [[%r(spec/), 'spec/tags/'], [/_spec.rb$/, '_tags.txt']]
281
+ patterns.inject(retrieve(:file).dup) do |file, pattern|
282
+ file.gsub(*pattern)
283
+ end
284
+ end
285
+
286
+ # Returns a list of tags matching any tag string in +keys+ based
287
+ # on the return value of <tt>keys.include?("tag_name")</tt>
288
+ def self.read_tags(keys)
289
+ tags = []
290
+ file = tags_file
291
+ if File.exist? file
292
+ File.open(file, "r") do |f|
293
+ unless File.directory?(f)
294
+ f.each_line do |line|
295
+ line.chomp!
296
+ next if line.empty?
297
+ tag = SpecTag.new line.chomp
298
+ tags << tag if keys.include? tag.tag
299
+ end
300
+ end
301
+ end
302
+ end
303
+ tags
304
+ end
305
+
306
+ # Writes each tag in +tags+ to the tag file. Overwrites the
307
+ # tag file if it exists.
308
+ def self.write_tags(tags)
309
+ file = tags_file
310
+ path = File.dirname file
311
+ FileUtils.mkdir_p path unless File.exist? path
312
+ File.open(file, "w") do |f|
313
+ tags.each { |t| f.puts t }
314
+ end
315
+ end
316
+
317
+ # Writes +tag+ to the tag file if it does not already exist.
318
+ # Returns +true+ if the tag is written, +false+ otherwise.
319
+ def self.write_tag(tag)
320
+ string = tag.to_s
321
+ file = tags_file
322
+ path = File.dirname file
323
+ FileUtils.mkdir_p path unless File.exist? path
324
+ if File.exist? file
325
+ File.open(file, "r") do |f|
326
+ f.each_line { |line| return false if line.chomp == string }
327
+ end
328
+ end
329
+ File.open(file, "a") { |f| f.puts string }
330
+ return true
331
+ end
332
+
333
+ # Deletes +tag+ from the tag file if it exists. Returns +true+
334
+ # if the tag is deleted, +false+ otherwise. Deletes the tag
335
+ # file if it is empty.
336
+ def self.delete_tag(tag)
337
+ deleted = false
338
+ pattern = /#{tag.tag}.*#{Regexp.escape(tag.escape(tag.description))}/
339
+ file = tags_file
340
+ if File.exist? file
341
+ lines = IO.readlines(file)
342
+ File.open(file, "w") do |f|
343
+ lines.each do |line|
344
+ unless pattern =~ line.chomp
345
+ f.puts line unless line.empty?
346
+ else
347
+ deleted = true
348
+ end
349
+ end
350
+ end
351
+ File.delete file unless File.size? file
352
+ end
353
+ return deleted
354
+ end
355
+
356
+ # Removes the tag file associated with a spec file.
357
+ def self.delete_tags
358
+ file = tags_file
359
+ File.delete file if File.exists? file
360
+ end
361
+ end
@@ -0,0 +1,24 @@
1
+ class Object
2
+ def before(at=:each, &block)
3
+ MSpec.current.before at, &block
4
+ end
5
+
6
+ def after(at=:each, &block)
7
+ MSpec.current.after at, &block
8
+ end
9
+
10
+ def describe(mod, msg=nil, options=nil, &block)
11
+ MSpec.describe mod, msg, &block
12
+ end
13
+
14
+ def it(msg, &block)
15
+ MSpec.current.it msg, &block
16
+ end
17
+
18
+ def it_should_behave_like(desc)
19
+ MSpec.current.it_should_behave_like desc
20
+ end
21
+
22
+ alias_method :context, :describe
23
+ alias_method :specify, :it
24
+ end