spec 5.0.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.autotest +34 -0
  3. data/.gitignore +3 -0
  4. data/History.txt +911 -0
  5. data/Manifest.txt +26 -0
  6. data/README.txt +497 -0
  7. data/Rakefile +214 -0
  8. data/design_rationale.rb +52 -0
  9. data/lib/hoe/minitest.rb +26 -0
  10. data/lib/minitest/assertions.rb +649 -0
  11. data/lib/minitest/autorun.rb +12 -0
  12. data/lib/minitest/benchmark.rb +423 -0
  13. data/lib/minitest/expectations.rb +268 -0
  14. data/lib/minitest/hell.rb +11 -0
  15. data/lib/minitest/mock.rb +220 -0
  16. data/lib/minitest/parallel_each.rb +120 -0
  17. data/lib/minitest/pride.rb +4 -0
  18. data/lib/minitest/pride_plugin.rb +143 -0
  19. data/lib/minitest/spec.rb +292 -0
  20. data/lib/minitest/test.rb +272 -0
  21. data/lib/minitest/unit.rb +45 -0
  22. data/lib/minitest.rb +839 -0
  23. data/lib/spec.rb +3 -0
  24. data/readme.md +7 -0
  25. data/release_notes.md +49 -0
  26. data/spec.gemspec +36 -0
  27. data/test/manual/appium.rb +14 -0
  28. data/test/manual/appium_after_last.rb +24 -0
  29. data/test/manual/appium_before_first.rb +23 -0
  30. data/test/manual/assert.rb +61 -0
  31. data/test/manual/before_first_0.rb +27 -0
  32. data/test/manual/before_first_1.rb +29 -0
  33. data/test/manual/debug.rb +37 -0
  34. data/test/manual/do_end.rb +31 -0
  35. data/test/manual/raise.rb +61 -0
  36. data/test/manual/run2.rb +74 -0
  37. data/test/manual/run3.rb +91 -0
  38. data/test/manual/setup.rb +13 -0
  39. data/test/manual/simple.rb +19 -0
  40. data/test/manual/simple2.rb +20 -0
  41. data/test/manual/t.rb +11 -0
  42. data/test/manual/trace.rb +19 -0
  43. data/test/manual/trace2.rb +15 -0
  44. data/test/minitest/metametameta.rb +78 -0
  45. data/test/minitest/test_helper.rb +20 -0
  46. data/test/minitest/test_minitest_benchmark.rb +131 -0
  47. data/test/minitest/test_minitest_mock.rb +490 -0
  48. data/test/minitest/test_minitest_reporter.rb +270 -0
  49. data/test/minitest/test_minitest_spec.rb +794 -0
  50. data/test/minitest/test_minitest_unit.rb +1846 -0
  51. metadata +147 -0
data/lib/spec.rb ADDED
@@ -0,0 +1,3 @@
1
+ # enable require 'spec'
2
+ require File.expand_path '../minitest.rb', __FILE__
3
+ require File.expand_path '../minitest/spec.rb', __FILE__
data/readme.md ADDED
@@ -0,0 +1,7 @@
1
+ #### spec [![Gem Version](https://badge.fury.io/rb/spec.png)](http://rubygems.org/gems/spec)[![Dependency Status](https://gemnasium.com/bootstraponline/spec.png)](https://gemnasium.com/bootstraponline/spec)
2
+
3
+ A modified [MiniTest](https://github.com/seattlerb/minitest) for Appium.
4
+
5
+ - `rake install` - Uninstall old gem, build gem, install new gem.
6
+ - `rake test` - Run the tests
7
+ - `rake rel` - Release new `spec` to GitHub and RubyGems.
data/release_notes.md ADDED
@@ -0,0 +1,49 @@
1
+ #### v5.0.13 2013-08-07
2
+
3
+ - [c401d7c](https://github.com/bootstraponline/spec/commit/c401d7cad546351f63ad62b17387643ce1b19b14) Release 5.0.13
4
+ - [f94221a](https://github.com/bootstraponline/spec/commit/f94221a3d3765c3884b76e320c479c901b39bcbb) Use set_trace_func instead of ruby2ruby
5
+
6
+
7
+ #### v5.0.12 2013-08-05
8
+
9
+ - [068adc4](https://github.com/bootstraponline/spec/commit/068adc41623e97981a5c80cf9c76bcb238b0dd46) Release 5.0.12
10
+ - [85460e5](https://github.com/bootstraponline/spec/commit/85460e58dbf95a9333771a3b508fc04c244ed057) Add method_source
11
+
12
+
13
+ #### v5.0.11 2013-08-05
14
+
15
+ - [2f64c6d](https://github.com/bootstraponline/spec/commit/2f64c6d65882f63f2cc2e19c83127bf8de957e5a) Release 5.0.11
16
+ - [7087a22](https://github.com/bootstraponline/spec/commit/7087a2254fc5644ea731852b2cbd9c384688c4d6) Fix comments
17
+ - [904c734](https://github.com/bootstraponline/spec/commit/904c734c6de78170e5128f24ab74a33f41407d45) Add more tests
18
+ - [c7a5948](https://github.com/bootstraponline/spec/commit/c7a5948169fb92fc11e8cc7afb2b0addd0bf60b3) All tests pass
19
+ - [6735b63](https://github.com/bootstraponline/spec/commit/6735b634467ba484085f8a26b815f65172a7c214) Fix after
20
+ - [3a578f4](https://github.com/bootstraponline/spec/commit/3a578f4eccead98793a437ca83e2bb66a9065c43) Start fixing rake test
21
+ - [9b04c73](https://github.com/bootstraponline/spec/commit/9b04c73410a5aeda35441078a7dfcea94ccabb9c) Don't print dots when running specs
22
+ - [e38252c](https://github.com/bootstraponline/spec/commit/e38252c587961d55b27d96d88e5b4aa32ece0d4e) t and it now print source
23
+ - [cb8063e](https://github.com/bootstraponline/spec/commit/cb8063e513d8be5a949366735130323a2b6cc67d) before_first, before, after, after_last now print source
24
+ - [0e370a7](https://github.com/bootstraponline/spec/commit/0e370a7181b94ed9f6eeb1e3c1557352501a9e8d) Fix before_first and after_last
25
+ - [9108c74](https://github.com/bootstraponline/spec/commit/9108c742f0fb061334a33eb29db3dade1b74e072) Add run specs
26
+ - [f2ea5f3](https://github.com/bootstraponline/spec/commit/f2ea5f387f3f92c8b1a9585bc560a1ed4041a57d) Fix raise
27
+ - [a41b7b5](https://github.com/bootstraponline/spec/commit/a41b7b5b170009dc5582c100ffa00ae99bf07bec) Fix gemspec
28
+ - [b35c3f9](https://github.com/bootstraponline/spec/commit/b35c3f9de6a8779ad575ad2c61bbfcb8ea7407c6) Fix reporting. More tests
29
+ - [ed620db](https://github.com/bootstraponline/spec/commit/ed620dbaaecf8e9aea18cfdc6c1db5c647b9aa51) Exit after first failure
30
+ - [0c359ef](https://github.com/bootstraponline/spec/commit/0c359efa663b4b6666c2e409faf57447db32ef4a) Start/report for full output
31
+ - [e78a157](https://github.com/bootstraponline/spec/commit/e78a157e23012ca2f26b7f1f20ab3761e511b434) Add before_first and after_last
32
+ - [17acf00](https://github.com/bootstraponline/spec/commit/17acf00114e32b2e45701a016212cd8eb558db18) Require minitest/spec by default
33
+ - [b7c66c8](https://github.com/bootstraponline/spec/commit/b7c66c839f7a520ea6eb9e22f54ecf493c7dab41) Fix test
34
+
35
+
36
+ #### v5.0.10 2013-07-29
37
+
38
+ - [8d6fe7d](https://github.com/bootstraponline/spec/commit/8d6fe7d724128ce263f2d4fc96bd40f293c3c8cb) Release 5.0.10
39
+ - [cb5f7b6](https://github.com/bootstraponline/spec/commit/cb5f7b69610c66281b6dc0a586048ce715d8288c) Enable require 'spec'
40
+ - [540ba98](https://github.com/bootstraponline/spec/commit/540ba98384e8945f6624a2726cc338e0378b67ff) Release 5.0.9
41
+ - [3be1349](https://github.com/bootstraponline/spec/commit/3be13498fc086f6b3fc4f342190383aba4992264) Release 5.0.9
42
+
43
+
44
+ #### v5.0.9 2013-07-29
45
+
46
+ - [3be1349](https://github.com/bootstraponline/spec/commit/3be13498fc086f6b3fc4f342190383aba4992264) Release 5.0.9
47
+ - [b09edff](https://github.com/bootstraponline/spec/commit/b09edff644cb25166177beb9c639a1817140d0b5) Add gem template
48
+ - [6c900a6](https://github.com/bootstraponline/spec/commit/6c900a69f6328238e5aeffcab1652bab20e0c699) Release 5.0.8
49
+ - [73e9f56](https://github.com/bootstraponline/spec/commit/73e9f5696e11d54e07bc3a8004ac0b62b5dd3616) Add gem template
data/spec.gemspec ADDED
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+
3
+ def self.add_to_path path
4
+ path = File.expand_path "../#{path}/", __FILE__
5
+
6
+ $:.unshift path unless $:.include? path
7
+ end
8
+
9
+ add_to_path 'lib'
10
+
11
+ require File.expand_path '../lib/minitest.rb', __FILE__
12
+
13
+ Gem::Specification.new do |s|
14
+ # 1.8.x is not supported
15
+ s.required_ruby_version = '>= 1.9.3'
16
+
17
+ s.name = 'spec'
18
+ s.version = Minitest::VERSION
19
+ s.date = Minitest::DATE
20
+ s.license = 'MIT'
21
+ s.description = s.summary = 'Modified minitest for Appium'
22
+ s.description += '.' # avoid identical warning
23
+ s.authors = s.email = [ 'code@bootstraponline.com' ]
24
+ s.homepage = 'https://github.com/bootstraponline/spec'
25
+ s.require_paths = %w[lib]
26
+ s.extra_rdoc_files = %w[History.txt Manifest.txt README.txt]
27
+ s.rdoc_options << '--main' << 'README.txt'
28
+ s.test_files = Dir.glob 'test/minitest/test_*.rb'
29
+
30
+ s.add_runtime_dependency 'chronic_duration', '~> 0.10.2'
31
+
32
+ s.add_development_dependency 'hoe', '~> 3.7'
33
+ s.add_development_dependency 'rdoc', '~> 4.0'
34
+
35
+ s.files = `git ls-files`.split "\n"
36
+ end
@@ -0,0 +1,14 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'stringio' # stdlib
5
+ require 'spec' # not 'minitest'
6
+
7
+ describe 'a' do
8
+ t('') { puts 1 }
9
+ t('') { 1.must_equal 2 }
10
+ t('') { puts 3 }
11
+ t('') { puts 4 }
12
+ end
13
+
14
+ Minitest.run_specs
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'stringio' # stdlib
5
+ require 'spec' # not 'minitest'
6
+
7
+ describe 'a' do
8
+ after_last do
9
+ 1.must_equal 2
10
+ end
11
+ t('') { puts 1 }
12
+ end
13
+
14
+ describe 'b' do
15
+ t('') { puts 2 }
16
+ end
17
+
18
+ # no dots
19
+ class Minitest::ProgressReporter
20
+ def record result
21
+ end
22
+ end
23
+
24
+ Minitest.run_specs
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'stringio' # stdlib
5
+ require 'spec' # not 'minitest'
6
+
7
+ describe 'a' do
8
+ before_first do
9
+ 1.must_equal 2
10
+ end
11
+ t('') { puts 1 }
12
+ t('') { 2.must_equal 3 }
13
+ t('') { 4.must_equal 5 }
14
+ t('') { puts 4 }
15
+ end
16
+
17
+ # no dots
18
+ class Minitest::ProgressReporter
19
+ def record result
20
+ end
21
+ end
22
+
23
+ Minitest.run_specs
@@ -0,0 +1,61 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'stringio' # stdlib
5
+ require 'spec' # not 'minitest'
6
+
7
+ class MiniTest::Spec
8
+ @@output = StringIO.new
9
+
10
+ def self.output
11
+ @@output
12
+ end
13
+
14
+ def p msg
15
+ @@output.puts msg
16
+ end
17
+ end
18
+
19
+ class SpecTest < MiniTest::Spec
20
+ describe 'a' do
21
+ t('') { p 1 }
22
+ t('') { 1.must_equal 2 }
23
+ t('') { p 3 }
24
+ t('') { p 4 }
25
+ end
26
+ end
27
+
28
+ options = {}
29
+ out = MiniTest::Spec.output
30
+ reporter = Minitest::CompositeReporter.new
31
+ reporter << Minitest::SummaryReporter.new(out, options)
32
+ reporter << Minitest::ProgressReporter.new(out, options)
33
+
34
+ reporter.start
35
+
36
+ begin
37
+ Minitest.__run reporter, options
38
+ reporter.reporters.each { |r| r.report }
39
+ rescue Minitest::Runnable::ExitAfterFirstFail
40
+ end
41
+
42
+ out.flush
43
+ out.rewind
44
+
45
+ actual = out.readlines.join ''
46
+
47
+ exp = <<'EXP'
48
+ 1
49
+ .F
50
+
51
+ Finished in 0s
52
+
53
+ 1) Failure:
54
+ a#test_0002_ [assert.rb:22]:
55
+ Expected: 2
56
+ Actual: 1
57
+
58
+ 2 runs, 1 assertions, 1 failures, 0 errors, 0 skips
59
+ EXP
60
+
61
+ puts actual.must_equal exp
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'stringio' # stdlib
5
+ require 'spec' # not 'minitest'
6
+
7
+ describe 'a' do
8
+ before_first { '1' }
9
+ end
10
+
11
+ =begin
12
+ describe 'a' do
13
+ before_first { '1' }
14
+ before { '2' }
15
+ t('') { '3' }
16
+ after { '4' }
17
+ after_last { '5' }
18
+ end
19
+ =end
20
+
21
+ # no dots
22
+ class Minitest::ProgressReporter
23
+ def record result
24
+ end
25
+ end
26
+
27
+ Minitest.run_specs
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'stringio' # stdlib
5
+ require 'spec' # not 'minitest'
6
+
7
+ describe 'a' do
8
+ before_first do
9
+ '1'
10
+ end
11
+ end
12
+
13
+ =begin
14
+ describe 'a' do
15
+ before_first { '1' }
16
+ before { '2' }
17
+ t('') { '3' }
18
+ after { '4' }
19
+ after_last { '5' }
20
+ end
21
+ =end
22
+
23
+ # no dots
24
+ class Minitest::ProgressReporter
25
+ def record result
26
+ end
27
+ end
28
+
29
+ Minitest.run_specs
@@ -0,0 +1,37 @@
1
+ # Source rewriting will cause problems with do/end blocks
2
+ # that expect a sane return value
3
+
4
+ @assertion_count = (@assertion_count + 3)
5
+ [1, 2, 3].must_include(2).must_equal(true)
6
+
7
+ assert_triggered("Expected [1, 2, 3] to include 5.") do
8
+ [1, 2, 3].must_include(5)
9
+ end
10
+
11
+ assert_triggered("msg.\nExpected [1, 2, 3] to include 5.") do
12
+ [1, 2, 3].must_include(5, "msg")
13
+ end
14
+
15
+ # --
16
+
17
+
18
+ puts %(@assertion_count = (@assertion_count + 3))
19
+ @assertion_count = (@assertion_count + 3)
20
+
21
+ puts %([1, 2, 3].must_include(2).must_equal(true))
22
+ [1, 2, 3].must_include(2).must_equal(true)
23
+
24
+
25
+ puts %(assert_triggered("Expected [1, 2, 3] to include 5.") do)
26
+ assert_triggered("Expected [1, 2, 3] to include 5.") do
27
+ puts %([1, 2, 3].must_include(5))
28
+ [1, 2, 3].must_include(5)
29
+
30
+
31
+
32
+ puts %(end)
33
+ puts %(assert_triggered("msg.\\nExpected [1, 2, 3] to include 5.") do)
34
+ end
35
+ assert_triggered("msg.\nExpected [1, 2, 3] to include 5.") do
36
+ puts %([1, 2, 3].must_include(5, "msg"))
37
+ [1, 2, 3].must_include(5, "msg")
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'stringio' # stdlib
5
+ require 'spec' # not 'minitest'
6
+
7
+ describe 'a' do
8
+ t('') do
9
+ def ok(&block); block.call; end
10
+ a = ok do
11
+ true
12
+ end
13
+ # should be true not nil
14
+ $stdout.puts "a is nil? #{a.nil?}"
15
+ end
16
+ end
17
+
18
+ Minitest.run_specs
19
+
20
+
21
+ $driver.public_methods(false).each do | m |
22
+ MiniTest::Spec.class_eval do
23
+ define_method m do | *args, &block |
24
+ begin
25
+ super(*args, &block)
26
+ rescue NoMethodError
27
+ $driver.send m, *args, &block if $driver.respond_to?(m)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,61 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'stringio' # stdlib
5
+ require 'spec' # not 'minitest'
6
+
7
+ class MiniTest::Spec
8
+ @@output = StringIO.new
9
+
10
+ def self.output
11
+ @@output
12
+ end
13
+
14
+ def p msg
15
+ @@output.puts msg
16
+ end
17
+ end
18
+
19
+ class SpecTest < MiniTest::Spec
20
+ describe 'a' do
21
+ t('') { p 1 }
22
+ t('') { raise 'fail' }
23
+ t('') { p 3 }
24
+ t('') { p 4 }
25
+ end
26
+ end
27
+
28
+ options = {}
29
+ out = MiniTest::Spec.output
30
+ reporter = Minitest::CompositeReporter.new
31
+ reporter << Minitest::SummaryReporter.new(out, options)
32
+ reporter << Minitest::ProgressReporter.new(out, options)
33
+
34
+ reporter.start
35
+
36
+ begin
37
+ Minitest.__run reporter, options
38
+ reporter.reporters.each { |r| r.report }
39
+ rescue Minitest::Runnable::ExitAfterFirstFail
40
+ end
41
+
42
+ out.flush
43
+ out.rewind
44
+
45
+ actual = out.readlines.join ''
46
+
47
+ exp = <<'EXP'
48
+ 1
49
+ .E
50
+
51
+ Finished in 0s
52
+
53
+ 1) Error:
54
+ a#test_0002_:
55
+ RuntimeError: fail
56
+ raise.rb:22:in `block (2 levels) in <class:SpecTest>'
57
+
58
+ 2 runs, 0 assertions, 0 failures, 1 errors, 0 skips
59
+ EXP
60
+
61
+ puts actual.must_equal exp
@@ -0,0 +1,74 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'stringio' # stdlib
5
+ require 'spec' # not 'minitest'
6
+
7
+ class MiniTest::Spec
8
+ @@output = StringIO.new
9
+
10
+ def self.output
11
+ @@output
12
+ end
13
+
14
+ def p msg
15
+ @@output.puts msg
16
+ end
17
+ end
18
+
19
+ class SpecTest < MiniTest::Spec
20
+ describe 'a' do
21
+ t('') { p 1 }
22
+ t('') { p 2 }
23
+ t('') { p 3 }
24
+ t('') { p 4 }
25
+ t('') { p 5 }
26
+ t('') { p 6 }
27
+ t('') { p 7 }
28
+ end
29
+
30
+ describe 'b' do
31
+ before { p '-- before' }
32
+ t('z') { p 8 }
33
+ t('b') { p 9 }
34
+ t('a') { p 10 }
35
+ end
36
+
37
+ describe 'z' do
38
+ t('a') { p 11 }
39
+ t('z') { p 12 }
40
+ end
41
+ end
42
+
43
+ options = {}
44
+ out = MiniTest::Spec.output
45
+ reporter = Minitest::CompositeReporter.new
46
+ reporter << Minitest::SummaryReporter.new(out, options)
47
+ reporter << Minitest::ProgressReporter.new(out, options)
48
+
49
+ Minitest.__run reporter, options
50
+
51
+ out.flush
52
+ out.rewind
53
+
54
+ actual = out.readlines.join ''
55
+ exp = <<'EXP'.strip
56
+ 1
57
+ .2
58
+ .3
59
+ .4
60
+ .5
61
+ .6
62
+ .7
63
+ .-- before
64
+ 8
65
+ .-- before
66
+ 9
67
+ .-- before
68
+ 10
69
+ .11
70
+ .12
71
+ .
72
+ EXP
73
+
74
+ puts actual.must_equal exp
@@ -0,0 +1,91 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'stringio' # stdlib
5
+ require 'spec' # not 'minitest'
6
+
7
+ class MiniTest::Spec
8
+ @@output = StringIO.new
9
+
10
+ def self.output
11
+ @@output
12
+ end
13
+
14
+ def p msg
15
+ @@output.puts msg
16
+ end
17
+ end
18
+
19
+ class SpecTest < MiniTest::Spec
20
+ describe 'a' do
21
+ before_first { p '-- before_first' }
22
+ after_last { p '-- after_last' }
23
+ t('') { p 1 }
24
+ t('') { p 2 }
25
+ t('') { p 3 }
26
+ t('') { p 4 }
27
+ t('') { p 5 }
28
+ t('') { p 6 }
29
+ t('') { p 7 }
30
+ end
31
+
32
+ describe 'b' do
33
+ t('') { p 8 }
34
+ t('') { p 9 }
35
+ end
36
+
37
+ describe 'c' do
38
+ before { p '-- before' }
39
+ after { p '-- after' }
40
+ t('') { p 10 }
41
+ t('') { p 11 }
42
+ t('') { p 12 }
43
+ end
44
+
45
+ describe 'd' do
46
+ t('') { p 13 }
47
+ t('') { p 14 }
48
+ end
49
+ end
50
+
51
+ options = {}
52
+ out = MiniTest::Spec.output
53
+ reporter = Minitest::CompositeReporter.new
54
+ reporter << Minitest::SummaryReporter.new(out, options)
55
+ reporter << Minitest::ProgressReporter.new(out, options)
56
+ #reporter.start
57
+
58
+ Minitest.__run reporter, options
59
+
60
+ #reporter.report
61
+ out.flush
62
+ out.rewind
63
+
64
+ actual = out.readlines.join ''
65
+ exp = <<'EXP'.strip
66
+ -- before_first
67
+ 1
68
+ .2
69
+ .3
70
+ .4
71
+ .5
72
+ .6
73
+ .7
74
+ .-- after_last
75
+ 8
76
+ .9
77
+ .-- before
78
+ 10
79
+ -- after
80
+ .-- before
81
+ 11
82
+ -- after
83
+ .-- before
84
+ 12
85
+ -- after
86
+ .13
87
+ .14
88
+ .
89
+ EXP
90
+
91
+ puts actual.must_equal exp
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'stringio' # stdlib
5
+ require 'spec' # not 'minitest'
6
+
7
+ before_list = []
8
+
9
+ describe 'a' do
10
+ t('') { before_list << 1 }
11
+ end
12
+
13
+ Minitest.run_specs
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'method_source'
3
+
4
+ ary = []
5
+
6
+ class Test
7
+ def self.run &block
8
+ define_method :run_method do
9
+ self.instance_eval &block
10
+ end
11
+
12
+ Test.new.run_method
13
+ end
14
+ end
15
+
16
+ Test.run do
17
+ ary << 1
18
+ puts 'complete'
19
+ end
@@ -0,0 +1,20 @@
1
+ ary = []
2
+
3
+ class Test
4
+ def self.run &block
5
+ define_method :run_method do
6
+ # eval %(ary << 1; puts 'complete'), block.binding
7
+ new_src = "ary << 1\nputs 'complete'"
8
+ block = eval("Proc.new { #{new_src} }", block.binding)
9
+ self.instance_eval &block
10
+ end
11
+
12
+ puts 'calling run method'
13
+ Test.new.run_method
14
+ end
15
+ end
16
+
17
+ Test.run do
18
+ ary << 1
19
+ puts 'complete'
20
+ end
data/test/manual/t.rb ADDED
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'stringio' # stdlib
5
+ require 'spec' # not 'minitest'
6
+
7
+ describe 'a' do
8
+ t('') { '1' }
9
+ end
10
+
11
+ Minitest.run_specs
@@ -0,0 +1,19 @@
1
+ # from http://apidock.com/ruby/Kernel/set_trace_func
2
+
3
+ class Test
4
+ def test
5
+ a = 1
6
+ b = 2
7
+ end
8
+ end
9
+
10
+ $lines = IO.readlines('trace.rb')
11
+ $last_line = -1
12
+ set_trace_func proc { |event, file, line, id, binding, classname|
13
+ if file == 'trace.rb' && $last_line != line
14
+ puts "#{line}: #{$lines[line-1]}"
15
+ $last_line = line
16
+ end
17
+ }
18
+ t = Test.new
19
+ t.test
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'stringio' # stdlib
5
+ require 'spec' # not 'minitest'
6
+
7
+ describe 'a' do
8
+ t('') { 1 }
9
+ t('') { 2 }
10
+ t('') { 3 }
11
+ t('') { 4 }
12
+ end
13
+
14
+ # Run specs and trace this file
15
+ Minitest.run_specs({ :trace => [__FILE__] })