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,5 +1,6 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
- require 'mspec/helpers/language_version'
1
+ require 'spec_helper'
2
+ require 'mspec/guards'
3
+ require 'mspec/helpers'
3
4
 
4
5
  describe Object, "#language_version" do
5
6
  before :all do
@@ -1,5 +1,6 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
- require 'mspec/helpers/mock_to_path'
1
+ require 'spec_helper'
2
+ require 'mspec/guards'
3
+ require 'mspec/helpers'
3
4
 
4
5
  describe Object, "#mock_to_path" do
5
6
  it "returns an object that responds to #to_path" do
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+ require 'mspec/guards'
3
+ require 'mspec/helpers'
4
+
5
+ describe Object, "#bignum_value" do
6
+ it "returns a value that is an instance of Bignum on any platform" do
7
+ bignum_value.should == 0x8000_0000_0000_0000
8
+ end
9
+
10
+ it "returns the default value incremented by the argument" do
11
+ bignum_value(42).should == 0x8000_0000_0000_002a
12
+ end
13
+ end
14
+
15
+ describe Object, "#nan_value" do
16
+ it "returns NaN" do
17
+ nan_value.nan?.should be_true
18
+ end
19
+ end
20
+
21
+ describe Object, "#infinity_value" do
22
+ it "returns Infinity" do
23
+ infinity_value.infinite?.should == 1
24
+ end
25
+ end
@@ -1,5 +1,6 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
- require 'mspec/helpers/ruby_exe'
1
+ require 'spec_helper'
2
+ require 'mspec/guards'
3
+ require 'mspec/helpers'
3
4
  require 'rbconfig'
4
5
 
5
6
  class RubyExeSpecs
@@ -31,11 +32,6 @@ describe "#ruby_exe_options" do
31
32
  @script.ruby_exe_options(:env).should == "kowabunga"
32
33
  end
33
34
 
34
- it "returns 'bin/rbx' when passed :engine and RUBY_NAME is 'rbx'" do
35
- Object.const_set :RUBY_NAME, 'rbx'
36
- @script.ruby_exe_options(:engine).should == 'bin/rbx'
37
- end
38
-
39
35
  it "returns 'bin/jruby' when passed :engine and RUBY_NAME is 'jruby'" do
40
36
  Object.const_set :RUBY_NAME, 'jruby'
41
37
  @script.ruby_exe_options(:engine).should == 'bin/jruby'
@@ -51,17 +47,46 @@ describe "#ruby_exe_options" do
51
47
  @script.ruby_exe_options(:engine).should == 'maglev-ruby'
52
48
  end
53
49
 
50
+ it "returns 'topaz' when passed :engine and RUBY_NAME is 'topaz'" do
51
+ Object.const_set :RUBY_NAME, 'topaz'
52
+ @script.ruby_exe_options(:engine).should == 'topaz'
53
+ end
54
+
54
55
  it "returns RUBY_NAME + $(EXEEXT) when passed :name" do
55
- bin = RUBY_NAME + (Config::CONFIG['EXEEXT'] || Config::CONFIG['exeext'] || '')
56
+ bin = RUBY_NAME + (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '')
56
57
  name = File.join ".", bin
57
58
  @script.ruby_exe_options(:name).should == name
58
59
  end
59
60
 
60
61
  it "returns $(bindir)/$(RUBY_INSTALL_NAME) + $(EXEEXT) when passed :install_name" do
61
- bin = Config::CONFIG['RUBY_INSTALL_NAME'] + (Config::CONFIG['EXEEXT'] || Config::CONFIG['exeext'] || '')
62
- name = File.join Config::CONFIG['bindir'], bin
62
+ bin = RbConfig::CONFIG['RUBY_INSTALL_NAME'] + (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '')
63
+ name = File.join RbConfig::CONFIG['bindir'], bin
63
64
  @script.ruby_exe_options(:install_name).should == name
64
65
  end
66
+
67
+ describe "under Rubinius" do
68
+ before :each do
69
+ @ruby_version = RUBY_VERSION
70
+ end
71
+
72
+ after :each do
73
+ Object.const_set :RUBY_VERSION, @ruby_version
74
+ end
75
+
76
+ it "returns 'bin/rbx' when passed :engine, RUBY_NAME is 'rbx' and RUBY_VERSION < 1.9" do
77
+ Object.const_set :RUBY_VERSION, "1.8.7"
78
+ Object.const_set :RUBY_NAME, 'rbx'
79
+
80
+ @script.ruby_exe_options(:engine).should == 'bin/rbx'
81
+ end
82
+
83
+ it "returns 'bin/rbx -X19' when passed :engine, RUBY_NAME is 'rbx' and RUBY_VERSION >= 1.9" do
84
+ Object.const_set :RUBY_VERSION, "1.9.2"
85
+ Object.const_set :RUBY_NAME, 'rbx'
86
+
87
+ @script.ruby_exe_options(:engine).should == 'bin/rbx -X19'
88
+ end
89
+ end
65
90
  end
66
91
 
67
92
  describe "#resolve_ruby_exe" do
@@ -85,6 +110,7 @@ describe "#resolve_ruby_exe" do
85
110
  @script.should_receive(:ruby_exe_options).and_return(@name)
86
111
  File.should_receive(:exists?).with(@name).and_return(true)
87
112
  File.should_receive(:executable?).with(@name).and_return(true)
113
+ File.should_receive(:expand_path).with(@name).and_return(@name)
88
114
  @script.resolve_ruby_exe.should == @name
89
115
  end
90
116
 
@@ -93,16 +119,26 @@ describe "#resolve_ruby_exe" do
93
119
  @script.should_receive(:ruby_exe_options).and_return(@name)
94
120
  File.should_receive(:exists?).with(@name).and_return(true)
95
121
  File.should_not_receive(:executable?)
122
+ File.should_receive(:expand_path).with(@name).and_return(@name)
96
123
  @script.resolve_ruby_exe.should == @name
97
124
  end
98
125
 
126
+ it "expands the path portion of the result of #ruby_exe_options" do
127
+ PlatformGuard.stub!(:windows?).and_return(false)
128
+ @script.should_receive(:ruby_exe_options).and_return("#{@name} -Xfoo")
129
+ File.should_receive(:exists?).with(@name).and_return(true)
130
+ File.should_receive(:executable?).with(@name).and_return(true)
131
+ File.should_receive(:expand_path).with(@name).and_return("/usr/bin/#{@name}")
132
+ @script.resolve_ruby_exe.should == "/usr/bin/#{@name} -Xfoo"
133
+ end
134
+
99
135
  it "returns nil if no exe is found" do
100
136
  File.should_receive(:exists?).at_least(:once).and_return(false)
101
137
  @script.resolve_ruby_exe.should be_nil
102
138
  end
103
139
  end
104
140
 
105
- describe Object, "#ruby_exe" do
141
+ describe Object, "#ruby_cmd" do
106
142
  before :all do
107
143
  @verbose = $VERBOSE
108
144
  $VERBOSE = nil
@@ -125,35 +161,85 @@ describe Object, "#ruby_exe" do
125
161
  $VERBOSE = @verbose
126
162
  end
127
163
 
128
- it "executes the argument if it is a file that exists" do
164
+ it "returns a command that runs the given file if it is a file that exists" do
129
165
  File.should_receive(:exists?).with(@file).and_return(true)
130
- @script.should_receive(:`).with("ruby_spec_exe -w -Q some/ruby/file.rb")
131
- @script.ruby_exe @file
166
+ @script.ruby_cmd(@file).should == "ruby_spec_exe -w -Q some/ruby/file.rb"
132
167
  end
133
168
 
134
- it "executes the file with options and arguments" do
169
+ it "includes the given options and arguments with a file" do
135
170
  File.should_receive(:exists?).with(@file).and_return(true)
136
- @script.should_receive(:`).with(
137
- "ruby_spec_exe -w -Q -w -Cdir some/ruby/file.rb < file.txt")
138
- @script.ruby_exe @file, :options => "-w -Cdir", :args => "< file.txt"
171
+ @script.ruby_cmd(@file, :options => "-w -Cdir", :args => "< file.txt").should ==
172
+ "ruby_spec_exe -w -Q -w -Cdir some/ruby/file.rb < file.txt"
139
173
  end
140
174
 
141
- it "executes the argument with -e" do
175
+ it "returns a command that runs code using -e" do
142
176
  File.should_receive(:exists?).with(@code).and_return(false)
143
- @script.should_receive(:`).with(
144
- %(ruby_spec_exe -w -Q -e "some \\"real\\" 'ruby' code"))
145
- @script.ruby_exe @code
177
+ @script.ruby_cmd(@code).should == %(ruby_spec_exe -w -Q -e "some \\"real\\" 'ruby' code")
146
178
  end
147
179
 
148
- it "executes the code with options and arguments" do
180
+ it "includes the given options and arguments with -e" do
149
181
  File.should_receive(:exists?).with(@code).and_return(false)
150
- @script.should_receive(:`).with(
151
- %(ruby_spec_exe -w -Q -W0 -Cdir -e "some \\"real\\" 'ruby' code" < file.txt))
152
- @script.ruby_exe @code, :options => "-W0 -Cdir", :args => "< file.txt"
182
+ @script.ruby_cmd(@code, :options => "-W0 -Cdir", :args => "< file.txt").should ==
183
+ %(ruby_spec_exe -w -Q -W0 -Cdir -e "some \\"real\\" 'ruby' code" < file.txt)
153
184
  end
154
185
 
155
- it "executes with options and arguments but without code or file" do
156
- @script.should_receive(:`).with("ruby_spec_exe -w -Q -c > file.txt")
157
- @script.ruby_exe nil, :options => "-c", :args => "> file.txt"
186
+ it "returns a command with options and arguments but without code or file" do
187
+ @script.ruby_cmd(nil, :options => "-c", :args => "> file.txt").should ==
188
+ "ruby_spec_exe -w -Q -c > file.txt"
189
+ end
190
+ end
191
+
192
+ describe Object, "#ruby_exe" do
193
+ before :all do
194
+ @script = RubyExeSpecs.new
195
+ end
196
+
197
+ before :each do
198
+ @script.stub!(:`)
199
+ end
200
+
201
+ it "executes (using `) the result of calling #ruby_cmd with the given arguments" do
202
+ code = "code"
203
+ options = {}
204
+ @script.should_receive(:ruby_cmd).with(code, options).and_return("ruby_cmd")
205
+ @script.should_receive(:`).with("ruby_cmd")
206
+ @script.ruby_exe(code, options)
207
+ end
208
+
209
+ describe "with :dir option" do
210
+ it "executes the command in the given working directory" do
211
+ Dir.should_receive(:chdir).with("tmp")
212
+ @script.ruby_exe nil, :dir => "tmp"
213
+ end
214
+ end
215
+
216
+ describe "with :env option" do
217
+ it "preserves the values of existing ENV keys" do
218
+ ENV["ABC"] = "123"
219
+ ENV.should_receive(:[]).with("RUBY_FLAGS")
220
+ ENV.should_receive(:[]).with("ABC")
221
+ @script.ruby_exe nil, :env => { :ABC => "xyz" }
222
+ end
223
+
224
+ it "adds the :env entries to ENV" do
225
+ ENV.should_receive(:[]=).with("ABC", "xyz")
226
+ @script.ruby_exe nil, :env => { :ABC => "xyz" }
227
+ end
228
+
229
+ it "deletes the :env entries in ENV when an exception is raised" do
230
+ ENV.should_receive(:delete).with("XYZ")
231
+ @script.ruby_exe nil, :env => { :XYZ => "xyz" }
232
+ end
233
+
234
+ it "resets the values of existing ENV keys when an exception is raised" do
235
+ ENV["ABC"] = "123"
236
+ ENV.should_receive(:[]=).with("ABC", "xyz")
237
+ ENV.should_receive(:[]=).with("ABC", "123")
238
+
239
+ @script.should_receive(:`).and_raise(Exception)
240
+ lambda do
241
+ @script.ruby_exe nil, :env => { :ABC => "xyz" }
242
+ end.should raise_error(Exception)
243
+ end
158
244
  end
159
245
  end
@@ -1,4 +1,6 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
+ require 'mspec/guards'
3
+ require 'mspec/helpers'
2
4
 
3
5
  describe ScratchPad do
4
6
  it "records an object and returns a previously recorded object" do
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+ require 'mspec/guards'
3
+ require 'mspec/helpers'
4
+
5
+ describe Object, "#stasy when RUBY_VERSION < 1.9" do
6
+ before :all do
7
+ @ruby_version = Object.const_get :RUBY_VERSION
8
+
9
+ Object.const_set :RUBY_VERSION, "1.8.7"
10
+ end
11
+
12
+ after :all do
13
+ Object.const_set :RUBY_VERSION, @ruby_version
14
+ end
15
+
16
+ it "returns a String when passed a String" do
17
+ stasy("nom").should == "nom"
18
+ end
19
+
20
+ it "returns a String when passed a Symbol" do
21
+ stasy(:some).should == "some"
22
+ end
23
+
24
+ it "returns an Array of Strings when passed an Array of Strings" do
25
+ stasy("nom", "nom").should == ["nom", "nom"]
26
+ end
27
+
28
+ it "returns an Array of Strings when passed an Array of Symbols" do
29
+ stasy(:some, :thing).should == ["some", "thing"]
30
+ end
31
+ end
32
+
33
+ describe Object, "#stasy when RUBY_VERSION >= 1.9.0" do
34
+ before :all do
35
+ @ruby_version = Object.const_get :RUBY_VERSION
36
+
37
+ Object.const_set :RUBY_VERSION, "1.9.0"
38
+ end
39
+
40
+ after :all do
41
+ Object.const_set :RUBY_VERSION, @ruby_version
42
+ end
43
+
44
+ it "returns a Symbol when passed a String" do
45
+ stasy("nom").should == :nom
46
+ end
47
+
48
+ it "returns a Symbol when passed a Symbol" do
49
+ stasy(:some).should == :some
50
+ end
51
+
52
+ it "returns an Array of Symbols when passed an Array of Strings" do
53
+ stasy("some", "thing").should == [:some, :thing]
54
+ end
55
+
56
+ it "returns an Array of Symbols when passed an Array of Symbols" do
57
+ stasy(:nom, :nom).should == [:nom, :nom]
58
+ end
59
+ end
@@ -1,10 +1,27 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
- require 'mspec/helpers/tmp'
1
+ require 'spec_helper'
2
+ require 'mspec/guards'
3
+ require 'mspec/helpers'
3
4
 
4
5
  describe Object, "#tmp" do
6
+ before :all do
7
+ @dir = "#{File.expand_path(Dir.pwd)}/rubyspec_temp"
8
+ end
9
+
5
10
  it "returns a name relative to the current working directory" do
6
- dir = "#{File.expand_path(Dir.pwd)}/rubyspec_temp"
11
+ tmp("test.txt").should == "#{@dir}/#{SPEC_TEMP_UNIQUIFIER}-test.txt"
12
+ end
13
+
14
+ it "returns a 'unique' name on repeated calls" do
15
+ a = tmp("text.txt")
16
+ b = tmp("text.txt")
17
+ a.should_not == b
18
+ end
19
+
20
+ it "does not 'uniquify' the name if requested not to" do
21
+ tmp("test.txt", false).should == "#{@dir}/test.txt"
22
+ end
7
23
 
8
- tmp("test.txt").should == dir + "/test.txt"
24
+ it "returns the name of the temporary directory when passed an empty string" do
25
+ tmp("").should == "#{@dir}/"
9
26
  end
10
27
  end
@@ -1,6 +1,6 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
  require 'mspec/expectations/expectations'
3
- require 'mspec/matchers/base'
3
+ require 'mspec/matchers'
4
4
  require 'time'
5
5
 
6
6
  describe SpecPositiveOperatorMatcher, "== operator" do
@@ -1,6 +1,6 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
  require 'mspec/expectations/expectations'
3
- require 'mspec/matchers/be_an_instance_of'
3
+ require 'mspec/matchers'
4
4
 
5
5
  module BeAnInOfSpecs
6
6
  class A
@@ -1,6 +1,6 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
  require 'mspec/expectations/expectations'
3
- require 'mspec/matchers/be_ancestor_of'
3
+ require 'mspec/matchers'
4
4
 
5
5
  class Parent; end
6
6
  class Child < Parent; end
@@ -1,6 +1,6 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
  require 'mspec/expectations/expectations'
3
- require 'mspec/matchers/be_close'
3
+ require 'mspec/matchers'
4
4
 
5
5
  # Adapted from RSpec 1.0.8
6
6
  describe BeCloseMatcher do
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+ require 'mspec/matchers'
3
+
4
+ describe BeComputedByFunctionMatcher do
5
+ it "matches when all entries in the Array compute" do
6
+ array = [ ["%2d", 65, "65"],
7
+ ["%04d", 90, "0090"] ]
8
+ BeComputedByFunctionMatcher.new(:sprintf).matches?(array).should be_true
9
+ end
10
+
11
+ it "matches when all entries in the Array with arguments compute" do
12
+ array = [ ["%2d", "65"],
13
+ ["%04d", "0065"] ]
14
+ BeComputedByFunctionMatcher.new(:sprintf, 65).matches?(array).should be_true
15
+ end
16
+
17
+ it "does not match when any entry in the Array does not compute" do
18
+ array = [ ["%2d", 65, "65"],
19
+ ["%04d", 90, "00090"] ]
20
+ BeComputedByFunctionMatcher.new(:sprintf).matches?(array).should be_false
21
+ end
22
+
23
+ it "does not match when any entry in the Array with arguments does not compute" do
24
+ array = [ ["%2d", "65"],
25
+ ["%04d", "0065"] ]
26
+ BeComputedByFunctionMatcher.new(:sprintf, 91).matches?(array).should be_false
27
+ end
28
+
29
+ it "provides a useful failure message" do
30
+ array = [ ["%2d", 90, "65"],
31
+ ["%04d", 90, "00090"] ]
32
+ matcher = BeComputedByFunctionMatcher.new(:sprintf)
33
+ matcher.matches?(array)
34
+ matcher.failure_message.should == ["Expected \"65\"", "to be computed by sprintf(\"%2d\", 90)"]
35
+ end
36
+ end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+ require 'mspec/matchers'
3
+
4
+ describe BeComputedByMatcher do
5
+ it "matches when all entries in the Array compute" do
6
+ array = [ [65, "A"],
7
+ [90, "Z"] ]
8
+ BeComputedByMatcher.new(:chr).matches?(array).should be_true
9
+ end
10
+
11
+ it "matches when all entries in the Array with arguments compute" do
12
+ array = [ [1, 2, 3],
13
+ [2, 4, 6] ]
14
+ BeComputedByMatcher.new(:+).matches?(array).should be_true
15
+ end
16
+
17
+ it "does not match when any entry in the Array does not compute" do
18
+ array = [ [65, "A" ],
19
+ [91, "Z" ] ]
20
+ BeComputedByMatcher.new(:chr).matches?(array).should be_false
21
+ end
22
+
23
+ it "accepts an argument list to apply to each method call" do
24
+ array = [ [65, "1000001" ],
25
+ [90, "1011010" ] ]
26
+ BeComputedByMatcher.new(:to_s, 2).matches?(array).should be_true
27
+ end
28
+
29
+ it "does not match when any entry in the Array with arguments does not compute" do
30
+ array = [ [1, 2, 3],
31
+ [2, 4, 7] ]
32
+ BeComputedByMatcher.new(:+).matches?(array).should be_false
33
+ end
34
+
35
+ it "provides a useful failure message" do
36
+ array = [ [65, "A" ],
37
+ [91, "Z" ] ]
38
+ matcher = BeComputedByMatcher.new(:chr)
39
+ matcher.matches?(array)
40
+ matcher.failure_message.should == ["Expected \"Z\"", "to be computed by 91.chr (computed \"[\" instead)"]
41
+ end
42
+ end