minitest-bacon 1.0.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.
Binary file
@@ -0,0 +1,24 @@
1
+ # -*- ruby -*-
2
+
3
+ require "autotest/restart"
4
+
5
+ Autotest.add_hook :initialize do |at|
6
+ at.testlib = "minitest/autorun"
7
+ at.add_exception "tmp"
8
+
9
+ [ "Bacon",
10
+ "before/after",
11
+ "before/after::when",
12
+ ">, >=, <, <=, ===",
13
+ "before/after::when nested at a sibling level",
14
+ "before/after::when nested",
15
+ "describe arguments",
16
+ "#should shortcut for #it",
17
+ ].each do |klass|
18
+ at.extra_class_map[klass] = "test/minitest/test_bacon.rb"
19
+ end
20
+ end
21
+
22
+ # Autotest.add_hook :run_command do |at|
23
+ # system "rake build"
24
+ # end
File without changes
@@ -0,0 +1,6 @@
1
+ === 1.0.0 / 2013-05-10
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
@@ -0,0 +1,9 @@
1
+ .autotest
2
+ History.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ lib/minitest/bacon.rb
7
+ test/minitest/test_bacon.rb
8
+ test/minitest/test_nontrue.rb
9
+ test/minitest/test_should.rb
@@ -0,0 +1,97 @@
1
+ = minitest-bacon
2
+
3
+ home :: https://github.com/seattlerb/minitest-bacon
4
+ rdoc :: http://docs.seattlerb.org/minitest-bacon
5
+
6
+ == DESCRIPTION:
7
+
8
+ minitest-bacon extends minitest with bacon-like functionality. It
9
+ should allow you to bridge 90+% of your bacon specs over to minitest.
10
+
11
+ == FEATURES/PROBLEMS:
12
+
13
+ * Passes almost all of bacon's tests.
14
+ * Where they don't it is documented why they don't.
15
+
16
+ === Differences with Bacon:
17
+
18
+ * Only one before/after block per describe (ie, they're just methods again).
19
+ * Object#should doesn't work outside of describe. Not sure what that's for.
20
+ * Tests are no longer order dependent. This is a Good Thing™.
21
+
22
+ == SYNOPSIS:
23
+
24
+ require "minitest/bacon"
25
+
26
+ describe "A new array" do
27
+ before do
28
+ @ary = Array.new
29
+ end
30
+
31
+ it "should be empty" do
32
+ @ary.should.be.empty
33
+ @ary.should.not.include 1
34
+ end
35
+
36
+ it "should have zero size" do
37
+ @ary.size.should.equal 0
38
+ @ary.size.should.be.close 0.1, 0.5
39
+ end
40
+
41
+ it "should raise on trying fetch any index" do
42
+ lambda { @ary.fetch 0 }.
43
+ should.raise(IndexError).
44
+ message.should.match(/out of array/)
45
+
46
+ # Alternatively:
47
+ should.raise(IndexError) { @ary.fetch 0 }
48
+ end
49
+
50
+ it "should have an object identity" do
51
+ @ary.should.not.be.same_as Array.new
52
+ end
53
+
54
+ # Custom assertions are trivial to do, they are lambdas returning a
55
+ # boolean vale:
56
+ palindrome = lambda { |obj| obj == obj.reverse }
57
+ it "should be a palindrome" do
58
+ @ary.should.be.a palindrome
59
+ end
60
+
61
+ it "should have super powers" do
62
+ should.flunk "no super powers found"
63
+ end
64
+ end
65
+
66
+ == REQUIREMENTS:
67
+
68
+ * minitest
69
+
70
+ == INSTALL:
71
+
72
+ * sudo gem install minitest-bacon
73
+
74
+ == LICENSE:
75
+
76
+ (The MIT License)
77
+
78
+ Copyright (c) Ryan Davis, seattle.rb
79
+
80
+ Permission is hereby granted, free of charge, to any person obtaining
81
+ a copy of this software and associated documentation files (the
82
+ 'Software'), to deal in the Software without restriction, including
83
+ without limitation the rights to use, copy, modify, merge, publish,
84
+ distribute, sublicense, and/or sell copies of the Software, and to
85
+ permit persons to whom the Software is furnished to do so, subject to
86
+ the following conditions:
87
+
88
+ The above copyright notice and this permission notice shall be
89
+ included in all copies or substantial portions of the Software.
90
+
91
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
92
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
93
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
94
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
95
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
96
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
97
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,28 @@
1
+ # -*- ruby -*-
2
+
3
+ require "rubygems"
4
+ require "hoe"
5
+
6
+ Hoe.plugin :isolate
7
+ Hoe.plugin :seattlerb
8
+
9
+ # Hoe.plugin :compiler
10
+ # Hoe.plugin :doofus
11
+ # Hoe.plugin :email
12
+ # Hoe.plugin :gem_prelude_sucks
13
+ # Hoe.plugin :git
14
+ # Hoe.plugin :inline
15
+ # Hoe.plugin :isolate
16
+ # Hoe.plugin :minitest
17
+ # Hoe.plugin :perforce
18
+ # Hoe.plugin :racc
19
+ # Hoe.plugin :rcov
20
+ # Hoe.plugin :rubyforge
21
+ # Hoe.plugin :seattlerb
22
+
23
+ Hoe.spec "minitest-bacon" do
24
+ developer "Ryan Davis", "ryand-ruby@zenspider.com"
25
+ license "MIT"
26
+ end
27
+
28
+ # vim: syntax=ruby
@@ -0,0 +1,178 @@
1
+ #!/usr/bin/ruby -w
2
+
3
+ ENV["MT_NO_EXPECTATIONS"] = "1"
4
+ require "minitest/autorun"
5
+
6
+ module Minitest
7
+ def self.poke
8
+ MiniTest::Spec.current.assertions += 1
9
+ end
10
+
11
+ def self.count
12
+ MiniTest::Spec.current.assertions
13
+ end
14
+ end
15
+
16
+ class Minitest::ValueMonad
17
+ VERSION = "1.0.0"
18
+
19
+ instance_methods.each { |name| undef_method name if name =~ /\?|^\W+$/ }
20
+
21
+ def initialize v
22
+ @val = v
23
+ @pos = true
24
+ end
25
+
26
+ def not(*args, &block)
27
+ @pos = !@pos
28
+
29
+ be(*args, &block)
30
+ end
31
+
32
+ def be(*args, &block)
33
+ if args.empty?
34
+ self
35
+ else
36
+ block = args.shift unless block_given?
37
+ block ||= lambda { @val.send(*args) }
38
+ assert(&block)
39
+ end
40
+ end
41
+
42
+ alias a be
43
+ alias an be
44
+
45
+ def be_true
46
+ assert { @val }
47
+ end
48
+
49
+ def be_false
50
+ assert { !@val }
51
+ end
52
+
53
+ def assert msg = nil
54
+ r = yield @val
55
+
56
+ Minitest.poke
57
+ msg ||= "boom"
58
+ raise MiniTest::Assertion, msg if @pos ^ r
59
+
60
+ r
61
+ end
62
+
63
+ def method_missing(name, *args, &block)
64
+ name = name.to_s.sub(/^be_/, '')
65
+ name = "#{name}?" if name =~ /\w[^?]\z/
66
+
67
+ msg = @pos ? "" : "not"
68
+ msg << @val.inspect << ".#{name}"
69
+ msg << "(#{args.map(&:inspect).join ", "}) failed"
70
+
71
+ assert(msg) { @val.__send__(name, *args, &block) }
72
+ end
73
+
74
+ def equal(value) self == value end
75
+ def match(value) self =~ value end
76
+ def identical_to(value) self.equal? value end
77
+ alias same_as identical_to
78
+
79
+ def raise?(*args, &block); block.raise?(*args); end
80
+ def throw?(*args, &block); block.throw?(*args); end
81
+ def change?(*args, &block); block.change?(*args); end
82
+
83
+ def flunk(reason="Flunked")
84
+ raise Minitest::Assertion, reason
85
+ end
86
+ end
87
+
88
+ class Minitest::SelfMonad < Minitest::ValueMonad
89
+ def initialize
90
+ super self
91
+ @depth = 0
92
+ end
93
+
94
+ def method_missing(name, *args, &block) # hacky, saves my butt on StackDepth
95
+ @depth += 1
96
+ super unless @depth > 1
97
+ ensure
98
+ @depth -= 1
99
+ end
100
+ end
101
+
102
+ class Minitest::Spec
103
+ class << self
104
+ alias should it
105
+ end
106
+
107
+ def should
108
+ Minitest::SelfMonad.new
109
+ end
110
+
111
+ def self.behaves_like(*names)
112
+ names.each do |name|
113
+ mod = Minitest::Shared[name]
114
+ raise NameError, "Unknown shared module #{name}" unless mod
115
+ include mod
116
+ end
117
+ end
118
+ end
119
+
120
+ Minitest::Shared = {}
121
+
122
+ class Object
123
+ alias eq? ==
124
+
125
+ def true?
126
+ !!self
127
+ end
128
+
129
+ def should(*args, &block)
130
+ Minitest::ValueMonad.new(self).be(*args, &block)
131
+ end
132
+
133
+ def shared(name, &block)
134
+ Minitest::Shared[name] = Module.new do |m|
135
+ (class << m; self; end).send :define_method, :included do |cls|
136
+ cls.instance_eval(&block)
137
+ end
138
+ end
139
+ end
140
+ end
141
+
142
+ class Proc
143
+ def raise?(*exceptions)
144
+ exceptions = [RuntimeError] if exceptions.empty?
145
+ call
146
+ rescue *exceptions => e
147
+ e
148
+ else
149
+ false
150
+ end
151
+
152
+ def throw?(sym)
153
+ not catch(sym) {
154
+ call
155
+ return false
156
+ }
157
+ return true
158
+ end
159
+
160
+ def change?
161
+ before = yield
162
+ call
163
+ after = yield
164
+ before != after
165
+ end
166
+ end
167
+
168
+ class Numeric
169
+ alias lt? <
170
+ alias gt? >
171
+ alias gte? >=
172
+ alias less_than? <
173
+ alias greater_than? >
174
+
175
+ def close?(to, delta = 0.001)
176
+ (self - to).abs <= delta rescue false
177
+ end
178
+ end
@@ -0,0 +1,449 @@
1
+ require "minitest/bacon"
2
+
3
+ class Minitest::ValueMonad # only for keeping tests closer to bacon
4
+ alias satisfy assert
5
+ end
6
+
7
+ # Hooray for meta-testing.
8
+ module MetaTests
9
+ def succeed
10
+ lambda { |block|
11
+ block.should.not.raise MiniTest::Assertion
12
+ true
13
+ }
14
+ end
15
+
16
+ def fail
17
+ lambda { |block|
18
+ block.should.raise MiniTest::Assertion
19
+ true
20
+ }
21
+ end
22
+
23
+ def equal_string(x)
24
+ lambda { |s|
25
+ x == s.to_s
26
+ }
27
+ end
28
+ end
29
+
30
+ describe "Bacon" do
31
+ include MetaTests
32
+
33
+ it "should have should.satisfy" do
34
+ lambda { should.satisfy { 1 == 1 } }.should succeed
35
+ lambda { should.satisfy { 1 } }.should succeed
36
+
37
+ lambda { should.satisfy { 1 != 1 } }.should fail
38
+ lambda { should.satisfy { false } }.should fail
39
+ lambda { should.satisfy { false } }.should fail
40
+
41
+ lambda { 1.should.satisfy { |n| n % 2 == 0 } }.should fail
42
+ lambda { 2.should.satisfy { |n| n % 2 == 0 } }.should succeed
43
+ end
44
+
45
+ it "should have should.==" do
46
+ lambda { "string1".should == "string1" }.should succeed
47
+ lambda { "string1".should == "string2" }.should fail
48
+
49
+ lambda { [1,2,3].should == [1,2,3] }.should succeed
50
+ lambda { [1,2,3].should == [1,2,4] }.should fail
51
+ end
52
+
53
+ it "should have should.equal" do
54
+ lambda { "string1".should == "string1" }.should succeed
55
+ lambda { "string1".should == "string2" }.should fail
56
+ lambda { "1".should == 1 }.should fail
57
+
58
+ lambda { "string1".should.equal "string1" }.should succeed
59
+ lambda { "string1".should.equal "string2" }.should fail
60
+ lambda { "1".should.equal 1 }.should fail
61
+ end
62
+
63
+ it "should have should.raise" do
64
+ lambda { lambda { raise "Error" }.should.raise }.should succeed
65
+ lambda { lambda { raise "Error" }.should.raise RuntimeError }.should succeed
66
+ lambda { lambda { raise "Error" }.should.not.raise }.should fail
67
+ lambda { lambda { raise "Error" }.should.not.raise(RuntimeError) }.should fail
68
+
69
+ lambda { lambda { 1 + 1 }.should.raise }.should fail
70
+ lambda {
71
+ lambda { raise "Error" }.should.raise(Interrupt)
72
+ }.should.raise
73
+ end
74
+
75
+ it "should have should.change" do
76
+ lambda { lambda {}.should.change { sleep 0.001; Time.now } }.should succeed
77
+
78
+ lambda {
79
+ i = 1
80
+ lambda { i *= 2 }.should.change { i }
81
+ }.should succeed
82
+
83
+ lambda {
84
+ i = 0
85
+ lambda { i *= 2 }.should.change { i }
86
+ }.should fail
87
+
88
+ ##
89
+ # top-level should is an alias for "it", not a blank value monad.
90
+
91
+ # lambda { should.change { sleep 0.001; Time.now } }.should succeed
92
+ # lambda { should.change { 42 } }.should fail
93
+ end
94
+
95
+ it "should have should.raise with a block" do
96
+ lambda { should.raise { raise "Error" } }.should succeed
97
+ lambda { should.raise(RuntimeError) { raise "Error" } }.should succeed
98
+ lambda { should.not.raise { raise "Error" } }.should fail
99
+ lambda { should.not.raise(RuntimeError) { raise "Error" } }.should fail
100
+
101
+ lambda { should.raise { 1 + 1 } }.should fail
102
+
103
+ lambda {
104
+ should.raise(Interrupt) { raise "Error" }
105
+ }.should.raise
106
+ end
107
+
108
+ it "should have a should.raise should return the exception" do
109
+ ex = lambda { raise "foo!" }.should.raise
110
+ ex.should.be.kind_of RuntimeError
111
+ ex.message.should =~ /foo/
112
+ end
113
+
114
+ it "should have should.be.an.instance_of" do
115
+ lambda { "string".should.be.instance_of String }.should succeed
116
+ lambda { "string".should.be.instance_of Hash }.should fail
117
+
118
+ lambda { "string".should.be.an.instance_of String }.should succeed
119
+ lambda { "string".should.be.an.instance_of Hash }.should fail
120
+ end
121
+
122
+ it "should have should.be.nil" do
123
+ lambda { nil.should.be.nil }.should succeed
124
+ lambda { nil.should.not.be.nil }.should fail
125
+ lambda { "foo".should.be.nil }.should fail
126
+ lambda { "foo".should.not.be.nil }.should succeed
127
+ end
128
+
129
+ it "should have should.include" do
130
+ lambda { [1,2,3].should.include 2 }.should succeed
131
+ lambda { [1,2,3].should.include 4 }.should fail
132
+
133
+ lambda { {1 =>2, 3=>4}.should.include 1 }.should succeed
134
+ lambda { {1 =>2, 3=>4}.should.include 2 }.should fail
135
+ end
136
+
137
+ it "should have should.be.a.kind_of" do
138
+ lambda { Array.should.be.kind_of Module }.should succeed
139
+ lambda { "string".should.be.kind_of Object }.should succeed
140
+ lambda { 1.should.be.kind_of Comparable }.should succeed
141
+
142
+ lambda { Array.should.be.a.kind_of Module }.should succeed
143
+
144
+ lambda { "string".should.be.a.kind_of Class }.should fail
145
+ end
146
+
147
+ it "should have should.match" do
148
+ lambda { "string".should.match(/strin./) }.should succeed
149
+ lambda { "string".should =~ /strin./ }.should succeed
150
+
151
+ lambda { "string".should.match(/slin./) }.should fail
152
+ lambda { "string".should =~ /slin./ }.should fail
153
+ end
154
+
155
+ it "should have should.not.raise" do
156
+ lambda { lambda { 1 + 1 }.should.not.raise }.should succeed
157
+ lambda { lambda { 1 + 1 }.should.not.raise(Interrupt) }.should succeed
158
+
159
+ lambda {
160
+ lambda {
161
+ lambda {
162
+ Kernel.raise ZeroDivisionError.new("ArgumentError")
163
+ }.should.not.raise(RuntimeError, Comparable)
164
+ }.should.raise ZeroDivisionError
165
+ }.should succeed
166
+
167
+ lambda { lambda { raise "Error" }.should.not.raise }.should fail
168
+ end
169
+
170
+ it "should have should.throw" do
171
+ lambda { lambda { throw :foo }.should.throw(:foo) }.should succeed
172
+
173
+ lambda { lambda { :foo }.should.throw(:foo) }.should fail
174
+
175
+ should.throw(:foo) { throw :foo }
176
+ end
177
+
178
+ it "should have should.not.satisfy" do
179
+ lambda { should.not.satisfy { 1 == 2 } }.should succeed
180
+ lambda { should.not.satisfy { 1 == 1 } }.should fail
181
+ end
182
+
183
+ it "should have should.not.equal" do
184
+ lambda { "string1".should.not == "string2" }.should succeed
185
+ lambda { "string1".should.not == "string1" }.should fail
186
+ end
187
+
188
+ it "should have should.not.match" do
189
+ lambda { "string".should.not.match(/sling/) }.should succeed
190
+ lambda { "string".should.not.match(/string/) }.should fail
191
+
192
+ ##
193
+ # doesn't coerce strings to regexps so that it can work with
194
+ # anything that implements =~
195
+
196
+ # lambda { "string".should.not.match("strin") }.should fail
197
+
198
+ lambda { "string".should.not =~ /sling/ }.should succeed
199
+ lambda { "string".should.not =~ /string/ }.should fail
200
+
201
+ ##
202
+ # doesn't coerce strings to regexps so that it can work with
203
+ # anything that implements =~
204
+
205
+ # lambda { "string".should.not =~ "strin" }.should fail
206
+ end
207
+
208
+ it "should have should.be.identical_to/same_as" do
209
+ lambda { s = "string"; s.should.be.identical_to s }.should succeed
210
+ lambda { "string".should.be.identical_to "string" }.should fail
211
+
212
+ lambda { s = "string"; s.should.be.same_as s }.should succeed
213
+ lambda { "string".should.be.same_as "string" }.should fail
214
+ end
215
+
216
+ it "should have should.respond_to" do
217
+ lambda { "foo".should.respond_to :to_s }.should succeed
218
+ lambda { 5.should.respond_to :to_str }.should fail
219
+ lambda { :foo.should.respond_to :nx }.should fail
220
+ end
221
+
222
+ it "should have should.be.close" do
223
+ lambda { 1.4.should.be.close 1.4, 0 }.should succeed
224
+ lambda { 0.4.should.be.close 0.5, 0.1 }.should succeed
225
+
226
+ lambda { 0.4.should.be.close 0.5, 0.05 }.should fail
227
+ lambda { 0.4.should.be.close Object.new, 0.1 }.should fail
228
+ lambda { 0.4.should.be.close 0.5, -0.1 }.should fail
229
+ end
230
+
231
+ it "should support multiple negation" do
232
+ lambda { 1.should.equal 1 }.should succeed
233
+ lambda { 1.should.not.equal 1 }.should fail
234
+ lambda { 1.should.not.not.equal 1 }.should succeed
235
+ lambda { 1.should.not.not.not.equal 1 }.should fail
236
+
237
+ lambda { 1.should.equal 2 }.should fail
238
+ lambda { 1.should.not.equal 2 }.should succeed
239
+ lambda { 1.should.not.not.equal 2 }.should fail
240
+ lambda { 1.should.not.not.not.equal 2 }.should succeed
241
+ end
242
+
243
+ it "should have should.<predicate>" do
244
+ lambda { [].should.be.empty }.should succeed
245
+ lambda { [1,2,3].should.not.be.empty }.should succeed
246
+
247
+ lambda { [].should.not.be.empty }.should fail
248
+ lambda { [1,2,3].should.be.empty }.should fail
249
+
250
+ lambda { {1=>2, 3=>4}.should.has_key 1 }.should succeed
251
+ lambda { {1=>2, 3=>4}.should.not.has_key 2 }.should succeed
252
+
253
+ lambda { nil.should.bla }.should.raise(NoMethodError)
254
+ lambda { nil.should.not.bla }.should.raise(NoMethodError)
255
+ end
256
+
257
+ it "should have should <operator> (>, >=, <, <=, ===)" do
258
+ lambda { 2.should.be > 1 }.should succeed
259
+ lambda { 1.should.be > 2 }.should fail
260
+
261
+ lambda { 1.should.be < 2 }.should succeed
262
+ lambda { 2.should.be < 1 }.should fail
263
+
264
+ lambda { 2.should.be >= 1 }.should succeed
265
+ lambda { 2.should.be >= 2 }.should succeed
266
+ lambda { 2.should.be >= 2.1 }.should fail
267
+
268
+ lambda { 2.should.be <= 1 }.should fail
269
+ lambda { 2.should.be <= 2 }.should succeed
270
+ lambda { 2.should.be <= 2.1 }.should succeed
271
+
272
+ lambda { Array.should === [1,2,3] }.should succeed
273
+ lambda { Integer.should === [1,2,3] }.should fail
274
+
275
+ lambda { /foo/.should === "foobar" }.should succeed
276
+ lambda { "foobar".should === /foo/ }.should fail
277
+ end
278
+
279
+ it "should allow for custom shoulds" do
280
+ lambda { (1+1).should equal_string("2") }.should succeed
281
+ lambda { (1+2).should equal_string("2") }.should fail
282
+
283
+ lambda { (1+1).should.be equal_string("2") }.should succeed
284
+ lambda { (1+2).should.be equal_string("2") }.should fail
285
+
286
+ lambda { (1+1).should.not equal_string("2") }.should fail
287
+ lambda { (1+2).should.not equal_string("2") }.should succeed
288
+ lambda { (1+2).should.not.not equal_string("2") }.should fail
289
+
290
+ lambda { (1+1).should.not.be equal_string("2") }.should fail
291
+ lambda { (1+2).should.not.be equal_string("2") }.should succeed
292
+ end
293
+
294
+ it "should have should.flunk" do
295
+ lambda { should.flunk }.should fail
296
+ lambda { should.flunk "yikes" }.should fail
297
+ end
298
+ end
299
+
300
+ describe "before/after" do
301
+ before do
302
+ @a = 1
303
+ @b = 2
304
+ end
305
+
306
+ ##
307
+ # Skipped because we don't support multiple befores, because
308
+ # they're just setup methods.
309
+
310
+ # before do
311
+ # @a = 2
312
+ # end
313
+
314
+ after do
315
+ @a.should.equal 1
316
+ # @a = 3
317
+ end
318
+
319
+ ##
320
+ # Skipped because we don't support multiple afters, because
321
+ # they're just teardown methods.
322
+
323
+ # after do
324
+ # @a.should.equal 3
325
+ # end
326
+
327
+ it "should run in the right order" do
328
+ @a.should.equal 1
329
+ @b.should.equal 2
330
+ end
331
+
332
+ describe "when nested" do
333
+ before do
334
+ @c = 5
335
+ end
336
+
337
+ it "should run from higher level" do
338
+ @a.should.equal 1
339
+ @b.should.equal 2
340
+ end
341
+
342
+ it "should run at the nested level" do
343
+ @c.should.equal 5
344
+ end
345
+
346
+ ##
347
+ # Skipped because we don't support multiple befores, because
348
+ # they're just setup methods.
349
+
350
+ # before do
351
+ # @a = 5
352
+ # end
353
+
354
+ # it "should run in the right order" do
355
+ # @a.should.equal 5
356
+ # @a = 2
357
+ # end
358
+ end
359
+
360
+ it "should not run from lower level" do
361
+ @c ||= nil # remove uninitialized warning
362
+ @c.should.be.nil
363
+ end
364
+
365
+ describe "when nested at a sibling level" do
366
+ it "should not run from sibling level" do
367
+ @c ||= nil # remove uninitialized warning
368
+ @c.should.be.nil
369
+ end
370
+ end
371
+ end
372
+
373
+ shared "a shared context" do
374
+ it "gets called where it is included" do
375
+ true.should.be.true
376
+ end
377
+ end
378
+
379
+ shared "another shared context" do
380
+ it "can access data" do
381
+ @magic.should.be.equal 42
382
+ end
383
+ end
384
+
385
+ describe "shared/behaves_like" do
386
+ behaves_like "a shared context"
387
+
388
+ ctx = self
389
+ it "raises NameError when the context is not found" do
390
+ lambda {
391
+ ctx.behaves_like "whoops"
392
+ }.should.raise NameError
393
+ end
394
+
395
+ behaves_like "a shared context"
396
+
397
+ before {
398
+ @magic = 42
399
+ }
400
+ behaves_like "another shared context"
401
+ end
402
+
403
+ describe "Methods" do
404
+ def the_meaning_of_life
405
+ 42
406
+ end
407
+
408
+ it "should be accessible in a test" do
409
+ the_meaning_of_life.should == 42
410
+ end
411
+
412
+ describe "when in a sibling context" do
413
+ it "should be accessible in a test" do
414
+ the_meaning_of_life.should == 42
415
+ end
416
+ end
417
+ end
418
+
419
+ ##
420
+ # Skipped because we don't have Bacon::Context. Everything just becomes a test.
421
+
422
+ # describe 'describe arguments' do
423
+ #
424
+ # def check(ctx,name)
425
+ # ctx.should.be.an.instance_of Bacon::Context
426
+ # ctx.instance_variable_get('@name').should == name
427
+ # end
428
+ #
429
+ # it 'should work with string' do
430
+ # check(describe('string') {},'string')
431
+ # end
432
+ #
433
+ # it 'should work with symbols' do
434
+ # check(describe(:behaviour) {},'behaviour')
435
+ # end
436
+ #
437
+ # it 'should work with modules' do
438
+ # check(describe(Bacon) {},'Bacon')
439
+ # end
440
+ #
441
+ # it 'should work with namespaced modules' do
442
+ # check(describe(Bacon::Context) {},'Bacon::Context')
443
+ # end
444
+ #
445
+ # it 'should work with multiple arguments' do
446
+ # check(describe(Bacon::Context, :empty) {},'Bacon::Context empty')
447
+ # end
448
+ #
449
+ # end
@@ -0,0 +1,16 @@
1
+ require "minitest/bacon"
2
+
3
+ # $false_is_not_true = false.should.not.be.true
4
+ # $nil_is_not_true = nil.should.not.be.true
5
+ #
6
+ # describe 'A non-true value' do
7
+ # it 'should pass negated tests inside specs' do
8
+ # false.should.not.be.true
9
+ # nil.should.not.be.true
10
+ # end
11
+ #
12
+ # # it 'should pass negated tests outside specs' do
13
+ # # $false_is_not_true.should.be.true
14
+ # # $nil_is_not_true.should.be.true
15
+ # # end
16
+ # end
@@ -0,0 +1,35 @@
1
+ require "minitest/bacon"
2
+
3
+ describe "#should shortcut for #it" do
4
+
5
+ should "be called" do
6
+ @called = true
7
+ @called.should.be == true
8
+ end
9
+
10
+ should "save some characters by typing should" do
11
+ lambda { should.assert { 1 == 1 } }.should.not.raise
12
+ end
13
+
14
+ should "save characters even on failure" do
15
+ lambda { should.assert { 1 == 2 } }.should.raise MiniTest::Assertion
16
+ end
17
+
18
+ should "work nested" do
19
+ should.assert {1==1}
20
+ end
21
+
22
+ ##
23
+ # Skipped because that's not how we do counting. minitest 5 will clean this up
24
+
25
+ # count = Bacon::Counter[:specifications]
26
+ # should "add new specifications" do
27
+ # # XXX this should +=1 but it's +=2
28
+ # (count+1).should == Bacon::Counter[:specifications]
29
+ # end
30
+
31
+ # should "have been called" do
32
+ # @called.should.be == true
33
+ # end
34
+
35
+ end
metadata ADDED
@@ -0,0 +1,147 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minitest-bacon
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Ryan Davis
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain:
17
+ - |
18
+ -----BEGIN CERTIFICATE-----
19
+ MIIDPjCCAiagAwIBAgIBADANBgkqhkiG9w0BAQUFADBFMRMwEQYDVQQDDApyeWFu
20
+ ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
21
+ GRYDY29tMB4XDTA5MDMwNjE4NTMxNVoXDTEwMDMwNjE4NTMxNVowRTETMBEGA1UE
22
+ AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
23
+ JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
24
+ b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
25
+ taCPaLmfYIaFcHHCSY4hYDJijRQkLxPeB3xbOfzfLoBDbjvx5JxgJxUjmGa7xhcT
26
+ oOvjtt5P8+GSK9zLzxQP0gVLS/D0FmoE44XuDr3iQkVS2ujU5zZL84mMNqNB1znh
27
+ GiadM9GHRaDiaxuX0cIUBj19T01mVE2iymf9I6bEsiayK/n6QujtyCbTWsAS9Rqt
28
+ qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
29
+ gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
30
+ HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBBQUAA4IB
31
+ AQAY59gYvDxqSqgC92nAP9P8dnGgfZgLxP237xS6XxFGJSghdz/nI6pusfCWKM8m
32
+ vzjjH2wUMSSf3tNudQ3rCGLf2epkcU13/rguI88wO6MrE0wi4ZqLQX+eZQFskJb/
33
+ w6x9W1ur8eR01s397LSMexySDBrJOh34cm2AlfKr/jokKCTwcM0OvVZnAutaovC0
34
+ l1SVZ0ecg88bsWHA0Yhh7NFxK1utWoIhtB6AFC/+trM0FQEB/jZkIS8SaNzn96Rl
35
+ n0sZEf77FLf5peR8TP/PtmIg7Cyqz23sLM4mCOoTGIy5OcZ8TdyiyINUHtb5ej/T
36
+ FBHgymkyj/AOSqKRIpXPhjC6
37
+ -----END CERTIFICATE-----
38
+
39
+ date: 2013-05-10 00:00:00 Z
40
+ dependencies:
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ prerelease: false
44
+ requirement: &id001 !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ~>
48
+ - !ruby/object:Gem::Version
49
+ hash: 31
50
+ segments:
51
+ - 5
52
+ - 0
53
+ version: "5.0"
54
+ type: :development
55
+ version_requirements: *id001
56
+ - !ruby/object:Gem::Dependency
57
+ name: rdoc
58
+ prerelease: false
59
+ requirement: &id002 !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ~>
63
+ - !ruby/object:Gem::Version
64
+ hash: 27
65
+ segments:
66
+ - 4
67
+ - 0
68
+ version: "4.0"
69
+ type: :development
70
+ version_requirements: *id002
71
+ - !ruby/object:Gem::Dependency
72
+ name: hoe
73
+ prerelease: false
74
+ requirement: &id003 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ hash: 11
80
+ segments:
81
+ - 3
82
+ - 6
83
+ version: "3.6"
84
+ type: :development
85
+ version_requirements: *id003
86
+ description: |-
87
+ minitest-bacon extends minitest with bacon-like functionality. It
88
+ should allow you to bridge 90+% of your bacon specs over to minitest.
89
+ email:
90
+ - ryand-ruby@zenspider.com
91
+ executables: []
92
+
93
+ extensions: []
94
+
95
+ extra_rdoc_files:
96
+ - History.txt
97
+ - Manifest.txt
98
+ - README.txt
99
+ files:
100
+ - .autotest
101
+ - History.txt
102
+ - Manifest.txt
103
+ - README.txt
104
+ - Rakefile
105
+ - lib/minitest/bacon.rb
106
+ - test/minitest/test_bacon.rb
107
+ - test/minitest/test_nontrue.rb
108
+ - test/minitest/test_should.rb
109
+ - .gemtest
110
+ homepage: https://github.com/seattlerb/minitest-bacon
111
+ licenses:
112
+ - MIT
113
+ post_install_message:
114
+ rdoc_options:
115
+ - --main
116
+ - README.txt
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ hash: 3
125
+ segments:
126
+ - 0
127
+ version: "0"
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ hash: 3
134
+ segments:
135
+ - 0
136
+ version: "0"
137
+ requirements: []
138
+
139
+ rubyforge_project: minitest-bacon
140
+ rubygems_version: 1.8.25
141
+ signing_key:
142
+ specification_version: 3
143
+ summary: minitest-bacon extends minitest with bacon-like functionality
144
+ test_files:
145
+ - test/minitest/test_bacon.rb
146
+ - test/minitest/test_nontrue.rb
147
+ - test/minitest/test_should.rb
Binary file