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.
- data/.gitignore +27 -0
- data/Gemfile +4 -0
- data/README +39 -159
- data/Rakefile +4 -44
- data/bin/mkspec.bat +1 -0
- data/bin/mspec-ci.bat +1 -0
- data/bin/mspec-run.bat +1 -0
- data/bin/mspec-tag.bat +1 -0
- data/bin/mspec.bat +1 -0
- data/lib/mspec/commands/mkspec.rb +2 -2
- data/lib/mspec/commands/mspec-run.rb +4 -0
- data/lib/mspec/commands/mspec.rb +18 -3
- data/lib/mspec/guards.rb +1 -0
- data/lib/mspec/guards/block_device.rb +22 -0
- data/lib/mspec/guards/guard.rb +14 -2
- data/lib/mspec/helpers.rb +5 -5
- data/lib/mspec/helpers/const_lookup.rb +6 -1
- data/lib/mspec/helpers/datetime.rb +28 -0
- data/lib/mspec/helpers/ducktype.rb +4 -4
- data/lib/mspec/helpers/environment.rb +19 -2
- data/lib/mspec/helpers/fs.rb +5 -1
- data/lib/mspec/helpers/io.rb +39 -1
- data/lib/mspec/helpers/numeric.rb +89 -0
- data/lib/mspec/helpers/pack.rb +3 -0
- data/lib/mspec/helpers/ruby_exe.rb +53 -15
- data/lib/mspec/helpers/singleton_class.rb +7 -0
- data/lib/mspec/helpers/stasy.rb +33 -0
- data/lib/mspec/helpers/tmp.rb +16 -3
- data/lib/mspec/matchers.rb +8 -0
- data/lib/mspec/matchers/be_computed_by.rb +37 -0
- data/lib/mspec/matchers/be_computed_by_function.rb +35 -0
- data/lib/mspec/matchers/be_nan.rb +20 -0
- data/lib/mspec/matchers/be_valid_dns_name.rb +25 -0
- data/lib/mspec/matchers/have_data.rb +6 -5
- data/lib/mspec/matchers/have_private_method.rb +24 -0
- data/lib/mspec/matchers/have_singleton_method.rb +24 -0
- data/lib/mspec/matchers/infinity.rb +28 -0
- data/lib/mspec/matchers/match_yaml.rb +5 -5
- data/lib/mspec/matchers/raise_error.rb +5 -3
- data/lib/mspec/matchers/signed_zero.rb +28 -0
- data/lib/mspec/mocks/mock.rb +15 -9
- data/lib/mspec/mocks/object.rb +4 -0
- data/lib/mspec/mocks/proxy.rb +26 -1
- data/lib/mspec/runner/actions.rb +0 -1
- data/lib/mspec/runner/context.rb +18 -16
- data/lib/mspec/runner/formatters.rb +2 -0
- data/lib/mspec/runner/formatters/dotted.rb +13 -1
- data/lib/mspec/runner/formatters/junit.rb +96 -0
- data/lib/mspec/runner/formatters/profile.rb +70 -0
- data/lib/mspec/runner/mspec.rb +11 -0
- data/lib/mspec/runner/shared.rb +1 -1
- data/lib/mspec/utils/options.rb +33 -9
- data/lib/mspec/utils/ruby_name.rb +1 -1
- data/lib/mspec/utils/script.rb +2 -1
- data/lib/mspec/version.rb +1 -1
- data/mspec.gemspec +40 -0
- data/spec/commands/mkspec_spec.rb +4 -3
- data/spec/commands/mspec_ci_spec.rb +1 -6
- data/spec/commands/mspec_run_spec.rb +1 -6
- data/spec/commands/mspec_spec.rb +14 -6
- data/spec/commands/mspec_tag_spec.rb +28 -27
- data/spec/expectations/expectations_spec.rb +1 -1
- data/spec/expectations/should_spec.rb +4 -4
- data/spec/guards/background_spec.rb +2 -2
- data/spec/guards/block_device_spec.rb +46 -0
- data/spec/guards/bug_spec.rb +2 -3
- data/spec/guards/compliance_spec.rb +2 -2
- data/spec/guards/conflict_spec.rb +2 -2
- data/spec/guards/endian_spec.rb +2 -2
- data/spec/guards/extensions_spec.rb +2 -2
- data/spec/guards/feature_spec.rb +2 -2
- data/spec/guards/guard_spec.rb +80 -22
- data/spec/guards/noncompliance_spec.rb +2 -2
- data/spec/guards/platform_spec.rb +2 -2
- data/spec/guards/quarantine_spec.rb +2 -2
- data/spec/guards/runner_spec.rb +2 -2
- data/spec/guards/specified_spec.rb +2 -2
- data/spec/guards/superuser_spec.rb +2 -2
- data/spec/guards/support_spec.rb +2 -2
- data/spec/guards/tty_spec.rb +2 -2
- data/spec/guards/user_spec.rb +2 -2
- data/spec/guards/version_spec.rb +2 -2
- data/spec/helpers/argv_spec.rb +3 -2
- data/spec/helpers/const_lookup_spec.rb +3 -2
- data/spec/helpers/datetime_spec.rb +44 -0
- data/spec/helpers/ducktype_spec.rb +3 -2
- data/spec/helpers/encode_spec.rb +3 -2
- data/spec/helpers/enumerator_class_spec.rb +5 -5
- data/spec/helpers/environment_spec.rb +15 -3
- data/spec/helpers/fixture_spec.rb +3 -2
- data/spec/helpers/flunk_spec.rb +4 -3
- data/spec/helpers/fs_spec.rb +35 -18
- data/spec/helpers/hash_spec.rb +3 -2
- data/spec/helpers/io_spec.rb +75 -6
- data/spec/helpers/language_version_spec.rb +3 -2
- data/spec/helpers/mock_to_path_spec.rb +3 -2
- data/spec/helpers/numeric_spec.rb +25 -0
- data/spec/helpers/ruby_exe_spec.rb +115 -29
- data/spec/helpers/scratch_spec.rb +3 -1
- data/spec/helpers/stasy_spec.rb +59 -0
- data/spec/helpers/tmp_spec.rb +21 -4
- data/spec/matchers/base_spec.rb +2 -2
- data/spec/matchers/be_an_instance_of_spec.rb +2 -2
- data/spec/matchers/be_ancestor_of_spec.rb +2 -2
- data/spec/matchers/be_close_spec.rb +2 -2
- data/spec/matchers/be_computed_by_function_spec.rb +36 -0
- data/spec/matchers/be_computed_by_spec.rb +42 -0
- data/spec/matchers/be_empty_spec.rb +2 -2
- data/spec/matchers/be_false_spec.rb +3 -3
- data/spec/matchers/be_kind_of_spec.rb +2 -2
- data/spec/matchers/be_nan_spec.rb +28 -0
- data/spec/matchers/be_nil_spec.rb +3 -3
- data/spec/matchers/be_true_spec.rb +3 -3
- data/spec/matchers/be_valid_dns_name_spec.rb +50 -0
- data/spec/matchers/complain_spec.rb +2 -2
- data/spec/matchers/eql_spec.rb +2 -2
- data/spec/matchers/equal_element_spec.rb +2 -2
- data/spec/matchers/equal_spec.rb +2 -2
- data/spec/matchers/equal_utf16_spec.rb +2 -2
- data/spec/matchers/have_class_variable_spec.rb +3 -3
- data/spec/matchers/have_constant_spec.rb +2 -2
- data/spec/matchers/have_data_spec.rb +8 -5
- data/spec/matchers/have_instance_method_spec.rb +2 -2
- data/spec/matchers/have_instance_variable_spec.rb +3 -3
- data/spec/matchers/have_method_spec.rb +2 -2
- data/spec/matchers/have_private_instance_method_spec.rb +3 -3
- data/spec/matchers/have_private_method_spec.rb +44 -0
- data/spec/matchers/have_protected_instance_method_spec.rb +2 -2
- data/spec/matchers/have_public_instance_method_spec.rb +2 -2
- data/spec/matchers/have_singleton_method_spec.rb +45 -0
- data/spec/matchers/include_spec.rb +2 -2
- data/spec/matchers/infinity_spec.rb +34 -0
- data/spec/matchers/match_yaml_spec.rb +3 -3
- data/spec/matchers/output_spec.rb +2 -2
- data/spec/matchers/output_to_fd_spec.rb +2 -2
- data/spec/matchers/raise_error_spec.rb +24 -3
- data/spec/matchers/respond_to_spec.rb +2 -2
- data/spec/matchers/signed_zero_spec.rb +32 -0
- data/spec/matchers/stringsymboladapter_spec.rb +2 -2
- data/spec/mocks/mock_spec.rb +12 -12
- data/spec/mocks/proxy_spec.rb +1 -1
- data/spec/runner/actions/gdb_spec.rb +1 -1
- data/spec/runner/actions/tag_spec.rb +1 -1
- data/spec/runner/actions/taglist_spec.rb +1 -1
- data/spec/runner/context_spec.rb +27 -27
- data/spec/runner/example_spec.rb +1 -1
- data/spec/runner/exception_spec.rb +1 -1
- data/spec/runner/filters/tag_spec.rb +2 -2
- data/spec/runner/formatters/describe_spec.rb +1 -1
- data/spec/runner/formatters/dotted_spec.rb +2 -2
- data/spec/runner/formatters/html_spec.rb +2 -2
- data/spec/runner/formatters/junit_spec.rb +147 -0
- data/spec/runner/formatters/unit_spec.rb +2 -2
- data/spec/runner/formatters/yaml_spec.rb +3 -3
- data/spec/runner/mspec_spec.rb +22 -21
- data/spec/runner/shared_spec.rb +9 -1
- data/spec/runner/tag_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -7
- data/spec/utils/name_map_spec.rb +1 -2
- data/spec/utils/options_spec.rb +58 -27
- data/spec/utils/script_spec.rb +5 -13
- data/spec/utils/version_spec.rb +1 -1
- metadata +254 -64
- data/lib/mspec/helpers/bignum.rb +0 -5
- data/lib/mspec/helpers/fmode.rb +0 -15
- data/lib/mspec/helpers/infinity.rb +0 -5
- data/lib/mspec/helpers/metaclass.rb +0 -7
- data/lib/mspec/helpers/nan.rb +0 -5
- data/lib/mspec/runner/actions/debug.rb +0 -17
- data/spec/helpers/bignum_spec.rb +0 -11
- data/spec/helpers/fmode_spec.rb +0 -14
- data/spec/helpers/infinity_spec.rb +0 -8
- data/spec/helpers/nan_spec.rb +0 -8
- data/spec/runner/actions/debug_spec.rb +0 -62
data/lib/mspec/utils/script.rb
CHANGED
|
@@ -86,7 +86,7 @@ class MSpecScript
|
|
|
86
86
|
# first two numbers in RUBY_VERSION. For example, on MRI 1.8.6,
|
|
87
87
|
# the file name would be 'ruby.1.8.mspec'.
|
|
88
88
|
def load_default
|
|
89
|
-
|
|
89
|
+
load 'default.mspec'
|
|
90
90
|
|
|
91
91
|
if Object.const_defined?(:RUBY_ENGINE)
|
|
92
92
|
engine = RUBY_ENGINE
|
|
@@ -141,6 +141,7 @@ class MSpecScript
|
|
|
141
141
|
def signals
|
|
142
142
|
if config[:abort]
|
|
143
143
|
Signal.trap "INT" do
|
|
144
|
+
MSpec.actions :abort
|
|
144
145
|
puts "\nProcess aborted!"
|
|
145
146
|
exit! 1
|
|
146
147
|
end
|
data/lib/mspec/version.rb
CHANGED
data/mspec.gemspec
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.unshift File.expand_path('../lib', __FILE__)
|
|
3
|
+
require 'mspec/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |gem|
|
|
6
|
+
gem.name = "mspec"
|
|
7
|
+
gem.version = MSpec::VERSION.to_s
|
|
8
|
+
gem.authors = ["Brian Shirai"]
|
|
9
|
+
gem.email = ["bshirai@engineyard.com"]
|
|
10
|
+
gem.homepage = "http://rubyspec.org"
|
|
11
|
+
|
|
12
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) unless File.extname(f) == ".bat" }.compact
|
|
13
|
+
gem.files = `git ls-files`.split("\n")
|
|
14
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
15
|
+
gem.require_paths = ["lib"]
|
|
16
|
+
gem.description = <<-EOD
|
|
17
|
+
MSpec is a specialized framework for RubySpec.
|
|
18
|
+
EOD
|
|
19
|
+
gem.summary = <<-EOS
|
|
20
|
+
MSpec is a specialized framework that is syntax-compatible
|
|
21
|
+
with RSpec for basic things like describe, it blocks and
|
|
22
|
+
before, after actions.
|
|
23
|
+
|
|
24
|
+
MSpec contains additional features that assist in writing
|
|
25
|
+
the RubySpecs used by multiple Ruby implementations. Also,
|
|
26
|
+
MSpec attempts to use the simplest Ruby language features
|
|
27
|
+
so that beginning Ruby implementations can run it.
|
|
28
|
+
EOS
|
|
29
|
+
gem.has_rdoc = true
|
|
30
|
+
gem.extra_rdoc_files = %w[ README LICENSE ]
|
|
31
|
+
gem.rubygems_version = %q{1.3.5}
|
|
32
|
+
gem.rubyforge_project = 'http://rubyforge.org/projects/mspec'
|
|
33
|
+
|
|
34
|
+
gem.rdoc_options << '--title' << 'MSpec Gem' <<
|
|
35
|
+
'--main' << 'README' <<
|
|
36
|
+
'--line-numbers'
|
|
37
|
+
|
|
38
|
+
gem.add_development_dependency "rake", "~> 10.0"
|
|
39
|
+
gem.add_development_dependency "rspec", "~> 2.8"
|
|
40
|
+
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
require 'mspec/commands/mkspec'
|
|
3
3
|
|
|
4
4
|
|
|
@@ -194,8 +194,9 @@ describe MkSpec, "#write_spec" do
|
|
|
194
194
|
end
|
|
195
195
|
|
|
196
196
|
it "checks if specs exist for the method if the spec file exists" do
|
|
197
|
+
name = Regexp.escape(@script.ruby)
|
|
197
198
|
@script.should_receive(:`).with(
|
|
198
|
-
%r"#{
|
|
199
|
+
%r"#{name} #{MSPEC_HOME}/bin/mspec-run --dry-run -fs -e 'Object#inspect' spec/core/tcejbo/inspect_spec.rb")
|
|
199
200
|
@script.write_spec("spec/core/tcejbo/inspect_spec.rb", "Object#inspect", true)
|
|
200
201
|
end
|
|
201
202
|
|
|
@@ -335,7 +336,7 @@ end
|
|
|
335
336
|
|
|
336
337
|
describe MkSpec, ".main" do
|
|
337
338
|
before :each do
|
|
338
|
-
@script = mock("MkSpec"
|
|
339
|
+
@script = mock("MkSpec").as_null_object
|
|
339
340
|
MkSpec.stub!(:new).and_return(@script)
|
|
340
341
|
end
|
|
341
342
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
require 'mspec/runner/mspec'
|
|
3
3
|
require 'mspec/runner/filters/tag'
|
|
4
4
|
require 'mspec/commands/mspec-ci'
|
|
@@ -88,11 +88,6 @@ describe MSpecCI, "#options" do
|
|
|
88
88
|
@script.options
|
|
89
89
|
end
|
|
90
90
|
|
|
91
|
-
it "enables the debug option" do
|
|
92
|
-
@options.should_receive(:debug)
|
|
93
|
-
@script.options @argv
|
|
94
|
-
end
|
|
95
|
-
|
|
96
91
|
it "calls #custom_options" do
|
|
97
92
|
@script.should_receive(:custom_options).with(@options)
|
|
98
93
|
@script.options
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
require 'mspec/runner/mspec'
|
|
3
3
|
require 'mspec/commands/mspec-run'
|
|
4
4
|
|
|
@@ -118,11 +118,6 @@ describe MSpecRun, "#options" do
|
|
|
118
118
|
@script.options @argv
|
|
119
119
|
end
|
|
120
120
|
|
|
121
|
-
it "enables the debug option" do
|
|
122
|
-
@options.should_receive(:debug)
|
|
123
|
-
@script.options @argv
|
|
124
|
-
end
|
|
125
|
-
|
|
126
121
|
it "exits if there are no files to process" do
|
|
127
122
|
@options.should_receive(:parse).and_return([])
|
|
128
123
|
@script.should_receive(:exit)
|
data/spec/commands/mspec_spec.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
require 'yaml'
|
|
3
3
|
require 'mspec/commands/mspec'
|
|
4
4
|
|
|
@@ -108,9 +108,9 @@ describe MSpecMain, "#report" do
|
|
|
108
108
|
before :each do
|
|
109
109
|
@stdout, $stdout = $stdout, IOStub.new
|
|
110
110
|
|
|
111
|
-
@timer = mock("timer"
|
|
111
|
+
@timer = mock("timer").as_null_object
|
|
112
112
|
@timer.stub!(:format).and_return("Finished in 42 seconds")
|
|
113
|
-
@file = mock("file"
|
|
113
|
+
@file = mock("file").as_null_object
|
|
114
114
|
|
|
115
115
|
File.stub!(:delete)
|
|
116
116
|
YAML.stub!(:load)
|
|
@@ -244,6 +244,14 @@ describe MSpecMain, "#run" do
|
|
|
244
244
|
@script.run
|
|
245
245
|
end
|
|
246
246
|
|
|
247
|
+
it "adds config[:launch] to the exec options" do
|
|
248
|
+
@script.should_receive(:exec).with("ruby",
|
|
249
|
+
"-Xlaunch.option", "-v", %r"#{MSPEC_HOME}/bin/mspec-run$")
|
|
250
|
+
@config[:launch] << "-Xlaunch.option"
|
|
251
|
+
@script.options []
|
|
252
|
+
@script.run
|
|
253
|
+
end
|
|
254
|
+
|
|
247
255
|
it "calls #multi_exec if the command is 'ci' and the multi option is passed" do
|
|
248
256
|
@script.should_receive(:multi_exec).and_return do |arg|
|
|
249
257
|
arg.length.should == 3
|
|
@@ -293,11 +301,11 @@ describe "The -A, --valgrind option" do
|
|
|
293
301
|
@script.options
|
|
294
302
|
end
|
|
295
303
|
|
|
296
|
-
it "sets
|
|
304
|
+
it "sets :use_valgrind config option to true" do
|
|
297
305
|
["-A", "--valgrind"].each do |opt|
|
|
298
|
-
@config[:
|
|
306
|
+
@config[:use_valgrind] = false
|
|
299
307
|
@script.options [opt]
|
|
300
|
-
@config[:
|
|
308
|
+
@config[:use_valgrind].should be_true
|
|
301
309
|
end
|
|
302
310
|
end
|
|
303
311
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
require 'mspec/runner/mspec'
|
|
3
3
|
require 'mspec/commands/mspec-tag'
|
|
4
4
|
require 'mspec/runner/actions/tag'
|
|
@@ -98,11 +98,6 @@ describe MSpecTag, "#options" do
|
|
|
98
98
|
@script.options @argv
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
-
it "enables the debug option" do
|
|
102
|
-
@options.should_receive(:debug)
|
|
103
|
-
@script.options @argv
|
|
104
|
-
end
|
|
105
|
-
|
|
106
101
|
it "calls #custom_options" do
|
|
107
102
|
@script.should_receive(:custom_options).with(@options)
|
|
108
103
|
@script.options @argv
|
|
@@ -264,7 +259,7 @@ describe MSpecTag, "#run" do
|
|
|
264
259
|
before :each do
|
|
265
260
|
MSpec.stub!(:process)
|
|
266
261
|
|
|
267
|
-
options = mock("MSpecOptions"
|
|
262
|
+
options = mock("MSpecOptions").as_null_object
|
|
268
263
|
options.stub!(:parse).and_return(["one", "two"])
|
|
269
264
|
MSpecOptions.stub!(:new).and_return(options)
|
|
270
265
|
|
|
@@ -318,36 +313,42 @@ describe MSpecTag, "#register" do
|
|
|
318
313
|
@tl.stub!(:register)
|
|
319
314
|
end
|
|
320
315
|
|
|
321
|
-
it "
|
|
322
|
-
|
|
323
|
-
@script.register
|
|
316
|
+
it "raises an ArgumentError if no recognized action is given" do
|
|
317
|
+
@config[:tagger] = :totally_whack
|
|
318
|
+
lambda { @script.register }.should raise_error(ArgumentError)
|
|
324
319
|
end
|
|
325
320
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
@script.register
|
|
331
|
-
end
|
|
321
|
+
describe "when config[:tagger] is the default (:add)" do
|
|
322
|
+
before :each do
|
|
323
|
+
@config[:formatter] = false
|
|
324
|
+
end
|
|
332
325
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
end
|
|
326
|
+
it "creates a TagAction" do
|
|
327
|
+
TagAction.should_receive(:new).and_return(@t)
|
|
328
|
+
@script.register
|
|
329
|
+
end
|
|
338
330
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
331
|
+
it "creates a TagAction if config[:tagger] is :del" do
|
|
332
|
+
@config[:tagger] = :del
|
|
333
|
+
@config[:outcome] = :pass
|
|
334
|
+
TagAction.should_receive(:new).with(:del, :pass, "fake", nil, [], []).and_return(@t)
|
|
335
|
+
@script.register
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
it "calls #register on the TagAction instance" do
|
|
339
|
+
TagAction.should_receive(:new).and_return(@t)
|
|
340
|
+
@t.should_receive(:register)
|
|
341
|
+
@script.register
|
|
342
|
+
end
|
|
342
343
|
end
|
|
343
344
|
|
|
344
345
|
describe "when config[:tagger] is :list" do
|
|
345
346
|
before :each do
|
|
347
|
+
TagListAction.should_receive(:new).with(@config[:ltags]).and_return(@tl)
|
|
346
348
|
@config[:tagger] = :list
|
|
347
349
|
end
|
|
348
350
|
|
|
349
351
|
it "creates a TagListAction" do
|
|
350
|
-
TagListAction.should_receive(:new).with(@config[:ltags]).and_return(@tl)
|
|
351
352
|
@tl.should_receive(:register)
|
|
352
353
|
@script.register
|
|
353
354
|
end
|
|
@@ -365,11 +366,11 @@ describe MSpecTag, "#register" do
|
|
|
365
366
|
|
|
366
367
|
describe "when config[:tagger] is :list_all" do
|
|
367
368
|
before :each do
|
|
369
|
+
TagListAction.should_receive(:new).with(nil).and_return(@tl)
|
|
368
370
|
@config[:tagger] = :list_all
|
|
369
371
|
end
|
|
370
372
|
|
|
371
373
|
it "creates a TagListAction" do
|
|
372
|
-
TagListAction.should_receive(:new).with(nil).and_return(@tl)
|
|
373
374
|
@tl.should_receive(:register)
|
|
374
375
|
@script.register
|
|
375
376
|
end
|
|
@@ -387,12 +388,12 @@ describe MSpecTag, "#register" do
|
|
|
387
388
|
|
|
388
389
|
describe "when config[:tagger] is :purge" do
|
|
389
390
|
before :each do
|
|
391
|
+
TagPurgeAction.should_receive(:new).and_return(@tl)
|
|
390
392
|
MSpec.stub!(:register_mode)
|
|
391
393
|
@config[:tagger] = :purge
|
|
392
394
|
end
|
|
393
395
|
|
|
394
396
|
it "creates a TagPurgeAction" do
|
|
395
|
-
TagPurgeAction.should_receive(:new).and_return(@tl)
|
|
396
397
|
@tl.should_receive(:register)
|
|
397
398
|
@script.register
|
|
398
399
|
end
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
require 'rbconfig'
|
|
3
3
|
|
|
4
|
-
describe MSpec do
|
|
4
|
+
describe "MSpec" do
|
|
5
5
|
before :all do
|
|
6
|
-
path =
|
|
7
|
-
exe =
|
|
6
|
+
path = RbConfig::CONFIG['bindir']
|
|
7
|
+
exe = RbConfig::CONFIG['ruby_install_name']
|
|
8
8
|
file = File.dirname(__FILE__) + '/should.rb'
|
|
9
9
|
@out = `#{path}/#{exe} #{file}`
|
|
10
10
|
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'mspec/guards'
|
|
3
|
+
|
|
4
|
+
describe Object, "#with_block_device" do
|
|
5
|
+
before :each do
|
|
6
|
+
ScratchPad.clear
|
|
7
|
+
|
|
8
|
+
@guard = BlockDeviceGuard.new
|
|
9
|
+
BlockDeviceGuard.stub!(:new).and_return(@guard)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
platform_is_not :freebsd, :windows do
|
|
13
|
+
it "yields if block device is available" do
|
|
14
|
+
@guard.should_receive(:`).and_return("block devices")
|
|
15
|
+
with_block_device { ScratchPad.record :yield }
|
|
16
|
+
ScratchPad.recorded.should == :yield
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "does not yield if block device is not available" do
|
|
20
|
+
@guard.should_receive(:`).and_return(nil)
|
|
21
|
+
with_block_device { ScratchPad.record :yield }
|
|
22
|
+
ScratchPad.recorded.should_not == :yield
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
platform_is :freebsd, :windows do
|
|
27
|
+
it "does not yield, since platform does not support block devices" do
|
|
28
|
+
@guard.should_not_receive(:`)
|
|
29
|
+
with_block_device { ScratchPad.record :yield }
|
|
30
|
+
ScratchPad.recorded.should_not == :yield
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "sets the name of the guard to :with_block_device" do
|
|
35
|
+
with_block_device { }
|
|
36
|
+
@guard.name.should == :with_block_device
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "calls #unregister even when an exception is raised in the guard block" do
|
|
40
|
+
@guard.should_receive(:match?).and_return(true)
|
|
41
|
+
@guard.should_receive(:unregister)
|
|
42
|
+
lambda do
|
|
43
|
+
with_block_device { raise Exception }
|
|
44
|
+
end.should raise_error(Exception)
|
|
45
|
+
end
|
|
46
|
+
end
|
data/spec/guards/bug_spec.rb
CHANGED
data/spec/guards/endian_spec.rb
CHANGED
data/spec/guards/feature_spec.rb
CHANGED
data/spec/guards/guard_spec.rb
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
|
-
require
|
|
2
|
-
require 'mspec/
|
|
3
|
-
require 'mspec/guards/guard'
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'mspec/guards'
|
|
4
3
|
require 'rbconfig'
|
|
5
4
|
|
|
5
|
+
describe SpecGuard, "#ruby_version_override=" do
|
|
6
|
+
after :each do
|
|
7
|
+
SpecGuard.ruby_version_override = nil
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "returns nil by default" do
|
|
11
|
+
SpecGuard.ruby_version_override.should be_nil
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "returns the value set by #ruby_version_override=" do
|
|
15
|
+
SpecGuard.ruby_version_override = "8.3.2"
|
|
16
|
+
SpecGuard.ruby_version_override.should == "8.3.2"
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
6
20
|
describe SpecGuard, ".ruby_version" do
|
|
7
|
-
before :
|
|
21
|
+
before :each do
|
|
8
22
|
@ruby_version = Object.const_get :RUBY_VERSION
|
|
9
23
|
@ruby_patchlevel = Object.const_get :RUBY_PATCHLEVEL
|
|
10
24
|
|
|
@@ -12,7 +26,7 @@ describe SpecGuard, ".ruby_version" do
|
|
|
12
26
|
Object.const_set :RUBY_PATCHLEVEL, 71
|
|
13
27
|
end
|
|
14
28
|
|
|
15
|
-
after :
|
|
29
|
+
after :each do
|
|
16
30
|
Object.const_set :RUBY_VERSION, @ruby_version
|
|
17
31
|
Object.const_set :RUBY_PATCHLEVEL, @ruby_patchlevel
|
|
18
32
|
end
|
|
@@ -45,6 +59,45 @@ describe SpecGuard, ".ruby_version" do
|
|
|
45
59
|
it "returns major for :major" do
|
|
46
60
|
SpecGuard.ruby_version(:major).should == "8"
|
|
47
61
|
end
|
|
62
|
+
|
|
63
|
+
describe "with ruby_version_override set" do
|
|
64
|
+
before :each do
|
|
65
|
+
SpecGuard.ruby_version_override = "8.3.2"
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
after :each do
|
|
69
|
+
SpecGuard.ruby_version_override = nil
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "returns the version and patchlevel for :full" do
|
|
73
|
+
SpecGuard.ruby_version(:full).should == "8.3.2.71"
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "returns 0 for negative RUBY_PATCHLEVEL values" do
|
|
77
|
+
Object.const_set :RUBY_PATCHLEVEL, -1
|
|
78
|
+
SpecGuard.ruby_version(:full).should == "8.3.2.0"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "returns major.minor.tiny for :tiny" do
|
|
82
|
+
SpecGuard.ruby_version(:tiny).should == "8.3.2"
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "returns major.minor.tiny for :teeny" do
|
|
86
|
+
SpecGuard.ruby_version(:tiny).should == "8.3.2"
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it "returns major.minor for :minor" do
|
|
90
|
+
SpecGuard.ruby_version(:minor).should == "8.3"
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it "defaults to :minor" do
|
|
94
|
+
SpecGuard.ruby_version.should == "8.3"
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it "returns major for :major" do
|
|
98
|
+
SpecGuard.ruby_version(:major).should == "8"
|
|
99
|
+
end
|
|
100
|
+
end
|
|
48
101
|
end
|
|
49
102
|
|
|
50
103
|
describe SpecGuard, "#yield?" do
|
|
@@ -158,6 +211,11 @@ describe SpecGuard, "#implementation?" do
|
|
|
158
211
|
@guard.implementation?(:maglev).should == true
|
|
159
212
|
end
|
|
160
213
|
|
|
214
|
+
it "returns true if passed :topaz and RUBY_NAME == 'topaz'" do
|
|
215
|
+
Object.const_set :RUBY_NAME, 'topaz'
|
|
216
|
+
@guard.implementation?(:topaz).should == true
|
|
217
|
+
end
|
|
218
|
+
|
|
161
219
|
it "returns true if passed :ruby and RUBY_NAME matches /^ruby/" do
|
|
162
220
|
Object.const_set :RUBY_NAME, 'ruby'
|
|
163
221
|
@guard.implementation?(:ruby).should == true
|
|
@@ -237,12 +295,12 @@ describe SpecGuard, "#platform?" do
|
|
|
237
295
|
@guard.platform?(:windows).should == true
|
|
238
296
|
end
|
|
239
297
|
|
|
240
|
-
it "returns false when arg is not :windows and
|
|
298
|
+
it "returns false when arg is not :windows and RbConfig::CONFIG['host_os'] contains 'mswin'" do
|
|
241
299
|
Object.const_set :RUBY_PLATFORM, 'i386-mswin32'
|
|
242
300
|
@guard.platform?(:linux).should == false
|
|
243
301
|
end
|
|
244
302
|
|
|
245
|
-
it "returns false when arg is not :windows and
|
|
303
|
+
it "returns false when arg is not :windows and RbConfig::CONFIG['host_os'] contains 'mingw'" do
|
|
246
304
|
Object.const_set :RUBY_PLATFORM, 'i386-mingw32'
|
|
247
305
|
@guard.platform?(:linux).should == false
|
|
248
306
|
end
|
|
@@ -273,12 +331,12 @@ describe SpecGuard, "#platform? on JRuby" do
|
|
|
273
331
|
end
|
|
274
332
|
|
|
275
333
|
it "returns true when arg is :windows and RUBY_PLATFORM contains 'java' and os?(:windows) is true" do
|
|
276
|
-
|
|
334
|
+
RbConfig::CONFIG.stub!(:[]).and_return('mswin32')
|
|
277
335
|
@guard.platform?(:windows).should == true
|
|
278
336
|
end
|
|
279
337
|
|
|
280
338
|
it "returns true when RUBY_PLATFORM contains 'java' and os?(argument) is true" do
|
|
281
|
-
|
|
339
|
+
RbConfig::CONFIG.stub!(:[]).and_return('amiga')
|
|
282
340
|
@guard.platform?(:amiga).should == true
|
|
283
341
|
end
|
|
284
342
|
end
|
|
@@ -300,42 +358,42 @@ end
|
|
|
300
358
|
describe SpecGuard, "#os?" do
|
|
301
359
|
before :each do
|
|
302
360
|
@guard = SpecGuard.new
|
|
303
|
-
|
|
361
|
+
RbConfig::CONFIG.stub!(:[]).and_return('unreal')
|
|
304
362
|
end
|
|
305
363
|
|
|
306
|
-
it "returns true if argument matches
|
|
364
|
+
it "returns true if argument matches RbConfig::CONFIG['host_os']" do
|
|
307
365
|
@guard.os?(:unreal).should == true
|
|
308
366
|
end
|
|
309
367
|
|
|
310
|
-
it "returns true if any argument matches
|
|
368
|
+
it "returns true if any argument matches RbConfig::CONFIG['host_os']" do
|
|
311
369
|
@guard.os?(:bsd, :unreal, :amiga).should == true
|
|
312
370
|
end
|
|
313
371
|
|
|
314
|
-
it "returns false if no argument matches
|
|
372
|
+
it "returns false if no argument matches RbConfig::CONFIG['host_os']" do
|
|
315
373
|
@guard.os?(:bsd, :netbsd, :amiga, :msdos).should == false
|
|
316
374
|
end
|
|
317
375
|
|
|
318
|
-
it "returns false if argument does not match
|
|
376
|
+
it "returns false if argument does not match RbConfig::CONFIG['host_os']" do
|
|
319
377
|
@guard.os?(:amiga).should == false
|
|
320
378
|
end
|
|
321
379
|
|
|
322
|
-
it "returns true when arg is :windows and
|
|
323
|
-
|
|
380
|
+
it "returns true when arg is :windows and RbConfig::CONFIG['host_os'] contains 'mswin'" do
|
|
381
|
+
RbConfig::CONFIG.stub!(:[]).and_return('i386-mswin32')
|
|
324
382
|
@guard.os?(:windows).should == true
|
|
325
383
|
end
|
|
326
384
|
|
|
327
|
-
it "returns true when arg is :windows and
|
|
328
|
-
|
|
385
|
+
it "returns true when arg is :windows and RbConfig::CONFIG['host_os'] contains 'mingw'" do
|
|
386
|
+
RbConfig::CONFIG.stub!(:[]).and_return('i386-mingw32')
|
|
329
387
|
@guard.os?(:windows).should == true
|
|
330
388
|
end
|
|
331
389
|
|
|
332
|
-
it "returns false when arg is not :windows and
|
|
333
|
-
|
|
390
|
+
it "returns false when arg is not :windows and RbConfig::CONFIG['host_os'] contains 'mswin'" do
|
|
391
|
+
RbConfig::CONFIG.stub!(:[]).and_return('i386-mingw32')
|
|
334
392
|
@guard.os?(:linux).should == false
|
|
335
393
|
end
|
|
336
394
|
|
|
337
|
-
it "returns false when arg is not :windows and
|
|
338
|
-
|
|
395
|
+
it "returns false when arg is not :windows and RbConfig::CONFIG['host_os'] contains 'mingw'" do
|
|
396
|
+
RbConfig::CONFIG.stub!(:[]).and_return('i386-mingw32')
|
|
339
397
|
@guard.os?(:linux).should == false
|
|
340
398
|
end
|
|
341
399
|
end
|