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/mocks/object.rb
CHANGED
data/lib/mspec/mocks/proxy.rb
CHANGED
|
@@ -7,6 +7,7 @@ class MockObject
|
|
|
7
7
|
def method_missing(sym, *args, &block)
|
|
8
8
|
@null ? self : super
|
|
9
9
|
end
|
|
10
|
+
private :method_missing
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
class NumericMockObject < Numeric
|
|
@@ -23,6 +24,29 @@ class NumericMockObject < Numeric
|
|
|
23
24
|
end
|
|
24
25
|
end
|
|
25
26
|
|
|
27
|
+
class MockIntObject
|
|
28
|
+
def initialize(val)
|
|
29
|
+
@value = val
|
|
30
|
+
@calls = 0
|
|
31
|
+
|
|
32
|
+
key = [self, :to_int]
|
|
33
|
+
|
|
34
|
+
Mock.objects[key] = self
|
|
35
|
+
Mock.mocks[key] << self
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
attr_reader :calls
|
|
39
|
+
|
|
40
|
+
def to_int
|
|
41
|
+
@calls += 1
|
|
42
|
+
@value
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def count
|
|
46
|
+
[:at_least, 1]
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
26
50
|
class MockProxy
|
|
27
51
|
attr_reader :raising, :yielding
|
|
28
52
|
|
|
@@ -105,7 +129,8 @@ class MockProxy
|
|
|
105
129
|
def with(*args)
|
|
106
130
|
raise ArgumentError, "you must specify the expected arguments" if args.empty?
|
|
107
131
|
@arguments = *args
|
|
108
|
-
|
|
132
|
+
behaves_like_ruby_1_9 = *[]
|
|
133
|
+
if (behaves_like_ruby_1_9)
|
|
109
134
|
@arguments = @arguments.first if @arguments.length <= 1
|
|
110
135
|
end
|
|
111
136
|
self
|
data/lib/mspec/runner/actions.rb
CHANGED
data/lib/mspec/runner/context.rb
CHANGED
|
@@ -197,24 +197,26 @@ class ContextState
|
|
|
197
197
|
|
|
198
198
|
if protect "before :all", pre(:all)
|
|
199
199
|
@examples.each do |state|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
200
|
+
MSpec.repeat do
|
|
201
|
+
@state = state
|
|
202
|
+
example = state.example
|
|
203
|
+
MSpec.actions :before, state
|
|
204
|
+
|
|
205
|
+
if protect "before :each", pre(:each)
|
|
206
|
+
MSpec.clear_expectations
|
|
207
|
+
if example
|
|
208
|
+
passed = protect nil, example
|
|
209
|
+
MSpec.actions :example, state, example
|
|
210
|
+
protect nil, @expectation_missing unless MSpec.expectation? or not passed
|
|
211
|
+
end
|
|
212
|
+
protect "after :each", post(:each)
|
|
213
|
+
protect "Mock.verify_count", @mock_verify
|
|
210
214
|
end
|
|
211
|
-
protect "after :each", post(:each)
|
|
212
|
-
protect "Mock.verify_count", @mock_verify
|
|
213
|
-
end
|
|
214
215
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
216
|
+
protect "Mock.cleanup", @mock_cleanup
|
|
217
|
+
MSpec.actions :after, state
|
|
218
|
+
@state = nil
|
|
219
|
+
end
|
|
218
220
|
end
|
|
219
221
|
protect "after :all", post(:all)
|
|
220
222
|
else
|
|
@@ -14,6 +14,8 @@ class DottedFormatter
|
|
|
14
14
|
else
|
|
15
15
|
@out = File.open out, "w"
|
|
16
16
|
end
|
|
17
|
+
|
|
18
|
+
@current_state = nil
|
|
17
19
|
end
|
|
18
20
|
|
|
19
21
|
# Creates the +TimerAction+ and +TallyAction+ instances and
|
|
@@ -28,6 +30,13 @@ class DottedFormatter
|
|
|
28
30
|
MSpec.register :before, self
|
|
29
31
|
MSpec.register :after, self
|
|
30
32
|
MSpec.register :finish, self
|
|
33
|
+
MSpec.register :abort, self
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def abort
|
|
37
|
+
if @current_state
|
|
38
|
+
puts " aborting example: #{@current_state.description}"
|
|
39
|
+
end
|
|
31
40
|
end
|
|
32
41
|
|
|
33
42
|
# Returns true if any exception is raised while running
|
|
@@ -47,7 +56,8 @@ class DottedFormatter
|
|
|
47
56
|
|
|
48
57
|
# Callback for the MSpec :before event. Resets the
|
|
49
58
|
# +#exception?+ and +#failure+ flags.
|
|
50
|
-
def before(state
|
|
59
|
+
def before(state=nil)
|
|
60
|
+
@current_state = state
|
|
51
61
|
@failure = @exception = false
|
|
52
62
|
end
|
|
53
63
|
|
|
@@ -68,6 +78,8 @@ class DottedFormatter
|
|
|
68
78
|
# F = An SpecExpectationNotMetError was raised
|
|
69
79
|
# E = Any exception other than SpecExpectationNotMetError
|
|
70
80
|
def after(state = nil)
|
|
81
|
+
@current_state = nil
|
|
82
|
+
|
|
71
83
|
unless exception?
|
|
72
84
|
print "."
|
|
73
85
|
else
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
require 'mspec/expectations/expectations'
|
|
2
|
+
require 'mspec/utils/ruby_name'
|
|
3
|
+
require 'mspec/runner/formatters/yaml'
|
|
4
|
+
|
|
5
|
+
class JUnitFormatter < YamlFormatter
|
|
6
|
+
def initialize(out=nil)
|
|
7
|
+
super
|
|
8
|
+
@tests = []
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def after(state = nil)
|
|
12
|
+
super
|
|
13
|
+
@tests << {:test => state, :exception => false} unless exception?
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def exception(exception)
|
|
17
|
+
super
|
|
18
|
+
@tests << {:test => exception, :exception => true}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def finish
|
|
22
|
+
switch
|
|
23
|
+
|
|
24
|
+
time = @timer.elapsed
|
|
25
|
+
tests = @tally.counter.examples
|
|
26
|
+
errors = @tally.counter.errors
|
|
27
|
+
failures = @tally.counter.failures
|
|
28
|
+
|
|
29
|
+
printf <<-XML
|
|
30
|
+
|
|
31
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
|
32
|
+
<testsuites
|
|
33
|
+
testCount="#{tests}"
|
|
34
|
+
errorCount="#{errors}"
|
|
35
|
+
failureCount="#{failures}"
|
|
36
|
+
timeCount="#{time}" time="#{time}">
|
|
37
|
+
<testsuite
|
|
38
|
+
tests="#{tests}"
|
|
39
|
+
errors="#{errors}"
|
|
40
|
+
failures="#{failures}"
|
|
41
|
+
time="#{time}"
|
|
42
|
+
name="Spec Output For #{::RUBY_NAME} (#{::RUBY_VERSION})">
|
|
43
|
+
XML
|
|
44
|
+
@tests.each do |h|
|
|
45
|
+
description = encode_for_xml h[:test].description
|
|
46
|
+
|
|
47
|
+
printf <<-XML, "Spec", description, 0.0
|
|
48
|
+
<testcase classname="%s" name="%s" time="%f">
|
|
49
|
+
XML
|
|
50
|
+
if h[:exception]
|
|
51
|
+
outcome = h[:test].failure? ? "failure" : "error"
|
|
52
|
+
message = encode_for_xml h[:test].message
|
|
53
|
+
backtrace = encode_for_xml h[:test].backtrace
|
|
54
|
+
print <<-XML
|
|
55
|
+
<#{outcome} message="error in #{description}" type="#{outcome}">
|
|
56
|
+
#{message}
|
|
57
|
+
#{backtrace}
|
|
58
|
+
</#{outcome}>
|
|
59
|
+
XML
|
|
60
|
+
end
|
|
61
|
+
print <<-XML
|
|
62
|
+
</testcase>
|
|
63
|
+
XML
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
print <<-XML
|
|
67
|
+
</testsuite>
|
|
68
|
+
</testsuites>
|
|
69
|
+
XML
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
private
|
|
73
|
+
LT = "<"
|
|
74
|
+
GT = ">"
|
|
75
|
+
QU = """
|
|
76
|
+
AP = "'"
|
|
77
|
+
AM = "&"
|
|
78
|
+
TARGET_ENCODING = "ISO-8859-1"
|
|
79
|
+
|
|
80
|
+
def encode_for_xml(str)
|
|
81
|
+
encode_as_latin1(str).gsub("<", LT).gsub(">", GT).
|
|
82
|
+
gsub('"', QU).gsub("'", AP).gsub("&", AM).
|
|
83
|
+
gsub(/[#{Regexp.escape("\0\1\2\3\4\5\6\7\8")}]/, "?")
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
if defined? Encoding
|
|
87
|
+
def encode_as_latin1(str)
|
|
88
|
+
str.encode(TARGET_ENCODING, :undef => :replace, :invalid => :replace)
|
|
89
|
+
end
|
|
90
|
+
else
|
|
91
|
+
require 'iconv'
|
|
92
|
+
def encode_as_latin1(str)
|
|
93
|
+
Iconv.conv("#{TARGET_ENCODING}//TRANSLIT//IGNORE", "UTF-8", str)
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require 'mspec/expectations/expectations'
|
|
2
|
+
require 'mspec/runner/formatters/dotted'
|
|
3
|
+
|
|
4
|
+
class ProfileFormatter < DottedFormatter
|
|
5
|
+
def initialize(out=nil)
|
|
6
|
+
super
|
|
7
|
+
|
|
8
|
+
@describe_name = nil
|
|
9
|
+
@describe_time = nil
|
|
10
|
+
@describes = []
|
|
11
|
+
@its = []
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def register
|
|
15
|
+
super
|
|
16
|
+
MSpec.register :enter, self
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Callback for the MSpec :enter event. Prints the
|
|
20
|
+
# +describe+ block string.
|
|
21
|
+
def enter(describe)
|
|
22
|
+
if @describe_time
|
|
23
|
+
@describes << [@describe_name, Time.now.to_f - @describe_time]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
@describe_name = describe
|
|
27
|
+
@describe_time = Time.now.to_f
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Callback for the MSpec :before event. Prints the
|
|
31
|
+
# +it+ block string.
|
|
32
|
+
def before(state)
|
|
33
|
+
super
|
|
34
|
+
|
|
35
|
+
@it_name = state.it
|
|
36
|
+
@it_time = Time.now.to_f
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Callback for the MSpec :after event. Prints a
|
|
40
|
+
# newline to finish the description string output.
|
|
41
|
+
def after(state)
|
|
42
|
+
@its << [@describe_name, @it_name, Time.now.to_f - @it_time]
|
|
43
|
+
super
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def finish
|
|
47
|
+
puts "\nProfiling info:"
|
|
48
|
+
|
|
49
|
+
desc = @describes.sort { |a,b| b.last <=> a.last }
|
|
50
|
+
desc.delete_if { |a| a.last <= 0.001 }
|
|
51
|
+
show = desc[0, 100]
|
|
52
|
+
|
|
53
|
+
puts "Top #{show.size} describes:"
|
|
54
|
+
|
|
55
|
+
show.each do |des, time|
|
|
56
|
+
printf "%3.3f - %s\n", time, des
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
its = @its.sort { |a,b| b.last <=> a.last }
|
|
60
|
+
its.delete_if { |a| a.last <= 0.001 }
|
|
61
|
+
show = its[0, 100]
|
|
62
|
+
|
|
63
|
+
puts "\nTop #{show.size} its:"
|
|
64
|
+
show.each do |des, it, time|
|
|
65
|
+
printf "%3.3f - %s %s\n", time, des, it
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
super
|
|
69
|
+
end
|
|
70
|
+
end
|
data/lib/mspec/runner/mspec.rb
CHANGED
|
@@ -24,6 +24,7 @@ module MSpec
|
|
|
24
24
|
@features = {}
|
|
25
25
|
@exception = nil
|
|
26
26
|
@randomize = nil
|
|
27
|
+
@repeat = nil
|
|
27
28
|
@expectation = nil
|
|
28
29
|
@expectations = false
|
|
29
30
|
|
|
@@ -229,6 +230,16 @@ module MSpec
|
|
|
229
230
|
@randomize == true
|
|
230
231
|
end
|
|
231
232
|
|
|
233
|
+
def self.repeat=(times)
|
|
234
|
+
@repeat = times
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
def self.repeat
|
|
238
|
+
(@repeat || 1).times do
|
|
239
|
+
yield
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
|
|
232
243
|
def self.shuffle(ary)
|
|
233
244
|
return if ary.empty?
|
|
234
245
|
|
data/lib/mspec/runner/shared.rb
CHANGED
data/lib/mspec/utils/options.rb
CHANGED
|
@@ -215,6 +215,12 @@ class MSpecOptions
|
|
|
215
215
|
config[:target] = 'ruby1.9'
|
|
216
216
|
when 'x', 'rubinius'
|
|
217
217
|
config[:target] = './bin/rbx'
|
|
218
|
+
when 'x18', 'rubinius18'
|
|
219
|
+
config[:target] = './bin/rbx -X18'
|
|
220
|
+
when 'x19', 'rubinius19'
|
|
221
|
+
config[:target] = './bin/rbx -X19'
|
|
222
|
+
when 'x20', 'rubinius20'
|
|
223
|
+
config[:target] = './bin/rbx -X20'
|
|
218
224
|
when 'X', 'rbx'
|
|
219
225
|
config[:target] = 'rbx'
|
|
220
226
|
when 'j', 'jruby'
|
|
@@ -223,20 +229,26 @@ class MSpecOptions
|
|
|
223
229
|
config[:target] = 'ir'
|
|
224
230
|
when 'm','maglev'
|
|
225
231
|
config[:target] = 'maglev-ruby'
|
|
232
|
+
when 't','topaz'
|
|
233
|
+
config[:target] = 'topaz'
|
|
226
234
|
else
|
|
227
235
|
config[:target] = t
|
|
228
236
|
end
|
|
229
237
|
end
|
|
230
238
|
|
|
231
239
|
doc ""
|
|
232
|
-
doc " r or ruby
|
|
233
|
-
doc " r19, ruby19
|
|
234
|
-
doc " x or rubinius
|
|
235
|
-
doc "
|
|
236
|
-
doc "
|
|
237
|
-
doc "
|
|
238
|
-
doc "
|
|
239
|
-
doc "
|
|
240
|
+
doc " r or ruby invokes ruby in PATH"
|
|
241
|
+
doc " r19, ruby19 invokes ruby1.9 in PATH"
|
|
242
|
+
doc " x or rubinius invokes ./bin/rbx"
|
|
243
|
+
doc " x18 or rubinius18 invokes ./bin/rbx -X18"
|
|
244
|
+
doc " x19 or rubinius19 invokes ./bin/rbx -X19"
|
|
245
|
+
doc " x20 or rubinius20 invokes ./bin/rbx -X20"
|
|
246
|
+
doc " X or rbx invokes rbx in PATH"
|
|
247
|
+
doc " j or jruby invokes jruby in PATH"
|
|
248
|
+
doc " i or ironruby invokes ir in PATH"
|
|
249
|
+
doc " m or maglev invokes maglev-ruby in PATH"
|
|
250
|
+
doc " t or topaz invokes topaz in PATH"
|
|
251
|
+
doc " full path to EXE invokes EXE directly\n"
|
|
240
252
|
|
|
241
253
|
on("-T", "--target-opt", "OPT",
|
|
242
254
|
"Pass OPT as a flag to the target implementation") do |t|
|
|
@@ -276,6 +288,10 @@ class MSpecOptions
|
|
|
276
288
|
config[:formatter] = MethodFormatter
|
|
277
289
|
when 'y', 'yaml'
|
|
278
290
|
config[:formatter] = YamlFormatter
|
|
291
|
+
when 'p', 'profile'
|
|
292
|
+
config[:formatter] = ProfileFormatter
|
|
293
|
+
when 'j', 'junit'
|
|
294
|
+
config[:formatter] = JUnitFormatter
|
|
279
295
|
else
|
|
280
296
|
puts "Unknown format: #{o}"
|
|
281
297
|
puts @parser
|
|
@@ -292,7 +308,8 @@ class MSpecOptions
|
|
|
292
308
|
doc " m, summary SummaryFormatter"
|
|
293
309
|
doc " a, *, spin SpinnerFormatter"
|
|
294
310
|
doc " t, method MethodFormatter"
|
|
295
|
-
doc " y, yaml YamlFormatter
|
|
311
|
+
doc " y, yaml YamlFormatter"
|
|
312
|
+
doc " j, junit JUnitFormatter\n"
|
|
296
313
|
|
|
297
314
|
on("-o", "--output", "FILE",
|
|
298
315
|
"Write formatter output to FILE") do |f|
|
|
@@ -378,6 +395,13 @@ class MSpecOptions
|
|
|
378
395
|
end
|
|
379
396
|
end
|
|
380
397
|
|
|
398
|
+
def repeat
|
|
399
|
+
on("-R", "--repeat", "NUMBER",
|
|
400
|
+
"Repeatedly run an example NUMBER times") do |o|
|
|
401
|
+
MSpec.repeat = o.to_i
|
|
402
|
+
end
|
|
403
|
+
end
|
|
404
|
+
|
|
381
405
|
def verbose
|
|
382
406
|
on("-V", "--verbose", "Output the name of each file processed") do
|
|
383
407
|
obj = Object.new
|
|
@@ -3,6 +3,6 @@ unless Object.const_defined?(:RUBY_NAME) and RUBY_NAME
|
|
|
3
3
|
RUBY_NAME = RUBY_ENGINE
|
|
4
4
|
else
|
|
5
5
|
require 'rbconfig'
|
|
6
|
-
RUBY_NAME =
|
|
6
|
+
RUBY_NAME = RbConfig::CONFIG["RUBY_INSTALL_NAME"] || RbConfig::CONFIG["ruby_install_name"]
|
|
7
7
|
end
|
|
8
8
|
end
|