mspec 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. data/LICENSE +22 -0
  2. data/README +101 -0
  3. data/Rakefile +44 -0
  4. data/bin/mkspec +7 -0
  5. data/bin/mspec +7 -0
  6. data/bin/mspec-ci +8 -0
  7. data/bin/mspec-run +8 -0
  8. data/bin/mspec-tag +8 -0
  9. data/lib/mspec.rb +6 -0
  10. data/lib/mspec/commands/mkspec.rb +147 -0
  11. data/lib/mspec/commands/mspec-ci.rb +71 -0
  12. data/lib/mspec/commands/mspec-run.rb +80 -0
  13. data/lib/mspec/commands/mspec-tag.rb +87 -0
  14. data/lib/mspec/commands/mspec.rb +143 -0
  15. data/lib/mspec/expectations.rb +2 -0
  16. data/lib/mspec/expectations/expectations.rb +12 -0
  17. data/lib/mspec/expectations/should.rb +23 -0
  18. data/lib/mspec/guards.rb +13 -0
  19. data/lib/mspec/guards/bug.rb +27 -0
  20. data/lib/mspec/guards/compliance.rb +18 -0
  21. data/lib/mspec/guards/conflict.rb +16 -0
  22. data/lib/mspec/guards/endian.rb +40 -0
  23. data/lib/mspec/guards/extensions.rb +12 -0
  24. data/lib/mspec/guards/guard.rb +120 -0
  25. data/lib/mspec/guards/noncompliance.rb +12 -0
  26. data/lib/mspec/guards/platform.rb +38 -0
  27. data/lib/mspec/guards/quarantine.rb +15 -0
  28. data/lib/mspec/guards/runner.rb +30 -0
  29. data/lib/mspec/guards/superuser.rb +15 -0
  30. data/lib/mspec/guards/support.rb +12 -0
  31. data/lib/mspec/guards/version.rb +40 -0
  32. data/lib/mspec/helpers.rb +6 -0
  33. data/lib/mspec/helpers/bignum.rb +5 -0
  34. data/lib/mspec/helpers/const_lookup.rb +5 -0
  35. data/lib/mspec/helpers/flunk.rb +5 -0
  36. data/lib/mspec/helpers/io.rb +13 -0
  37. data/lib/mspec/helpers/scratch.rb +17 -0
  38. data/lib/mspec/helpers/tmp.rb +32 -0
  39. data/lib/mspec/matchers.rb +16 -0
  40. data/lib/mspec/matchers/base.rb +95 -0
  41. data/lib/mspec/matchers/be_ancestor_of.rb +24 -0
  42. data/lib/mspec/matchers/be_close.rb +27 -0
  43. data/lib/mspec/matchers/be_empty.rb +20 -0
  44. data/lib/mspec/matchers/be_false.rb +20 -0
  45. data/lib/mspec/matchers/be_kind_of.rb +24 -0
  46. data/lib/mspec/matchers/be_nil.rb +20 -0
  47. data/lib/mspec/matchers/be_true.rb +20 -0
  48. data/lib/mspec/matchers/complain.rb +56 -0
  49. data/lib/mspec/matchers/eql.rb +26 -0
  50. data/lib/mspec/matchers/equal.rb +26 -0
  51. data/lib/mspec/matchers/equal_utf16.rb +34 -0
  52. data/lib/mspec/matchers/include.rb +32 -0
  53. data/lib/mspec/matchers/output.rb +67 -0
  54. data/lib/mspec/matchers/output_to_fd.rb +71 -0
  55. data/lib/mspec/matchers/raise_error.rb +48 -0
  56. data/lib/mspec/mocks.rb +3 -0
  57. data/lib/mspec/mocks/mock.rb +123 -0
  58. data/lib/mspec/mocks/object.rb +28 -0
  59. data/lib/mspec/mocks/proxy.rb +112 -0
  60. data/lib/mspec/runner.rb +13 -0
  61. data/lib/mspec/runner/actions.rb +6 -0
  62. data/lib/mspec/runner/actions/debug.rb +17 -0
  63. data/lib/mspec/runner/actions/filter.rb +40 -0
  64. data/lib/mspec/runner/actions/gdb.rb +17 -0
  65. data/lib/mspec/runner/actions/tag.rb +97 -0
  66. data/lib/mspec/runner/actions/tally.rb +80 -0
  67. data/lib/mspec/runner/actions/timer.rb +22 -0
  68. data/lib/mspec/runner/filters.rb +4 -0
  69. data/lib/mspec/runner/filters/match.rb +22 -0
  70. data/lib/mspec/runner/filters/profile.rb +54 -0
  71. data/lib/mspec/runner/filters/regexp.rb +7 -0
  72. data/lib/mspec/runner/filters/tag.rb +29 -0
  73. data/lib/mspec/runner/formatters.rb +7 -0
  74. data/lib/mspec/runner/formatters/dotted.rb +81 -0
  75. data/lib/mspec/runner/formatters/html.rb +87 -0
  76. data/lib/mspec/runner/formatters/specdoc.rb +27 -0
  77. data/lib/mspec/runner/formatters/spinner.rb +89 -0
  78. data/lib/mspec/runner/formatters/summary.rb +8 -0
  79. data/lib/mspec/runner/formatters/unit.rb +25 -0
  80. data/lib/mspec/runner/formatters/yaml.rb +43 -0
  81. data/lib/mspec/runner/mspec.rb +232 -0
  82. data/lib/mspec/runner/object.rb +20 -0
  83. data/lib/mspec/runner/shared.rb +12 -0
  84. data/lib/mspec/runner/state.rb +116 -0
  85. data/lib/mspec/runner/tag.rb +20 -0
  86. data/lib/mspec/utils/name_map.rb +130 -0
  87. data/lib/mspec/utils/options.rb +344 -0
  88. data/lib/mspec/utils/script.rb +77 -0
  89. data/lib/mspec/version.rb +3 -0
  90. data/spec/commands/mkspec_spec.rb +321 -0
  91. data/spec/commands/mspec_ci_spec.rb +139 -0
  92. data/spec/commands/mspec_run_spec.rb +146 -0
  93. data/spec/commands/mspec_spec.rb +359 -0
  94. data/spec/commands/mspec_tag_spec.rb +131 -0
  95. data/spec/expectations/expectations_spec.rb +16 -0
  96. data/spec/expectations/should_spec.rb +99 -0
  97. data/spec/guards/bug_spec.rb +137 -0
  98. data/spec/guards/compliance_spec.rb +70 -0
  99. data/spec/guards/conflict_spec.rb +20 -0
  100. data/spec/guards/endian_spec.rb +42 -0
  101. data/spec/guards/extensions_spec.rb +36 -0
  102. data/spec/guards/guard_spec.rb +355 -0
  103. data/spec/guards/noncompliance_spec.rb +36 -0
  104. data/spec/guards/platform_spec.rb +84 -0
  105. data/spec/guards/quarantine_spec.rb +19 -0
  106. data/spec/guards/runner_spec.rb +75 -0
  107. data/spec/guards/superuser_spec.rb +22 -0
  108. data/spec/guards/support_spec.rb +22 -0
  109. data/spec/guards/version_spec.rb +133 -0
  110. data/spec/helpers/bignum_spec.rb +11 -0
  111. data/spec/helpers/const_lookup_spec.rb +19 -0
  112. data/spec/helpers/flunk_spec.rb +15 -0
  113. data/spec/helpers/io_spec.rb +34 -0
  114. data/spec/helpers/scratch_spec.rb +22 -0
  115. data/spec/helpers/tmp_spec.rb +72 -0
  116. data/spec/matchers/base_spec.rb +180 -0
  117. data/spec/matchers/be_ancestor_of_spec.rb +28 -0
  118. data/spec/matchers/be_close_spec.rb +46 -0
  119. data/spec/matchers/be_empty_spec.rb +26 -0
  120. data/spec/matchers/be_false_spec.rb +28 -0
  121. data/spec/matchers/be_kind_of_spec.rb +29 -0
  122. data/spec/matchers/be_nil_spec.rb +27 -0
  123. data/spec/matchers/be_true_spec.rb +28 -0
  124. data/spec/matchers/complain_spec.rb +52 -0
  125. data/spec/matchers/eql_spec.rb +33 -0
  126. data/spec/matchers/equal_spec.rb +33 -0
  127. data/spec/matchers/equal_utf16_spec.rb +47 -0
  128. data/spec/matchers/include_spec.rb +37 -0
  129. data/spec/matchers/output_spec.rb +74 -0
  130. data/spec/matchers/output_to_fd_spec.rb +33 -0
  131. data/spec/matchers/raise_error_spec.rb +56 -0
  132. data/spec/mocks/mock_spec.rb +272 -0
  133. data/spec/mocks/proxy_spec.rb +259 -0
  134. data/spec/runner/actions/debug_spec.rb +61 -0
  135. data/spec/runner/actions/filter_spec.rb +84 -0
  136. data/spec/runner/actions/gdb_spec.rb +61 -0
  137. data/spec/runner/actions/tag_spec.rb +253 -0
  138. data/spec/runner/actions/tally_spec.rb +107 -0
  139. data/spec/runner/actions/timer_spec.rb +42 -0
  140. data/spec/runner/filters/a.yaml +4 -0
  141. data/spec/runner/filters/b.yaml +11 -0
  142. data/spec/runner/filters/match_spec.rb +44 -0
  143. data/spec/runner/filters/profile_spec.rb +117 -0
  144. data/spec/runner/filters/regexp_spec.rb +13 -0
  145. data/spec/runner/filters/tag_spec.rb +77 -0
  146. data/spec/runner/formatters/dotted_spec.rb +184 -0
  147. data/spec/runner/formatters/html_spec.rb +191 -0
  148. data/spec/runner/formatters/specdoc_spec.rb +57 -0
  149. data/spec/runner/formatters/spinner_spec.rb +78 -0
  150. data/spec/runner/formatters/summary_spec.rb +29 -0
  151. data/spec/runner/formatters/unit_spec.rb +71 -0
  152. data/spec/runner/formatters/yaml_spec.rb +123 -0
  153. data/spec/runner/mspec_spec.rb +393 -0
  154. data/spec/runner/shared_spec.rb +41 -0
  155. data/spec/runner/state_spec.rb +535 -0
  156. data/spec/runner/tag_spec.rb +93 -0
  157. data/spec/runner/tags.txt +3 -0
  158. data/spec/spec_helper.rb +46 -0
  159. data/spec/utils/name_map_spec.rb +178 -0
  160. data/spec/utils/options_spec.rb +862 -0
  161. data/spec/utils/script_spec.rb +240 -0
  162. metadata +217 -0
@@ -0,0 +1,36 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'mspec/guards/noncompliance'
3
+
4
+ describe Object, "#deviates_on" do
5
+ before :each do
6
+ @guard = NonComplianceGuard.new
7
+ NonComplianceGuard.stub!(:new).and_return(@guard)
8
+ ScratchPad.clear
9
+ end
10
+
11
+ it "does not yield when #implementation? and #platform? return false" do
12
+ @guard.stub!(:implementation?).and_return(false)
13
+ @guard.stub!(:platform?).and_return(false)
14
+ deviates_on(:rbx) { ScratchPad.record :yield }
15
+ ScratchPad.recorded.should_not == :yield
16
+ end
17
+
18
+ it "yields when #implementation? or #platform? return true" do
19
+ @guard.stub!(:implementation?).and_return(true)
20
+ @guard.stub!(:platform?).and_return(false)
21
+ deviates_on(:rbx) { ScratchPad.record :yield }
22
+ ScratchPad.recorded.should == :yield
23
+
24
+ @guard.stub!(:implementation?).and_return(false)
25
+ @guard.stub!(:platform?).and_return(true)
26
+ deviates_on(:rbx) { ScratchPad.record :yield }
27
+ ScratchPad.recorded.should == :yield
28
+ end
29
+
30
+ it "yields when #implementation? and #platform? return true" do
31
+ @guard.stub!(:implementation?).and_return(true)
32
+ @guard.stub!(:platform?).and_return(true)
33
+ deviates_on(:rbx) { ScratchPad.record :yield }
34
+ ScratchPad.recorded.should == :yield
35
+ end
36
+ end
@@ -0,0 +1,84 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'mspec/guards/platform'
3
+
4
+ describe Object, "#platform_is" do
5
+ before :each do
6
+ @guard = PlatformGuard.new :dummy
7
+ PlatformGuard.stub!(:new).and_return(@guard)
8
+ ScratchPad.clear
9
+ end
10
+
11
+ it "does not yield when #platform? returns false" do
12
+ @guard.stub!(:platform?).and_return(false)
13
+ platform_is(:ruby) { ScratchPad.record :yield }
14
+ ScratchPad.recorded.should_not == :yield
15
+ end
16
+
17
+ it "yields when #platform? returns true" do
18
+ @guard.stub!(:platform?).and_return(true)
19
+ platform_is(:solarce) { ScratchPad.record :yield }
20
+ ScratchPad.recorded.should == :yield
21
+ end
22
+ end
23
+
24
+ describe Object, "#platform_is_not" do
25
+ before :each do
26
+ @guard = PlatformGuard.new :dummy
27
+ PlatformGuard.stub!(:new).and_return(@guard)
28
+ ScratchPad.clear
29
+ end
30
+
31
+ it "does not yield when #platform? returns true" do
32
+ @guard.stub!(:platform?).and_return(true)
33
+ platform_is_not(:ruby) { ScratchPad.record :yield }
34
+ ScratchPad.recorded.should_not == :yield
35
+ end
36
+
37
+ it "yields when #platform? returns false" do
38
+ @guard.stub!(:platform?).and_return(false)
39
+ platform_is_not(:solarce) { ScratchPad.record :yield }
40
+ ScratchPad.recorded.should == :yield
41
+ end
42
+ end
43
+
44
+ describe Object, "#platform_is :wordsize => SIZE_SPEC" do
45
+ before :each do
46
+ @guard = PlatformGuard.new :darwin, :wordsize => 32
47
+ @guard.stub!(:platform?).and_return(true)
48
+ PlatformGuard.stub!(:new).and_return(@guard)
49
+ ScratchPad.clear
50
+ end
51
+
52
+ it "yields when #wordsize? returns true" do
53
+ @guard.stub!(:wordsize?).and_return(true)
54
+ platform_is(:wordsize => 32) { ScratchPad.record :yield }
55
+ ScratchPad.recorded.should == :yield
56
+ end
57
+
58
+ it "doesn not yield when #wordsize? returns false" do
59
+ @guard.stub!(:wordsize?).and_return(false)
60
+ platform_is(:wordsize => 32) { ScratchPad.record :yield }
61
+ ScratchPad.recorded.should_not == :yield
62
+ end
63
+ end
64
+
65
+ describe Object, "#platform_is_not :wordsize => SIZE_SPEC" do
66
+ before :each do
67
+ @guard = PlatformGuard.new :darwin, :wordsize => 32
68
+ @guard.stub!(:platform?).and_return(true)
69
+ PlatformGuard.stub!(:new).and_return(@guard)
70
+ ScratchPad.clear
71
+ end
72
+
73
+ it "yields when #wordsize? returns false" do
74
+ @guard.stub!(:wordsize?).and_return(false)
75
+ platform_is_not(:wordsize => 32) { ScratchPad.record :yield }
76
+ ScratchPad.recorded.should == :yield
77
+ end
78
+
79
+ it "doesn not yield when #wordsize? returns true" do
80
+ @guard.stub!(:wordsize?).and_return(true)
81
+ platform_is_not(:wordsize => 32) { ScratchPad.record :yield }
82
+ ScratchPad.recorded.should_not == :yield
83
+ end
84
+ end
@@ -0,0 +1,19 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'mspec/guards/quarantine'
3
+
4
+ describe QuarantineGuard, "#match?" do
5
+ it "returns false" do
6
+ QuarantineGuard.new.match?.should == false
7
+ end
8
+ end
9
+
10
+ describe Object, "#quarantine!" do
11
+ before :each do
12
+ ScratchPad.clear
13
+ end
14
+
15
+ it "does not yield" do
16
+ quarantine! { ScratchPad.record :yield }
17
+ ScratchPad.recorded.should_not == :yield
18
+ end
19
+ end
@@ -0,0 +1,75 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'mspec/guards/runner'
3
+
4
+ describe RunnerGuard, "#match?" do
5
+ before :all do
6
+ @verbose = $VERBOSE
7
+ $VERBOSE = nil
8
+ end
9
+
10
+ after :all do
11
+ $VERBOSE = @verbose
12
+ end
13
+
14
+ it "returns true when passed :mspec and ENV['MSPEC_RUNNER'] is true" do
15
+ ENV['MSPEC_RUNNER'] = '1'
16
+ RunnerGuard.new(:mspec).match?.should == true
17
+ end
18
+
19
+ it "returns false when passed :mspec and ENV['MSPEC_RUNNER'] is false" do
20
+ ENV.delete 'MSPEC_RUNNER'
21
+ RunnerGuard.new(:mspec).match?.should == false
22
+ end
23
+
24
+ it "returns true when passed :rspec and ENV['RSPEC_RUNNER'] is false but the constant Spec exists" do
25
+ ENV.delete 'RSPEC_RUNNER'
26
+ Object.const_set(:Spec, 1) unless Object.const_defined?(:Spec)
27
+ RunnerGuard.new(:rspec).match?.should == true
28
+ end
29
+
30
+ it "returns true when passed :rspec and ENV['RSPEC_RUNNER'] is true but the constant Spec does not exist" do
31
+ ENV['RSPEC_RUNNER'] = '1'
32
+ Object.should_receive(:const_defined?).with(:Spec).any_number_of_times.and_return(false)
33
+ RunnerGuard.new(:rspec).match?.should == true
34
+ end
35
+ end
36
+
37
+ describe Object, "#runner_is" do
38
+ before :each do
39
+ @guard = RunnerGuard.new
40
+ RunnerGuard.stub!(:new).and_return(@guard)
41
+ ScratchPad.clear
42
+ end
43
+
44
+ it "yields when #match? returns true" do
45
+ @guard.stub!(:match?).and_return(true)
46
+ runner_is(:mspec) { ScratchPad.record :yield }
47
+ ScratchPad.recorded.should == :yield
48
+ end
49
+
50
+ it "does not yield when #match? returns false" do
51
+ @guard.stub!(:match?).and_return(false)
52
+ runner_is(:mspec) { ScratchPad.record :yield }
53
+ ScratchPad.recorded.should_not == :yield
54
+ end
55
+ end
56
+
57
+ describe Object, "#runner_is_not" do
58
+ before :each do
59
+ @guard = RunnerGuard.new
60
+ RunnerGuard.stub!(:new).and_return(@guard)
61
+ ScratchPad.clear
62
+ end
63
+
64
+ it "does not yield when #match? returns true" do
65
+ @guard.stub!(:match?).and_return(true)
66
+ runner_is_not(:mspec) { ScratchPad.record :yield }
67
+ ScratchPad.recorded.should_not == :yield
68
+ end
69
+
70
+ it "yields when #match? returns false" do
71
+ @guard.stub!(:match?).and_return(false)
72
+ runner_is_not(:mspec) { ScratchPad.record :yield }
73
+ ScratchPad.recorded.should == :yield
74
+ end
75
+ end
@@ -0,0 +1,22 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'mspec/guards/superuser'
3
+
4
+ describe Object, "#as_superuser" do
5
+ before :each do
6
+ @guard = SuperUserGuard.new
7
+ SuperUserGuard.stub!(:new).and_return(@guard)
8
+ ScratchPad.clear
9
+ end
10
+
11
+ it "does not yield when Process.euid is not 0" do
12
+ Process.stub!(:euid).and_return(501)
13
+ as_superuser { ScratchPad.record :yield }
14
+ ScratchPad.recorded.should_not == :yield
15
+ end
16
+
17
+ it "yields when Process.euid is 0" do
18
+ Process.stub!(:euid).and_return(0)
19
+ as_superuser { ScratchPad.record :yield }
20
+ ScratchPad.recorded.should == :yield
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'mspec/guards/support'
3
+
4
+ describe Object, "#not_supported_on" do
5
+ before :each do
6
+ @guard = SupportedGuard.new
7
+ SupportedGuard.stub!(:new).and_return(@guard)
8
+ ScratchPad.clear
9
+ end
10
+
11
+ it "does not yield when #implementation? returns true" do
12
+ @guard.stub!(:implementation?).and_return(true)
13
+ not_supported_on(:rbx) { ScratchPad.record :yield }
14
+ ScratchPad.recorded.should_not == :yield
15
+ end
16
+
17
+ it "yields when #implementation? returns false" do
18
+ @guard.stub!(:implementation?).and_return(false)
19
+ not_supported_on(:rbx) { ScratchPad.record :yield }
20
+ ScratchPad.recorded.should == :yield
21
+ end
22
+ end
@@ -0,0 +1,133 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'mspec/guards/version'
3
+
4
+ # The VersionGuard specifies a version of Ruby with a String of
5
+ # the form: v = 'major.minor.tiny.patchlevel'.
6
+ #
7
+ # A VersionGuard instance can be created with a single String,
8
+ # which means any version >= each component of v.
9
+ # Or, the guard can be created with a Range, a..b, or a...b,
10
+ # where a, b are of the same form as v. The meaning of the Range
11
+ # is as typically understood: a..b means v >= a and v <= b;
12
+ # a...b means v >= a and v < b.
13
+
14
+ describe VersionGuard, "#ruby_version" do
15
+ before :all do
16
+ @verbose = $VERBOSE
17
+ $VERBOSE = nil
18
+ end
19
+
20
+ after :all do
21
+ $VERBOSE = @verbose
22
+ end
23
+
24
+ before :each do
25
+ @ruby_version = Object.const_get :RUBY_VERSION
26
+ @ruby_patch = Object.const_get :RUBY_PATCHLEVEL
27
+
28
+ Object.const_set :RUBY_VERSION, '1.8.6'
29
+ Object.const_set :RUBY_PATCHLEVEL, 114
30
+
31
+ @guard = VersionGuard.new 'x.x.x.x'
32
+ end
33
+
34
+ after :each do
35
+ Object.const_set :RUBY_VERSION, @ruby_version
36
+ Object.const_set :RUBY_PATCHLEVEL, @ruby_patch
37
+ end
38
+
39
+ it "returns 'RUBY_VERSION.RUBY_PATCHLEVEL'" do
40
+ @guard.ruby_version.should == 10108060114
41
+ end
42
+ end
43
+
44
+ describe VersionGuard, "#to_v" do
45
+ before :each do
46
+ @guard = VersionGuard.new 'x.x.x.x'
47
+ end
48
+
49
+ it "returns a version string containing only digits" do
50
+ @guard.to_v("1.8.6.22").should == 10108060022
51
+ end
52
+
53
+ it "replaces missing version parts with zeros" do
54
+ @guard.to_v("1.8").should == 10108000000
55
+ @guard.to_v("1.8.6").should == 10108060000
56
+ @guard.to_v("1.8.7.333").should == 10108070333
57
+ end
58
+ end
59
+
60
+ describe VersionGuard, "#match?" do
61
+ before :all do
62
+ @verbose = $VERBOSE
63
+ $VERBOSE = nil
64
+ end
65
+
66
+ after :all do
67
+ $VERBOSE = @verbose
68
+ end
69
+
70
+ before :each do
71
+ @ruby_version = Object.const_get :RUBY_VERSION
72
+ @ruby_patch = Object.const_get :RUBY_PATCHLEVEL
73
+
74
+ Object.const_set :RUBY_VERSION, '1.8.6'
75
+ Object.const_set :RUBY_PATCHLEVEL, 114
76
+ end
77
+
78
+ after :each do
79
+ Object.const_set :RUBY_VERSION, @ruby_version
80
+ Object.const_set :RUBY_PATCHLEVEL, @ruby_patch
81
+ end
82
+
83
+ it "returns true when the argument is equal to RUBY_VERSION and RUBY_PATCHLEVEL" do
84
+ VersionGuard.new('1.8.6.114').match?.should == true
85
+ end
86
+
87
+ it "returns true when the argument is less than RUBY_VERSION and RUBY_PATCHLEVEL" do
88
+ VersionGuard.new('1.8').match?.should == true
89
+ VersionGuard.new('1.8.5').match?.should == true
90
+ end
91
+
92
+ it "returns false when the argument is greater than RUBY_VERSION and RUBY_PATCHLEVEL" do
93
+ VersionGuard.new('1.8.7').match?.should == false
94
+ VersionGuard.new('1.8.7.000').match?.should == false
95
+ VersionGuard.new('1.8.7.10').match?.should == false
96
+ end
97
+
98
+ it "returns true when the argument range includes RUBY_VERSION and RUBY_PATCHLEVEL" do
99
+ VersionGuard.new('1.8.5'..'1.8.7.111').match?.should == true
100
+ VersionGuard.new('1.8'..'1.9').match?.should == true
101
+ VersionGuard.new('1.8'...'1.9').match?.should == true
102
+ VersionGuard.new('1.8'..'1.8.6.114').match?.should == true
103
+ VersionGuard.new('1.8'...'1.8.6.115').match?.should == true
104
+ end
105
+
106
+ it "returns false when the argument range does not include RUBY_VERSION and RUBY_PATCHLEVEL" do
107
+ VersionGuard.new('1.8.7'..'1.8.9').match?.should == false
108
+ VersionGuard.new('1.8.4'..'1.8.5').match?.should == false
109
+ VersionGuard.new('1.8.5'..'1.8.6.113').match?.should == false
110
+ VersionGuard.new('1.8.4'...'1.8.6').match?.should == false
111
+ VersionGuard.new('1.8.5'...'1.8.6.114').match?.should == false
112
+ end
113
+ end
114
+
115
+ describe Object, "#ruby_version_is" do
116
+ before :each do
117
+ @guard = VersionGuard.new 'x.x.x.x'
118
+ VersionGuard.stub!(:new).and_return(@guard)
119
+ ScratchPad.clear
120
+ end
121
+
122
+ it "yields when #match? returns true" do
123
+ @guard.stub!(:match?).and_return(true)
124
+ ruby_version_is('x.x.x.x') { ScratchPad.record :yield }
125
+ ScratchPad.recorded.should == :yield
126
+ end
127
+
128
+ it "does not yield when #match? returns false" do
129
+ @guard.stub!(:match?).and_return(false)
130
+ ruby_version_is('x.x.x.x') { ScratchPad.record :yield }
131
+ ScratchPad.recorded.should_not == :yield
132
+ end
133
+ end
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'mspec/helpers/bignum'
3
+
4
+ describe Object, "#bignum_value" do
5
+ it "returns a value that is an instance of Bignum on any platform" do
6
+ bignum_value.should == 0x8000_0000_0000_0000
7
+ end
8
+
9
+ it "returns the default value incremented by the argument" do
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'mspec/helpers/const_lookup'
3
+
4
+ module ConstLookupSpecs
5
+ class A
6
+ class B
7
+ end
8
+ end
9
+ end
10
+
11
+ describe Kernel, "#const_lookup" do
12
+ it "returns the constant specified by 'A::B'" do
13
+ const_lookup("ConstLookupSpecs::A::B").should == ConstLookupSpecs::A::B
14
+ end
15
+
16
+ it "returns a regular constant specified without scoping" do
17
+ const_lookup("ConstLookupSpecs").should == ConstLookupSpecs
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'mspec/expectations/expectations'
3
+ require 'mspec/helpers/flunk'
4
+ require 'mspec/runner/mspec'
5
+
6
+ describe Object, "#flunk" do
7
+ before :each do
8
+ MSpec.stub!(:actions)
9
+ MSpec.stub!(:current).and_return(mock("spec state", :null_object => true))
10
+ end
11
+
12
+ it "raises an ExpectationNotMetError unconditionally" do
13
+ lambda { flunk }.should raise_error(ExpectationNotMetError)
14
+ end
15
+ end