mspec 1.5.17 → 1.5.18

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.
Files changed (174) hide show
  1. data/.gitignore +27 -0
  2. data/Gemfile +4 -0
  3. data/README +39 -159
  4. data/Rakefile +4 -44
  5. data/bin/mkspec.bat +1 -0
  6. data/bin/mspec-ci.bat +1 -0
  7. data/bin/mspec-run.bat +1 -0
  8. data/bin/mspec-tag.bat +1 -0
  9. data/bin/mspec.bat +1 -0
  10. data/lib/mspec/commands/mkspec.rb +2 -2
  11. data/lib/mspec/commands/mspec-run.rb +4 -0
  12. data/lib/mspec/commands/mspec.rb +18 -3
  13. data/lib/mspec/guards.rb +1 -0
  14. data/lib/mspec/guards/block_device.rb +22 -0
  15. data/lib/mspec/guards/guard.rb +14 -2
  16. data/lib/mspec/helpers.rb +5 -5
  17. data/lib/mspec/helpers/const_lookup.rb +6 -1
  18. data/lib/mspec/helpers/datetime.rb +28 -0
  19. data/lib/mspec/helpers/ducktype.rb +4 -4
  20. data/lib/mspec/helpers/environment.rb +19 -2
  21. data/lib/mspec/helpers/fs.rb +5 -1
  22. data/lib/mspec/helpers/io.rb +39 -1
  23. data/lib/mspec/helpers/numeric.rb +89 -0
  24. data/lib/mspec/helpers/pack.rb +3 -0
  25. data/lib/mspec/helpers/ruby_exe.rb +53 -15
  26. data/lib/mspec/helpers/singleton_class.rb +7 -0
  27. data/lib/mspec/helpers/stasy.rb +33 -0
  28. data/lib/mspec/helpers/tmp.rb +16 -3
  29. data/lib/mspec/matchers.rb +8 -0
  30. data/lib/mspec/matchers/be_computed_by.rb +37 -0
  31. data/lib/mspec/matchers/be_computed_by_function.rb +35 -0
  32. data/lib/mspec/matchers/be_nan.rb +20 -0
  33. data/lib/mspec/matchers/be_valid_dns_name.rb +25 -0
  34. data/lib/mspec/matchers/have_data.rb +6 -5
  35. data/lib/mspec/matchers/have_private_method.rb +24 -0
  36. data/lib/mspec/matchers/have_singleton_method.rb +24 -0
  37. data/lib/mspec/matchers/infinity.rb +28 -0
  38. data/lib/mspec/matchers/match_yaml.rb +5 -5
  39. data/lib/mspec/matchers/raise_error.rb +5 -3
  40. data/lib/mspec/matchers/signed_zero.rb +28 -0
  41. data/lib/mspec/mocks/mock.rb +15 -9
  42. data/lib/mspec/mocks/object.rb +4 -0
  43. data/lib/mspec/mocks/proxy.rb +26 -1
  44. data/lib/mspec/runner/actions.rb +0 -1
  45. data/lib/mspec/runner/context.rb +18 -16
  46. data/lib/mspec/runner/formatters.rb +2 -0
  47. data/lib/mspec/runner/formatters/dotted.rb +13 -1
  48. data/lib/mspec/runner/formatters/junit.rb +96 -0
  49. data/lib/mspec/runner/formatters/profile.rb +70 -0
  50. data/lib/mspec/runner/mspec.rb +11 -0
  51. data/lib/mspec/runner/shared.rb +1 -1
  52. data/lib/mspec/utils/options.rb +33 -9
  53. data/lib/mspec/utils/ruby_name.rb +1 -1
  54. data/lib/mspec/utils/script.rb +2 -1
  55. data/lib/mspec/version.rb +1 -1
  56. data/mspec.gemspec +40 -0
  57. data/spec/commands/mkspec_spec.rb +4 -3
  58. data/spec/commands/mspec_ci_spec.rb +1 -6
  59. data/spec/commands/mspec_run_spec.rb +1 -6
  60. data/spec/commands/mspec_spec.rb +14 -6
  61. data/spec/commands/mspec_tag_spec.rb +28 -27
  62. data/spec/expectations/expectations_spec.rb +1 -1
  63. data/spec/expectations/should_spec.rb +4 -4
  64. data/spec/guards/background_spec.rb +2 -2
  65. data/spec/guards/block_device_spec.rb +46 -0
  66. data/spec/guards/bug_spec.rb +2 -3
  67. data/spec/guards/compliance_spec.rb +2 -2
  68. data/spec/guards/conflict_spec.rb +2 -2
  69. data/spec/guards/endian_spec.rb +2 -2
  70. data/spec/guards/extensions_spec.rb +2 -2
  71. data/spec/guards/feature_spec.rb +2 -2
  72. data/spec/guards/guard_spec.rb +80 -22
  73. data/spec/guards/noncompliance_spec.rb +2 -2
  74. data/spec/guards/platform_spec.rb +2 -2
  75. data/spec/guards/quarantine_spec.rb +2 -2
  76. data/spec/guards/runner_spec.rb +2 -2
  77. data/spec/guards/specified_spec.rb +2 -2
  78. data/spec/guards/superuser_spec.rb +2 -2
  79. data/spec/guards/support_spec.rb +2 -2
  80. data/spec/guards/tty_spec.rb +2 -2
  81. data/spec/guards/user_spec.rb +2 -2
  82. data/spec/guards/version_spec.rb +2 -2
  83. data/spec/helpers/argv_spec.rb +3 -2
  84. data/spec/helpers/const_lookup_spec.rb +3 -2
  85. data/spec/helpers/datetime_spec.rb +44 -0
  86. data/spec/helpers/ducktype_spec.rb +3 -2
  87. data/spec/helpers/encode_spec.rb +3 -2
  88. data/spec/helpers/enumerator_class_spec.rb +5 -5
  89. data/spec/helpers/environment_spec.rb +15 -3
  90. data/spec/helpers/fixture_spec.rb +3 -2
  91. data/spec/helpers/flunk_spec.rb +4 -3
  92. data/spec/helpers/fs_spec.rb +35 -18
  93. data/spec/helpers/hash_spec.rb +3 -2
  94. data/spec/helpers/io_spec.rb +75 -6
  95. data/spec/helpers/language_version_spec.rb +3 -2
  96. data/spec/helpers/mock_to_path_spec.rb +3 -2
  97. data/spec/helpers/numeric_spec.rb +25 -0
  98. data/spec/helpers/ruby_exe_spec.rb +115 -29
  99. data/spec/helpers/scratch_spec.rb +3 -1
  100. data/spec/helpers/stasy_spec.rb +59 -0
  101. data/spec/helpers/tmp_spec.rb +21 -4
  102. data/spec/matchers/base_spec.rb +2 -2
  103. data/spec/matchers/be_an_instance_of_spec.rb +2 -2
  104. data/spec/matchers/be_ancestor_of_spec.rb +2 -2
  105. data/spec/matchers/be_close_spec.rb +2 -2
  106. data/spec/matchers/be_computed_by_function_spec.rb +36 -0
  107. data/spec/matchers/be_computed_by_spec.rb +42 -0
  108. data/spec/matchers/be_empty_spec.rb +2 -2
  109. data/spec/matchers/be_false_spec.rb +3 -3
  110. data/spec/matchers/be_kind_of_spec.rb +2 -2
  111. data/spec/matchers/be_nan_spec.rb +28 -0
  112. data/spec/matchers/be_nil_spec.rb +3 -3
  113. data/spec/matchers/be_true_spec.rb +3 -3
  114. data/spec/matchers/be_valid_dns_name_spec.rb +50 -0
  115. data/spec/matchers/complain_spec.rb +2 -2
  116. data/spec/matchers/eql_spec.rb +2 -2
  117. data/spec/matchers/equal_element_spec.rb +2 -2
  118. data/spec/matchers/equal_spec.rb +2 -2
  119. data/spec/matchers/equal_utf16_spec.rb +2 -2
  120. data/spec/matchers/have_class_variable_spec.rb +3 -3
  121. data/spec/matchers/have_constant_spec.rb +2 -2
  122. data/spec/matchers/have_data_spec.rb +8 -5
  123. data/spec/matchers/have_instance_method_spec.rb +2 -2
  124. data/spec/matchers/have_instance_variable_spec.rb +3 -3
  125. data/spec/matchers/have_method_spec.rb +2 -2
  126. data/spec/matchers/have_private_instance_method_spec.rb +3 -3
  127. data/spec/matchers/have_private_method_spec.rb +44 -0
  128. data/spec/matchers/have_protected_instance_method_spec.rb +2 -2
  129. data/spec/matchers/have_public_instance_method_spec.rb +2 -2
  130. data/spec/matchers/have_singleton_method_spec.rb +45 -0
  131. data/spec/matchers/include_spec.rb +2 -2
  132. data/spec/matchers/infinity_spec.rb +34 -0
  133. data/spec/matchers/match_yaml_spec.rb +3 -3
  134. data/spec/matchers/output_spec.rb +2 -2
  135. data/spec/matchers/output_to_fd_spec.rb +2 -2
  136. data/spec/matchers/raise_error_spec.rb +24 -3
  137. data/spec/matchers/respond_to_spec.rb +2 -2
  138. data/spec/matchers/signed_zero_spec.rb +32 -0
  139. data/spec/matchers/stringsymboladapter_spec.rb +2 -2
  140. data/spec/mocks/mock_spec.rb +12 -12
  141. data/spec/mocks/proxy_spec.rb +1 -1
  142. data/spec/runner/actions/gdb_spec.rb +1 -1
  143. data/spec/runner/actions/tag_spec.rb +1 -1
  144. data/spec/runner/actions/taglist_spec.rb +1 -1
  145. data/spec/runner/context_spec.rb +27 -27
  146. data/spec/runner/example_spec.rb +1 -1
  147. data/spec/runner/exception_spec.rb +1 -1
  148. data/spec/runner/filters/tag_spec.rb +2 -2
  149. data/spec/runner/formatters/describe_spec.rb +1 -1
  150. data/spec/runner/formatters/dotted_spec.rb +2 -2
  151. data/spec/runner/formatters/html_spec.rb +2 -2
  152. data/spec/runner/formatters/junit_spec.rb +147 -0
  153. data/spec/runner/formatters/unit_spec.rb +2 -2
  154. data/spec/runner/formatters/yaml_spec.rb +3 -3
  155. data/spec/runner/mspec_spec.rb +22 -21
  156. data/spec/runner/shared_spec.rb +9 -1
  157. data/spec/runner/tag_spec.rb +1 -1
  158. data/spec/spec_helper.rb +1 -7
  159. data/spec/utils/name_map_spec.rb +1 -2
  160. data/spec/utils/options_spec.rb +58 -27
  161. data/spec/utils/script_spec.rb +5 -13
  162. data/spec/utils/version_spec.rb +1 -1
  163. metadata +254 -64
  164. data/lib/mspec/helpers/bignum.rb +0 -5
  165. data/lib/mspec/helpers/fmode.rb +0 -15
  166. data/lib/mspec/helpers/infinity.rb +0 -5
  167. data/lib/mspec/helpers/metaclass.rb +0 -7
  168. data/lib/mspec/helpers/nan.rb +0 -5
  169. data/lib/mspec/runner/actions/debug.rb +0 -17
  170. data/spec/helpers/bignum_spec.rb +0 -11
  171. data/spec/helpers/fmode_spec.rb +0 -14
  172. data/spec/helpers/infinity_spec.rb +0 -8
  173. data/spec/helpers/nan_spec.rb +0 -8
  174. data/spec/runner/actions/debug_spec.rb +0 -62
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
  require 'mspec/expectations/expectations'
3
3
  require 'mspec/runner/example'
4
4
  require 'mspec/runner/exception'
@@ -5,7 +5,7 @@ require 'mspec/runner/filters/tag'
5
5
 
6
6
  describe TagFilter, "#load" do
7
7
  before :each do
8
- @match = mock("match filter", :null_object => true)
8
+ @match = mock("match filter").as_null_object
9
9
  @filter = TagFilter.new :include, "tag", "key"
10
10
  @tag = SpecTag.new "tag(comment):description"
11
11
  MSpec.stub!(:read_tags).and_return([@tag])
@@ -50,7 +50,7 @@ describe TagFilter, "#unload" do
50
50
  end
51
51
 
52
52
  it "unregisters the MatchFilter if one was registered" do
53
- match = mock("match filter", :null_object => true)
53
+ match = mock("match filter").as_null_object
54
54
  match.should_receive(:unregister)
55
55
  MatchFilter.stub!(:new).with(:include, "description").and_return(match)
56
56
  @filter.load
@@ -7,7 +7,7 @@ describe DescribeFormatter, "#finish" do
7
7
  MSpec.stub!(:register)
8
8
  MSpec.stub!(:unregister)
9
9
 
10
- @timer = mock("timer", :null_object => true)
10
+ @timer = mock("timer").as_null_object
11
11
  TimerAction.stub!(:new).and_return(@timer)
12
12
  @timer.stub!(:format).and_return("Finished in 2.0 seconds")
13
13
 
@@ -221,9 +221,9 @@ end
221
221
 
222
222
  describe DottedFormatter, "#finish" do
223
223
  before :each do
224
- @tally = mock("tally", :null_object => true)
224
+ @tally = mock("tally").as_null_object
225
225
  TallyAction.stub!(:new).and_return(@tally)
226
- @timer = mock("timer", :null_object => true)
226
+ @timer = mock("timer").as_null_object
227
227
  TimerAction.stub!(:new).and_return(@timer)
228
228
 
229
229
  $stdout = @out = IOStub.new
@@ -144,9 +144,9 @@ end
144
144
 
145
145
  describe HtmlFormatter, "#finish" do
146
146
  before :each do
147
- @tally = mock("tally", :null_object => true)
147
+ @tally = mock("tally").as_null_object
148
148
  TallyAction.stub!(:new).and_return(@tally)
149
- @timer = mock("timer", :null_object => true)
149
+ @timer = mock("timer").as_null_object
150
150
  TimerAction.stub!(:new).and_return(@timer)
151
151
 
152
152
  $stdout = @out = IOStub.new
@@ -0,0 +1,147 @@
1
+ # -*- coding: utf-8 -*-
2
+ require File.dirname(__FILE__) + '/../../spec_helper'
3
+ require 'mspec/runner/formatters/junit'
4
+ require 'mspec/runner/example'
5
+
6
+ describe JUnitFormatter, "#initialize" do
7
+ it "permits zero arguments" do
8
+ lambda { JUnitFormatter.new }.should_not raise_error
9
+ end
10
+
11
+ it "accepts one argument" do
12
+ lambda { JUnitFormatter.new nil }.should_not raise_error
13
+ end
14
+ end
15
+
16
+ describe JUnitFormatter, "#print" do
17
+ before :each do
18
+ $stdout = IOStub.new
19
+ @out = IOStub.new
20
+ File.stub!(:open).and_return(@out)
21
+ @formatter = JUnitFormatter.new "some/file"
22
+ end
23
+
24
+ after :each do
25
+ $stdout = STDOUT
26
+ end
27
+
28
+ it "writes to $stdout if #switch has not been called" do
29
+ @formatter.print "begonias"
30
+ $stdout.should == "begonias"
31
+ @out.should == ""
32
+ end
33
+
34
+ it "writes to the file passed to #initialize once #switch has been called" do
35
+ @formatter.switch
36
+ @formatter.print "begonias"
37
+ $stdout.should == ""
38
+ @out.should == "begonias"
39
+ end
40
+
41
+ it "writes to $stdout once #switch is called if no file was passed to #initialize" do
42
+ formatter = JUnitFormatter.new
43
+ formatter.switch
44
+ formatter.print "begonias"
45
+ $stdout.should == "begonias"
46
+ @out.should == ""
47
+ end
48
+ end
49
+
50
+ describe JUnitFormatter, "#finish" do
51
+ before :each do
52
+ @tally = mock("tally").as_null_object
53
+ @counter = mock("counter").as_null_object
54
+ @tally.stub!(:counter).and_return(@counter)
55
+ TallyAction.stub!(:new).and_return(@tally)
56
+
57
+ @timer = mock("timer").as_null_object
58
+ TimerAction.stub!(:new).and_return(@timer)
59
+
60
+ $stdout = IOStub.new
61
+ context = ContextState.new "describe"
62
+ @state = ExampleState.new(context, "it")
63
+
64
+ @formatter = JUnitFormatter.new
65
+ @formatter.stub!(:backtrace).and_return("")
66
+ MSpec.stub!(:register)
67
+ @formatter.register
68
+
69
+ exc = ExceptionState.new @state, nil, MSpecExampleError.new("broken")
70
+ exc.stub!(:backtrace).and_return("path/to/some/file.rb:35:in method")
71
+ @formatter.exception exc
72
+ @formatter.after @state
73
+ end
74
+
75
+ after :each do
76
+ $stdout = STDOUT
77
+ end
78
+
79
+ it "calls #switch" do
80
+ @formatter.should_receive(:switch)
81
+ @formatter.finish
82
+ end
83
+
84
+ it "outputs a failure message and backtrace" do
85
+ @formatter.finish
86
+ $stdout.should =~ /message="error in describe it" type="error"/
87
+ $stdout.should =~ /MSpecExampleError: broken\n/
88
+ $stdout.should =~ %r[path/to/some/file.rb:35:in method]
89
+ end
90
+
91
+ it "encodes message and backtrace in latin1 for jenkins" do
92
+ exc = ExceptionState.new @state, nil, MSpecExampleError.new("broken…")
93
+ exc.stub!(:backtrace).and_return("path/to/some/file.rb:35:in methød")
94
+ @formatter.exception exc
95
+ @formatter.finish
96
+ $stdout.should =~ /MSpecExampleError: broken((\.\.\.)|\?)\n/
97
+ $stdout.should =~ /path\/to\/some\/file\.rb:35:in meth(\?|o)d/
98
+ end
99
+
100
+ it "outputs an elapsed time" do
101
+ @timer.should_receive(:elapsed).and_return(4.2)
102
+ @formatter.finish
103
+ $stdout.should =~ /time="4.2"/
104
+ end
105
+
106
+ it "outputs overall elapsed time" do
107
+ @timer.should_receive(:elapsed).and_return(4.2)
108
+ @formatter.finish
109
+ $stdout.should =~ /timeCount="4.2"/
110
+ end
111
+
112
+ it "outputs the number of examples as test count" do
113
+ @counter.should_receive(:examples).and_return(9)
114
+ @formatter.finish
115
+ $stdout.should =~ /tests="9"/
116
+ end
117
+
118
+ it "outputs overall number of examples as test count" do
119
+ @counter.should_receive(:examples).and_return(9)
120
+ @formatter.finish
121
+ $stdout.should =~ /testCount="9"/
122
+ end
123
+
124
+ it "outputs a failure count" do
125
+ @counter.should_receive(:failures).and_return(2)
126
+ @formatter.finish
127
+ $stdout.should =~ /failureCount="2"/
128
+ end
129
+
130
+ it "outputs overall failure count" do
131
+ @counter.should_receive(:failures).and_return(2)
132
+ @formatter.finish
133
+ $stdout.should =~ /failures="2"/
134
+ end
135
+
136
+ it "outputs an error count" do
137
+ @counter.should_receive(:errors).and_return(1)
138
+ @formatter.finish
139
+ $stdout.should =~ /errors="1"/
140
+ end
141
+
142
+ it "outputs overall error count" do
143
+ @counter.should_receive(:errors).and_return(1)
144
+ @formatter.finish
145
+ $stdout.should =~ /errorCount="1"/
146
+ end
147
+ end
@@ -5,9 +5,9 @@ require 'mspec/utils/script'
5
5
 
6
6
  describe UnitdiffFormatter, "#finish" do
7
7
  before :each do
8
- @tally = mock("tally", :null_object => true)
8
+ @tally = mock("tally").as_null_object
9
9
  TallyAction.stub!(:new).and_return(@tally)
10
- @timer = mock("timer", :null_object => true)
10
+ @timer = mock("timer").as_null_object
11
11
  TimerAction.stub!(:new).and_return(@timer)
12
12
 
13
13
  $stdout = @out = IOStub.new
@@ -48,12 +48,12 @@ end
48
48
 
49
49
  describe YamlFormatter, "#finish" do
50
50
  before :each do
51
- @tally = mock("tally", :null_object => true)
52
- @counter = mock("counter", :null_object => true)
51
+ @tally = mock("tally").as_null_object
52
+ @counter = mock("counter").as_null_object
53
53
  @tally.stub!(:counter).and_return(@counter)
54
54
  TallyAction.stub!(:new).and_return(@tally)
55
55
 
56
- @timer = mock("timer", :null_object => true)
56
+ @timer = mock("timer").as_null_object
57
57
  TimerAction.stub!(:new).and_return(@timer)
58
58
 
59
59
  $stdout = IOStub.new
@@ -1,5 +1,6 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
  require 'mspec/helpers/tmp'
3
+ require 'mspec/helpers/fs'
3
4
  require 'mspec/matchers/base'
4
5
  require 'mspec/runner/mspec'
5
6
  require 'mspec/runner/example'
@@ -418,12 +419,12 @@ end
418
419
  describe MSpec, ".read_tags" do
419
420
  before :each do
420
421
  @tag = SpecTag.new "fails:Some#method"
421
- File.open(tmp("tags.txt"), "w") do |f|
422
+ File.open(tmp("tags.txt", false), "w") do |f|
422
423
  f.puts ""
423
424
  f.puts @tag
424
425
  f.puts ""
425
426
  end
426
- MSpec.stub!(:tags_file).and_return(tmp("tags.txt"))
427
+ MSpec.stub!(:tags_file).and_return(tmp("tags.txt", false))
427
428
  end
428
429
 
429
430
  it "does not return a tag object for empty lines" do
@@ -433,24 +434,24 @@ end
433
434
 
434
435
  describe MSpec, ".write_tags" do
435
436
  before :each do
436
- FileUtils.cp File.dirname(__FILE__) + "/tags.txt", tmp("tags.txt")
437
- MSpec.stub!(:tags_file).and_return(tmp("tags.txt"))
437
+ FileUtils.cp File.dirname(__FILE__) + "/tags.txt", tmp("tags.txt", false)
438
+ MSpec.stub!(:tags_file).and_return(tmp("tags.txt", false))
438
439
  @tag1 = SpecTag.new "check(broken):Tag#rewrite works"
439
440
  @tag2 = SpecTag.new "broken:Tag#write_tags fails"
440
441
  end
441
442
 
442
443
  after :all do
443
- File.delete tmp("tags.txt") rescue nil
444
+ rm_r tmp("tags.txt", false)
444
445
  end
445
446
 
446
447
  it "overwrites the tags in the tag file" do
447
- IO.read(tmp("tags.txt")).should == %[fail(broken):Some#method? works
448
+ IO.read(tmp("tags.txt", false)).should == %[fail(broken):Some#method? works
448
449
  incomplete(20%):The#best method ever
449
450
  benchmark(0.01825):The#fastest method today
450
451
  extended():\"Multi-line\\ntext\\ntag\"
451
452
  ]
452
453
  MSpec.write_tags [@tag1, @tag2]
453
- IO.read(tmp("tags.txt")).should == %[check(broken):Tag#rewrite works
454
+ IO.read(tmp("tags.txt", false)).should == %[check(broken):Tag#rewrite works
454
455
  broken:Tag#write_tags fails
455
456
  ]
456
457
  end
@@ -459,40 +460,40 @@ end
459
460
  describe MSpec, ".write_tag" do
460
461
  before :each do
461
462
  FileUtils.stub!(:mkdir_p)
462
- MSpec.stub!(:tags_file).and_return(tmp("tags.txt"))
463
+ MSpec.stub!(:tags_file).and_return(tmp("tags.txt", false))
463
464
  @tag = SpecTag.new "fail(broken):Some#method works"
464
465
  end
465
466
 
466
467
  after :all do
467
- File.delete tmp("tags.txt") rescue nil
468
+ rm_r tmp("tags.txt", false)
468
469
  end
469
470
 
470
471
  it "writes a tag to the tags file for the current spec file" do
471
472
  MSpec.write_tag @tag
472
- IO.read(tmp("tags.txt")).should == "fail(broken):Some#method works\n"
473
+ IO.read(tmp("tags.txt", false)).should == "fail(broken):Some#method works\n"
473
474
  end
474
475
 
475
476
  it "does not write a duplicate tag" do
476
- File.open(tmp("tags.txt"), "w") { |f| f.puts @tag }
477
+ File.open(tmp("tags.txt", false), "w") { |f| f.puts @tag }
477
478
  MSpec.write_tag @tag
478
- IO.read(tmp("tags.txt")).should == "fail(broken):Some#method works\n"
479
+ IO.read(tmp("tags.txt", false)).should == "fail(broken):Some#method works\n"
479
480
  end
480
481
  end
481
482
 
482
483
  describe MSpec, ".delete_tag" do
483
484
  before :each do
484
- FileUtils.cp File.dirname(__FILE__) + "/tags.txt", tmp("tags.txt")
485
- MSpec.stub!(:tags_file).and_return(tmp("tags.txt"))
485
+ FileUtils.cp File.dirname(__FILE__) + "/tags.txt", tmp("tags.txt", false)
486
+ MSpec.stub!(:tags_file).and_return(tmp("tags.txt", false))
486
487
  @tag = SpecTag.new "fail(Comments don't matter):Some#method? works"
487
488
  end
488
489
 
489
490
  after :each do
490
- File.delete tmp("tags.txt") rescue nil
491
+ rm_r tmp("tags.txt", false)
491
492
  end
492
493
 
493
494
  it "deletes the tag if it exists" do
494
495
  MSpec.delete_tag(@tag).should == true
495
- IO.read(tmp("tags.txt")).should == %[incomplete(20%):The#best method ever
496
+ IO.read(tmp("tags.txt", false)).should == %[incomplete(20%):The#best method ever
496
497
  benchmark(0.01825):The#fastest method today
497
498
  extended():\"Multi-line\\ntext\\ntag\"
498
499
  ]
@@ -500,7 +501,7 @@ extended():\"Multi-line\\ntext\\ntag\"
500
501
 
501
502
  it "deletes a tag with escaped newlines" do
502
503
  MSpec.delete_tag(SpecTag.new('extended:"Multi-line\ntext\ntag"')).should == true
503
- IO.read(tmp("tags.txt")).should == %[fail(broken):Some#method? works
504
+ IO.read(tmp("tags.txt", false)).should == %[fail(broken):Some#method? works
504
505
  incomplete(20%):The#best method ever
505
506
  benchmark(0.01825):The#fastest method today
506
507
  ]
@@ -509,7 +510,7 @@ benchmark(0.01825):The#fastest method today
509
510
  it "does not change the tags file contents if the tag doesn't exist" do
510
511
  @tag.tag = "failed"
511
512
  MSpec.delete_tag(@tag).should == false
512
- IO.read(tmp("tags.txt")).should == %[fail(broken):Some#method? works
513
+ IO.read(tmp("tags.txt", false)).should == %[fail(broken):Some#method? works
513
514
  incomplete(20%):The#best method ever
514
515
  benchmark(0.01825):The#fastest method today
515
516
  extended():\"Multi-line\\ntext\\ntag\"
@@ -521,13 +522,13 @@ extended():\"Multi-line\\ntext\\ntag\"
521
522
  MSpec.delete_tag(SpecTag.new("incomplete:The#best method ever")).should == true
522
523
  MSpec.delete_tag(SpecTag.new("benchmark:The#fastest method today")).should == true
523
524
  MSpec.delete_tag(SpecTag.new("extended:\"Multi-line\ntext\ntag\"")).should == true
524
- File.exist?(tmp("tags.txt")).should == false
525
+ File.exist?(tmp("tags.txt", false)).should == false
525
526
  end
526
527
  end
527
528
 
528
529
  describe MSpec, ".delete_tags" do
529
530
  before :each do
530
- @tags = tmp("tags.txt")
531
+ @tags = tmp("tags.txt", false)
531
532
  FileUtils.cp File.dirname(__FILE__) + "/tags.txt", @tags
532
533
  MSpec.stub!(:tags_file).and_return(@tags)
533
534
  end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
  require 'mspec/runner/shared'
3
3
  require 'mspec/runner/context'
4
4
  require 'mspec/runner/example'
@@ -29,6 +29,14 @@ describe Object, "#it_behaves_like" do
29
29
  ScratchPad.recorded.should == object
30
30
  end
31
31
 
32
+ it "creates @object if the passed false" do
33
+ object = false
34
+ @shared.it("an example") { ScratchPad.record @object }
35
+ @state.it_behaves_like :shared_spec, :some_method, object
36
+ @state.process
37
+ ScratchPad.recorded.should == object
38
+ end
39
+
32
40
  it "sends :it_should_behave_like" do
33
41
  @state.should_receive(:it_should_behave_like)
34
42
  @state.it_behaves_like :shared_spec, :some_method
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
  require 'mspec/runner/tag'
3
3
 
4
4
  describe SpecTag do
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,3 @@
1
- dir_path = File.dirname(__FILE__)
2
- lib_path = File.expand_path(dir_path + '/../lib')
3
- bin_path = File.expand_path(dir_path + '/..')
4
- $:.unshift lib_path unless $:.include? lib_path
5
- $:.unshift bin_path unless $:.include? bin_path
6
-
7
1
  require 'pp'
8
2
  require 'mspec/helpers/io'
9
3
  require 'mspec/helpers/scratch'
@@ -29,6 +23,7 @@ class MOSConfig < Hash
29
23
  self[:command] = nil
30
24
  self[:ltags] = []
31
25
  self[:files] = []
26
+ self[:launch] = []
32
27
  end
33
28
  end
34
29
 
@@ -40,4 +35,3 @@ end
40
35
  # Just to have an exception name output not be "Exception"
41
36
  class MSpecExampleError < Exception
42
37
  end
43
-
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
  require 'mspec/utils/name_map'
3
3
 
4
4
  module NameMapSpecs
@@ -74,7 +74,6 @@ describe NameMap, "#class_or_module" do
74
74
  DTracer
75
75
  NameMap
76
76
  OptionParser
77
- YAML
78
77
  ]
79
78
 
80
79
  excluded.each do |const|
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
  require 'mspec/utils/options'
3
3
  require 'mspec/version'
4
4
  require 'mspec/guards/guard'
@@ -544,16 +544,20 @@ describe "The -t, --target TARGET option" do
544
544
  @options.targets
545
545
  end
546
546
 
547
- it "sets the target to 'ruby' and flags to verbose with TARGET 'ruby'" do
547
+ it "sets the target to 'ruby' and flags to verbose with TARGET 'r' or 'ruby'" do
548
548
  ["-t", "--target"].each do |opt|
549
- @options.parse [opt, "ruby"]
550
- @config[:target].should == "ruby"
549
+ ["r", "ruby"].each do |t|
550
+ @config[:target] = nil
551
+ @options.parse [opt, t]
552
+ @config[:target].should == "ruby"
553
+ end
551
554
  end
552
555
  end
553
556
 
554
557
  it "sets the target to 'ruby1.9' with TARGET 'r19', 'ruby19' or 'ruby1.9'" do
555
558
  ["-t", "--target"].each do |opt|
556
- ["r19", "ruby19", "ruby1.9"].each do |t|
559
+ ["r19", "ruby19"].each do |t|
560
+ @config[:target] = nil
557
561
  @options.parse [opt, t]
558
562
  @config[:target].should == "ruby1.9"
559
563
  end
@@ -563,6 +567,7 @@ describe "The -t, --target TARGET option" do
563
567
  it "sets the target to 'jruby' with TARGET 'j' or 'jruby'" do
564
568
  ["-t", "--target"].each do |opt|
565
569
  ["j", "jruby"].each do |t|
570
+ @config[:target] = nil
566
571
  @options.parse [opt, t]
567
572
  @config[:target].should == "jruby"
568
573
  end
@@ -572,6 +577,7 @@ describe "The -t, --target TARGET option" do
572
577
  it "sets the target to 'shotgun/rubinius' with TARGET 'x' or 'rubinius'" do
573
578
  ["-t", "--target"].each do |opt|
574
579
  ["x", "rubinius"].each do |t|
580
+ @config[:target] = nil
575
581
  @options.parse [opt, t]
576
582
  @config[:target].should == "./bin/rbx"
577
583
  end
@@ -581,6 +587,7 @@ describe "The -t, --target TARGET option" do
581
587
  it "set the target to 'rbx' with TARGET 'rbx'" do
582
588
  ["-t", "--target"].each do |opt|
583
589
  ["X", "rbx"].each do |t|
590
+ @config[:target] = nil
584
591
  @options.parse [opt, t]
585
592
  @config[:target].should == "rbx"
586
593
  end
@@ -590,14 +597,26 @@ describe "The -t, --target TARGET option" do
590
597
  it "sets the target to 'maglev' with TARGET 'm' or 'maglev'" do
591
598
  ["-t", "--target"].each do |opt|
592
599
  ["m", "maglev"].each do |t|
600
+ @config[:target] = nil
593
601
  @options.parse [opt, t]
594
602
  @config[:target].should == "maglev-ruby"
595
603
  end
596
604
  end
597
605
  end
598
606
 
607
+ it "sets the target to 'topaz' with TARGET 't' or 'topaz'" do
608
+ ["-t", "--target"].each do |opt|
609
+ ["t", "topaz"].each do |t|
610
+ @config[:target] = nil
611
+ @options.parse [opt, t]
612
+ @config[:target].should == "topaz"
613
+ end
614
+ end
615
+ end
616
+
599
617
  it "sets the target to TARGET" do
600
618
  ["-t", "--target"].each do |opt|
619
+ @config[:target] = nil
601
620
  @options.parse [opt, "whateva"]
602
621
  @config[:target].should == "whateva"
603
622
  end
@@ -782,6 +801,16 @@ describe "The -f, --format FORMAT option" do
782
801
  end
783
802
  end
784
803
  end
804
+
805
+ it "sets the JUnitFormatter with FORMAT 'j' or 'junit'" do
806
+ ["-f", "--format"].each do |opt|
807
+ ["j", "junit"].each do |f|
808
+ @config[:formatter] = nil
809
+ @options.parse [opt, f]
810
+ @config[:formatter].should == JUnitFormatter
811
+ end
812
+ end
813
+ end
785
814
  end
786
815
 
787
816
  describe "The -o, --output FILE option" do
@@ -1073,6 +1102,30 @@ describe "The -H, --random option" do
1073
1102
  end
1074
1103
  end
1075
1104
 
1105
+ describe "The -R, --repeat option" do
1106
+ before :each do
1107
+ @options, @config = new_option
1108
+ @options.repeat
1109
+ end
1110
+
1111
+ it "is enabled with #repeat" do
1112
+ @options.should_receive(:on).with("-R", "--repeat", "NUMBER", an_instance_of(String))
1113
+ @options.repeat
1114
+ end
1115
+
1116
+ it "registers the MSpec repeat mode" do
1117
+ ["-R", "--repeat"].each do |opt|
1118
+ MSpec.repeat = 1
1119
+ @options.parse [opt, "10"]
1120
+ repeat_count = 0
1121
+ MSpec.repeat do
1122
+ repeat_count += 1
1123
+ end
1124
+ repeat_count.should == 10
1125
+ end
1126
+ end
1127
+ end
1128
+
1076
1129
  describe "The -V, --verbose option" do
1077
1130
  before :each do
1078
1131
  @options, @config = new_option
@@ -1256,28 +1309,6 @@ describe "The -S, --action-string STR option" do
1256
1309
  end
1257
1310
  end
1258
1311
 
1259
- describe "The --spec-debug option" do
1260
- before :each do
1261
- @options, @config = new_option
1262
- @options.actions
1263
- end
1264
-
1265
- it "is enabled with #actions" do
1266
- @options.stub!(:on)
1267
- @options.should_receive(:on).with("--spec-debug", an_instance_of(String))
1268
- @options.actions
1269
- end
1270
-
1271
- it "enables the triggering the ruby debugger" do
1272
- @options.action_filters
1273
- @options.parse ["-S", "some spec"]
1274
-
1275
- @config[:debugger] = nil
1276
- @options.parse "--spec-debug"
1277
- @config[:debugger].should == true
1278
- end
1279
- end
1280
-
1281
1312
  describe "The --spec-gdb option" do
1282
1313
  before :each do
1283
1314
  @options, @config = new_option