kosher_bacon 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MGJlZTViMWRiM2ZiY2YzZTYwZjE0ZGViYzZmYTQ5N2VhNWRiNmVkZQ==
5
+ data.tar.gz: !binary |-
6
+ ODFlMzAyN2NjOTQxNjBiZjVjYzhiYTVmYTYzYWM1YTNjZDc1MjE2OQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NTg5ZDM0NzJjYWI1Njg2Zjc5OWUwNGMzOGM5ZTgxYjE5YTk0ODIxNzA3OTk5
10
+ OWNiZTgyY2U5Yzg5Yzg0NTUzYmMxNTAyNjcwY2NkN2UxOGFhMDQ0NDdkNTg4
11
+ ZWM5YjFkODYzZGExYTdjZjI0NTM3NzFmOTIzY2I1ODkwOGU3MDc=
12
+ data.tar.gz: !binary |-
13
+ MWZhMzE0MDYwMTQwNjg5ZmZmMjNhYTA5MzVhNWQ4Mjk1MGRkNDA2ODJlOGI1
14
+ OTQ1ZGVhYWU3MDUzMzE2NjNjNjM4Njc1M2ExYzMzNTNmOGM4YjU0MWI1MDhk
15
+ NjgzMWMxNzM4YTA3NzlkNDFjY2YwNTFlNjc3NzY4ODM5NmMzNjc=
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kosher_bacon.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Dave Lee
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # kosher_bacon
2
+
3
+ kosher_bacon is an adaptor that converts test written for
4
+ MiniTest::Unit (and Test::Unit) into specs that can be run by
5
+ [MacBacon](https://github.com/alloy/MacBacon) on
6
+ [RubyMotion](http://www.rubymotion.com/)
7
+
8
+ ## Status
9
+
10
+ Version: 0.0.1 "Lucky"
11
+
12
+ ## Installation
13
+
14
+ For apps using Bundler:
15
+
16
+ gem 'kosher_bacon'
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ For apps without Bundler, install the gem by hand:
23
+
24
+ $ gem install kosher_bacon
25
+
26
+ And then update your Rakefile like so:
27
+
28
+ require 'kosher_bacon'
29
+
30
+ ## Usage
31
+
32
+ Write your tests in a test/unit style. For learning how to do this,
33
+ feel free to start with the links below, if you trust this README. If
34
+ your eyes slanted as you read the word "trust", enjoy your upcoming
35
+ search engine time.
36
+
37
+ * [WikiBooks: Ruby Programming/Unit testing](http://en.wikibooks.org/wiki/Ruby_Programming/Unit_testing)
38
+ * [A Guide to Testing Rails Applications, Unit Testing your Models](http://guides.rubyonrails.org/testing.html)
39
+
40
+ ## Contributing
41
+
42
+ 1. Fork it
43
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
44
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
45
+ 4. Push to the branch (`git push origin my-new-feature`)
46
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'kosher_bacon/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "kosher_bacon"
8
+ spec.version = KosherBacon::VERSION
9
+ spec.authors = ["Dave Lee"]
10
+ spec.email = ["dave@kastiglione.com"]
11
+ spec.summary = '{MiniTest,Test}::Unit adaptor for RubyMotion'
12
+ spec.description = <<-DESC
13
+ kosher_bacon is an adaptor that converts test written for MiniTest::Unit into
14
+ specs that can be run by MacBacon.
15
+ DESC
16
+ spec.homepage = "https://github.com/kastiglione/#{spec.name}"
17
+ spec.license = "MIT"
18
+
19
+ spec.files = `git ls-files`.split($/)
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "rake"
26
+ end
@@ -0,0 +1,14 @@
1
+ if defined? Motion::Project::App
2
+ Motion::Project::App.setup do |config|
3
+ # Inject helpers that provide a (Mini)?Test::Unit adaptor
4
+ __dir__ = File.dirname(File.realpath(__FILE__))
5
+ helpers = Dir[File.join(__dir__, 'kosher_bacon', 'adaptor.rb')]
6
+ # Place kosher_bacon helpers immediately before the app's spec files.
7
+ # An app's spec files are immediately after RubyMotion's.
8
+ before_app_specs = config.spec_files.index { |file| !file.start_with?(config.motiondir) }
9
+ config.spec_files.insert(before_app_specs, *helpers)
10
+ ENV['output'] = 'test_unit'
11
+ end
12
+ else
13
+ raise 'This file must be required within a RubyMotion project Rakefile.'
14
+ end
@@ -0,0 +1,358 @@
1
+ MiniTest = Test = Module.new
2
+
3
+ module MiniTest
4
+ module Unit
5
+ class TestCase
6
+
7
+ # @see skip
8
+ SKIP = Object.new
9
+
10
+ #
11
+ # Hooks to perform MiniTest -> MacBacon translations
12
+ #
13
+
14
+ def self.inherited(subclass)
15
+ name = subclass.to_s.sub(/^Test/, '').gsub(/([a-z])([A-Z])/, '\1 \2')
16
+ context = describe name do
17
+ before do
18
+ @test_case = subclass.new
19
+ @test_case.setup if @test_case.respond_to?(:setup)
20
+ end
21
+ after do
22
+ @test_case.teardown if @test_case.respond_to?(:teardown)
23
+ @test_case = nil
24
+ end
25
+ end
26
+ subclass.instance_variable_set(:@context, context)
27
+ end
28
+
29
+ def self.method_added(meth)
30
+ return unless meth =~ /^test_/
31
+ name = meth.sub(/^test_/, '').tr('_', ' ')
32
+ @context.it name do
33
+ skipped = catch SKIP do
34
+ @test_case.__send__(meth)
35
+ end
36
+ if skipped
37
+ Bacon::Counter[:requirements] += 1 # Convince Bacon that tests passed
38
+ end
39
+ end
40
+ end
41
+
42
+ #
43
+ # Test control
44
+ #
45
+
46
+ def skip
47
+ throw SKIP, true
48
+ end
49
+
50
+ def pass(_=nil)
51
+ assert true
52
+ end
53
+
54
+ #
55
+ # Assertions
56
+ #
57
+
58
+ # @see assert_operator
59
+ UNDEFINED = Object.new
60
+
61
+ def assert(test, msg=nil)
62
+ if msg.nil?
63
+ test.should.be.true?
64
+ else
65
+ Bacon::Should.new(nil).satisfy(msg) { test }
66
+ end
67
+ true
68
+ end
69
+
70
+ def refute(test, msg=nil)
71
+ if msg.nil?
72
+ test.should.be.false?
73
+ else
74
+ !assert(!test, msg)
75
+ end
76
+ end
77
+
78
+ def assert_empty(obj, msg=nil)
79
+ if msg.nil?
80
+ obj.should.be.empty?
81
+ else
82
+ assert obj.empty?, msg
83
+ end
84
+ end
85
+
86
+ def refute_empty(obj, msg=nil)
87
+ if msg.nil?
88
+ obj.should.not.be.empty?
89
+ else
90
+ refute obj.empty?, msg
91
+ end
92
+ end
93
+
94
+ def assert_equal(exp, act, msg=nil)
95
+ if msg.nil?
96
+ act.should == exp
97
+ else
98
+ assert act == exp, msg
99
+ end
100
+ end
101
+
102
+ def refute_equal(exp, act, msg=nil)
103
+ if msg.nil?
104
+ act.should != exp
105
+ else
106
+ refute act == exp, msg
107
+ end
108
+ end
109
+ alias_method :assert_not_equal, :refute_equal
110
+
111
+ def assert_in_delta(exp, act, delta=0.001, msg=nil)
112
+ if msg.nil?
113
+ act.should.be.close?(exp, delta)
114
+ else
115
+ assert delta >= (act-exp).abs, msg
116
+ end
117
+ end
118
+
119
+ def refute_in_delta(exp, act, delta=0.001, msg=nil)
120
+ if msg.nil?
121
+ act.should.not.be.close?(exp, delta)
122
+ else
123
+ refute delta >= (act-exp).abs, msg
124
+ end
125
+ end
126
+
127
+ def assert_in_epsilon(exp, act, epsilon=0.001, msg=nil)
128
+ delta = epsilon * [exp.abs, act.abs].min
129
+ assert_in_delta exp, act, delta, msg
130
+ end
131
+
132
+ def refute_in_epsilon(exp, act, epsilon=0.001, msg=nil)
133
+ delta = epsilon * [exp.abs, act.abs].min
134
+ refute_in_delta exp, act, delta, msg
135
+ end
136
+
137
+ def assert_includes(collection, obj, msg=nil)
138
+ if msg.nil?
139
+ collection.should.include?(obj)
140
+ else
141
+ assert collection.include?(obj), msg
142
+ end
143
+ end
144
+
145
+ def refute_includes(collection, obj, msg=nil)
146
+ if msg.nil?
147
+ collection.should.not.include?(obj)
148
+ else
149
+ refute collection.include?(obj), msg
150
+ end
151
+ end
152
+
153
+ def assert_instance_of(cls, obj, msg=nil)
154
+ if msg.nil?
155
+ obj.should.be.instance_of?(cls)
156
+ else
157
+ assert obj.instance_of?(cls), msg
158
+ end
159
+ end
160
+
161
+ def refute_instance_of(cls, obj, msg=nil)
162
+ if msg.nil?
163
+ obj.should.not.be.instance_of?(cls)
164
+ else
165
+ refute obj.instance_of?(cls), msg
166
+ end
167
+ end
168
+
169
+ def assert_kind_of(cls, obj, msg=nil)
170
+ if msg.nil?
171
+ obj.should.be.kind_of?(cls)
172
+ else
173
+ assert obj.kind_of?(cls), msg
174
+ end
175
+ end
176
+
177
+ def refute_kind_of(cls, obj, msg=nil)
178
+ if msg.nil?
179
+ obj.should.not.be.kind_of?(cls)
180
+ else
181
+ refute obj.kind_of?(cls), msg
182
+ end
183
+ end
184
+
185
+ def assert_match(matcher, obj, msg=nil)
186
+ matcher = /#{Regexp.escape(matcher)}/ if String === matcher
187
+ if msg.nil?
188
+ obj.should =~ matcher
189
+ else
190
+ assert matcher =~ obj, msg
191
+ end
192
+ end
193
+
194
+ def refute_match(matcher, obj, msg=nil)
195
+ matcher = /#{Regexp.escape(matcher)}/ if String === matcher
196
+ if msg.nil?
197
+ obj.should !~ matcher
198
+ else
199
+ refute matcher =~ obj, msg
200
+ end
201
+ end
202
+ alias_method :assert_no_match, :refute_match
203
+
204
+ def assert_nil(obj, msg=nil)
205
+ if msg.nil?
206
+ obj.should.be.nil?
207
+ else
208
+ assert obj.nil?, msg
209
+ end
210
+ end
211
+
212
+ def refute_nil(obj, msg=nil)
213
+ if msg.nil?
214
+ obj.should.not.be.nil?
215
+ else
216
+ refute obj.nil?, msg
217
+ end
218
+ end
219
+ alias_method :assert_not_nil, :refute_nil
220
+
221
+ def assert_operator(obj1, op, obj2=UNDEFINED, msg=nil)
222
+ args = obj2 == UNDEFINED ? [op] : [op, obj2]
223
+ if msg.nil?
224
+ obj1.should.public_send(*args)
225
+ else
226
+ assert obj1.__send__(*args), msg
227
+ end
228
+ end
229
+
230
+ def refute_operator(obj1, op, obj2=UNDEFINED, msg=nil)
231
+ args = obj2 == UNDEFINED ? [op] : [op, obj2]
232
+ if msg.nil?
233
+ obj1.should.not.public_send(*args)
234
+ else
235
+ refute obj1.__send__(*args), msg
236
+ end
237
+ end
238
+
239
+ def assert_output
240
+ raise NotImplementedError
241
+ end
242
+
243
+ def assert_predicate(obj, predicate, msg=nil)
244
+ if msg.nil?
245
+ obj.should.public_send(predicate)
246
+ else
247
+ assert obj.__send__(predicate), msg
248
+ end
249
+ end
250
+
251
+ def refute_predicate(obj, predicate, msg=nil)
252
+ if msg.nil?
253
+ obj.should.not.public_send(predicate)
254
+ else
255
+ refute obj.__send__(predicate), msg
256
+ end
257
+ end
258
+
259
+ def assert_raises(*exceptions, &block)
260
+ msg = exceptions.last if String === exceptions.last
261
+ if msg.nil?
262
+ block.should.raise?(*exceptions)
263
+ else
264
+ assert block.raise?(*exceptions), msg
265
+ end
266
+ end
267
+ alias_method :assert_raise, :assert_raises
268
+
269
+ def refute_raises(msg=nil)
270
+ msg = exceptions.last if String === exceptions.last
271
+ if msg.nil?
272
+ block.should.not.raise?(*exceptions)
273
+ else
274
+ refute block.raise?(*exceptions), msg
275
+ end
276
+ end
277
+ alias_method :assert_nothing_raised, :refute_raises
278
+
279
+ def assert_respond_to(obj, meth, msg=nil)
280
+ if msg.nil?
281
+ obj.should.respond_to?(meth)
282
+ else
283
+ assert obj.respond_to?(meth), msg
284
+ end
285
+ end
286
+
287
+ def refute_respond_to(obj, meth, msg=nil)
288
+ if msg.nil?
289
+ obj.should.not.respond_to?(meth)
290
+ else
291
+ refute obj.respond_to?(meth), msg
292
+ end
293
+ end
294
+
295
+ def assert_same(exp, act, msg=nil)
296
+ if msg.nil?
297
+ act.should.equal?(exp)
298
+ else
299
+ assert act.equal?(exp), msg
300
+ end
301
+ end
302
+
303
+ def refute_same(exp, act, msg=nil)
304
+ if msg.nil?
305
+ act.should.not.equal?(exp)
306
+ else
307
+ refute act.equal?(exp), msg
308
+ end
309
+ end
310
+ alias_method :assert_not_same, :refute_same
311
+
312
+ def assert_send(send_ary, msg=nil)
313
+ obj, meth, *args = send_ary
314
+ if msg.nil?
315
+ obj.should.public_send(meth, *args)
316
+ else
317
+ assert obj.__send__(meth, *args), msg
318
+ end
319
+ end
320
+
321
+ def refute_send(send_ary, msg=nil)
322
+ obj, meth, *args = send_ary
323
+ if msg.nil?
324
+ obj.should.not.public_send(meth, *args)
325
+ else
326
+ refute obj.__send__(meth, *args), msg
327
+ end
328
+ end
329
+ alias_method :assert_not_send, :refute_send
330
+
331
+ def assert_throws(tag, msg=nil, &block)
332
+ if msg.nil?
333
+ block.should.throw?(tag)
334
+ else
335
+ assert block.throw?(tag), msg
336
+ end
337
+ end
338
+
339
+ def refute_throws(msg=nil)
340
+ if msg.nil?
341
+ block.should.not.throw?(tag)
342
+ else
343
+ refute block.throw?(tag), msg
344
+ end
345
+ end
346
+ alias_method :assert_nothing_thrown, :refute_throws
347
+
348
+ def assert_block(msg=nil, &block)
349
+ if msg.nil?
350
+ block.should.call
351
+ else
352
+ assert yield, msg
353
+ end
354
+ end
355
+
356
+ end
357
+ end
358
+ end
@@ -0,0 +1,3 @@
1
+ module KosherBacon
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kosher_bacon
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dave Lee
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-03-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: ! 'kosher_bacon is an adaptor that converts test written for MiniTest::Unit
42
+ into
43
+
44
+ specs that can be run by MacBacon.
45
+
46
+ '
47
+ email:
48
+ - dave@kastiglione.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - LICENSE.txt
56
+ - README.md
57
+ - Rakefile
58
+ - kosher_bacon.gemspec
59
+ - lib/kosher_bacon.rb
60
+ - lib/kosher_bacon/adaptor.rb
61
+ - lib/kosher_bacon/version.rb
62
+ homepage: https://github.com/kastiglione/kosher_bacon
63
+ licenses:
64
+ - MIT
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.0.0
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: ! '{MiniTest,Test}::Unit adaptor for RubyMotion'
86
+ test_files: []
87
+ has_rdoc: