mspec 1.0.0

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 (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,131 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'mspec/runner/mspec'
3
+ require 'mspec/commands/mspec-tag'
4
+
5
+ describe MSpecTag, "#options" do
6
+ before :each do
7
+ @stdout, $stdout = $stdout, IOStub.new
8
+
9
+ @argv = ["a", "b"]
10
+ @options, @config = new_option
11
+ MSpecOptions.stub!(:new).and_return(@options)
12
+
13
+ @script = MSpecTag.new
14
+ @script.stub!(:config).and_return(@config)
15
+ end
16
+
17
+ after :each do
18
+ $stdout = @stdout
19
+ end
20
+
21
+ it "enables the filter options" do
22
+ @options.should_receive(:add_filters)
23
+ @script.options @argv
24
+ end
25
+
26
+ it "enables the config option" do
27
+ @options.should_receive(:add_config)
28
+ @script.options @argv
29
+ end
30
+
31
+ it "provides a custom action (block) to the config option" do
32
+ @script.should_receive(:load).with("cfg.mspec")
33
+ @script.options ["-B", "cfg.mspec", "a"]
34
+ end
35
+
36
+ it "enables the name option" do
37
+ @options.should_receive(:add_name)
38
+ @script.options @argv
39
+ end
40
+
41
+ it "enables the tags dir option" do
42
+ @options.should_receive(:add_tags_dir)
43
+ @script.options @argv
44
+ end
45
+
46
+ it "enables the dry run option" do
47
+ @options.should_receive(:add_pretend)
48
+ @script.options @argv
49
+ end
50
+
51
+ it "enables the interrupt single specs option" do
52
+ @options.should_receive(:add_interrupt)
53
+ @script.options @argv
54
+ end
55
+
56
+ it "enables the formatter options" do
57
+ @options.should_receive(:add_formatters)
58
+ @script.options @argv
59
+ end
60
+
61
+ it "enables the verbose option" do
62
+ @options.should_receive(:add_verbose)
63
+ @script.options @argv
64
+ end
65
+
66
+ it "enables the tagging options" do
67
+ @options.should_receive(:add_tagging)
68
+ @script.options @argv
69
+ end
70
+
71
+ it "enables the version option" do
72
+ @options.should_receive(:add_version)
73
+ @script.options @argv
74
+ end
75
+
76
+ it "enables the help option" do
77
+ @options.should_receive(:add_help)
78
+ @script.options @argv
79
+ end
80
+
81
+ it "exits if there are no files to process" do
82
+ @options.should_receive(:parse).and_return([])
83
+ @script.should_receive(:exit)
84
+ @script.options
85
+ $stdout.should =~ /No files specified/
86
+ end
87
+ end
88
+
89
+ describe MSpecTag, "#run" do
90
+ before :each do
91
+ MSpec.stub!(:process)
92
+
93
+ stat = mock("stat")
94
+ stat.stub!(:file?).and_return(true)
95
+ stat.stub!(:directory?).and_return(false)
96
+ File.stub!(:expand_path)
97
+ File.stub!(:stat).and_return(stat)
98
+
99
+ options = mock("MSpecOptions", :null_object => true)
100
+ options.stub!(:parse).and_return(["one", "two"])
101
+ MSpecOptions.stub!(:new).and_return(options)
102
+
103
+ @config = { }
104
+ @script = MSpecTag.new
105
+ @script.stub!(:exit)
106
+ @script.stub!(:config).and_return(@config)
107
+ @script.options
108
+ end
109
+
110
+ it "registers the tags directory path" do
111
+ @config[:tags_dir] = "tags_dir"
112
+ MSpec.should_receive(:register_tags_path).with("tags_dir")
113
+ @script.run
114
+ end
115
+
116
+ it "registers the files to process" do
117
+ MSpec.should_receive(:register_files).with(["one", "two"])
118
+ @script.run
119
+ end
120
+
121
+ it "processes the files" do
122
+ MSpec.should_receive(:process)
123
+ @script.run
124
+ end
125
+
126
+ it "exits with the exit code registered with MSpec" do
127
+ MSpec.stub!(:exit_code).and_return(7)
128
+ @script.should_receive(:exit).with(7)
129
+ @script.run
130
+ end
131
+ end
@@ -0,0 +1,16 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'mspec/expectations/expectations'
3
+
4
+ describe ExpectationNotMetError do
5
+ it "is a subclass of StandardError" do
6
+ ExpectationNotMetError.ancestors.should include(StandardError)
7
+ end
8
+ end
9
+
10
+ describe Expectation, "#fail_with" do
11
+ it "raises an ExpectationNotMetError" do
12
+ lambda {
13
+ Expectation.fail_with "expected this", "to equal that"
14
+ }.should raise_error(ExpectationNotMetError, "expected this to equal that")
15
+ end
16
+ end
@@ -0,0 +1,99 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'mspec/expectations/expectations'
3
+ require 'mspec/matchers/base'
4
+ require 'mspec/runner/mspec'
5
+
6
+ class Object
7
+ alias_method :rspec_should, :should
8
+ alias_method :rspec_should_not, :should_not
9
+ end
10
+ require 'mspec/expectations/should'
11
+ class Object
12
+ alias_method :mspec_should, :should
13
+ alias_method :mspec_should_not, :should_not
14
+ alias_method :should, :rspec_should
15
+ alias_method :should_not, :rspec_should_not
16
+ end
17
+
18
+ # Adapted from RSpec 1.0.8
19
+ describe Object, "#should" do
20
+ before :each do
21
+ class Object; alias_method :should, :mspec_should; end
22
+ MSpec.stub!(:actions)
23
+ MSpec.stub!(:current).and_return(mock("spec state", :null_object => true))
24
+
25
+ @target = "target"
26
+ @matcher = mock("matcher")
27
+ end
28
+
29
+ after :each do
30
+ class Object; alias_method :should, :rspec_should; end
31
+ end
32
+
33
+ it "accepts and interacts with a matcher" do
34
+ @matcher.should_receive(:matches?).with(@target).and_return(true)
35
+ @target.should @matcher
36
+ end
37
+
38
+ it "calls #failure_message when matcher #matches? returns false" do
39
+ @matcher.should_receive(:matches?).with(@target).and_return(false)
40
+ @matcher.should_receive(:failure_message).and_return(["expected", "actual"])
41
+ @target.should @matcher rescue nil
42
+ end
43
+
44
+ it "raises an ExpectationNotMetError when matcher #matches? returns false" do
45
+ @matcher.should_receive(:matches?).with(@target).and_return(false)
46
+ @matcher.should_receive(:failure_message).and_return(["expected", "actual"])
47
+ lambda {
48
+ @target.should @matcher
49
+ }.should raise_error(ExpectationNotMetError, "expected actual")
50
+ end
51
+
52
+ it "returns a PostiveOperatorMatcher instance when not passed a matcher" do
53
+ matcher = should
54
+ class Object; alias_method :should, :rspec_should; end
55
+ matcher.should be_instance_of(PositiveOperatorMatcher)
56
+ end
57
+ end
58
+
59
+ describe Object, "#should_not" do
60
+ before :each do
61
+ class Object; alias_method :should, :mspec_should; end
62
+ class Object; alias_method :should_not, :mspec_should_not; end
63
+ MSpec.stub!(:actions)
64
+ MSpec.stub!(:current).and_return(mock("spec state", :null_object => true))
65
+
66
+ @target = "target"
67
+ @matcher = mock("matcher")
68
+ end
69
+
70
+ after :each do
71
+ class Object; alias_method :should, :rspec_should; end
72
+ class Object; alias_method :should_not, :rspec_should_not; end
73
+ end
74
+
75
+ it "accepts and interacts with a matcher" do
76
+ @matcher.should_receive(:matches?).with(@target).and_return(false)
77
+ @target.should_not @matcher
78
+ end
79
+
80
+ it "calls #negative_failure_message when matcher.matches? returns true" do
81
+ @matcher.should_receive(:matches?).with(@target).and_return(true)
82
+ @matcher.should_receive(:negative_failure_message).and_return(["expected", "actual"])
83
+ @target.should_not @matcher rescue nil
84
+ end
85
+
86
+ it "raises an ExpectationNotMetError when matcher.matches? returns true" do
87
+ @matcher.should_receive(:matches?).with(@target).and_return(true)
88
+ @matcher.should_receive(:negative_failure_message).and_return(["expected", "actual"])
89
+ lambda {
90
+ @target.should_not @matcher
91
+ }.should raise_error(ExpectationNotMetError, "expected actual")
92
+ end
93
+
94
+ it "returns a NegativeOperatorMatcher instance when not passed a matcher" do
95
+ matcher = should_not
96
+ class Object; alias_method :should, :rspec_should; end
97
+ matcher.should be_instance_of(NegativeOperatorMatcher)
98
+ end
99
+ end
@@ -0,0 +1,137 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'mspec/guards/bug'
3
+
4
+ describe BugGuard, "#to_v" do
5
+ before :each do
6
+ @guard = BugGuard.new "#1", "x.x.x.x"
7
+ end
8
+
9
+ it "returns a version string containing only digits" do
10
+ @guard.to_v("1.8.6.22").should == 10108060022
11
+ end
12
+
13
+ it "replaces missing version parts with zeros" do
14
+ @guard.to_v("1.8").should == 10108999999
15
+ @guard.to_v("1.8.6").should == 10108069999
16
+ @guard.to_v("1.8.7.333").should == 10108070333
17
+ end
18
+ end
19
+
20
+ describe BugGuard, "#match? when #implementation? is 'ruby'" do
21
+ before :all do
22
+ @verbose = $VERBOSE
23
+ $VERBOSE = nil
24
+ end
25
+
26
+ after :all do
27
+ $VERBOSE = @verbose
28
+ end
29
+
30
+ before :each do
31
+ @ruby_version = Object.const_get :RUBY_VERSION
32
+ @ruby_patch = Object.const_get :RUBY_PATCHLEVEL
33
+ @ruby_name = Object.const_get :RUBY_NAME
34
+
35
+ Object.const_set :RUBY_VERSION, '1.8.6'
36
+ Object.const_set :RUBY_PATCHLEVEL, 114
37
+ Object.const_set :RUBY_NAME, 'ruby'
38
+ end
39
+
40
+ after :each do
41
+ Object.const_set :RUBY_VERSION, @ruby_version
42
+ Object.const_set :RUBY_PATCHLEVEL, @ruby_patch
43
+ Object.const_set :RUBY_NAME, @ruby_name
44
+ end
45
+
46
+ it "returns false when version argument is less than RUBY_VERSION and RUBY_PATCHLEVEL" do
47
+ BugGuard.new("#1", "1.8.5").match?.should == false
48
+ BugGuard.new("#1", "1.8.6.113").match?.should == false
49
+ end
50
+
51
+ it "returns true when version argument is equal to RUBY_VERSION and RUBY_PATCHLEVEL" do
52
+ BugGuard.new("#1", "1.8.6.114").match?.should == true
53
+ end
54
+
55
+ it "returns true when version argument is greater than RUBY_VERSION and RUBY_PATCHLEVEL" do
56
+ BugGuard.new("#1", "1.8.7").match?.should == true
57
+ BugGuard.new("#1", "1.8.6.115").match?.should == true
58
+ end
59
+
60
+ it "returns true when version argument implicitly includes RUBY_VERSION and RUBY_PATCHLEVEL" do
61
+ BugGuard.new("#1", "1.8").match?.should == true
62
+ BugGuard.new("#1", "1.8.6").match?.should == true
63
+ end
64
+ end
65
+
66
+ describe BugGuard, "#match? when #implementation? is not 'ruby'" do
67
+ before :all do
68
+ @verbose = $VERBOSE
69
+ $VERBOSE = nil
70
+ end
71
+
72
+ after :all do
73
+ $VERBOSE = @verbose
74
+ end
75
+
76
+ before :each do
77
+ @ruby_version = Object.const_get :RUBY_VERSION
78
+ @ruby_patch = Object.const_get :RUBY_PATCHLEVEL
79
+ @ruby_name = Object.const_get :RUBY_NAME
80
+
81
+ Object.const_set :RUBY_VERSION, '1.8.6'
82
+ Object.const_set :RUBY_PATCHLEVEL, 114
83
+ Object.const_set :RUBY_NAME, 'jruby'
84
+ end
85
+
86
+ after :each do
87
+ Object.const_set :RUBY_VERSION, @ruby_version
88
+ Object.const_set :RUBY_PATCHLEVEL, @ruby_patch
89
+ Object.const_set :RUBY_NAME, @ruby_name
90
+ end
91
+
92
+ it "returns false when version argument is less than RUBY_VERSION and RUBY_PATCHLEVEL" do
93
+ BugGuard.new("#1", "1.8").match?.should == false
94
+ BugGuard.new("#1", "1.8.6").match?.should == false
95
+ end
96
+
97
+ it "returns false when version argument is equal to RUBY_VERSION and RUBY_PATCHLEVEL" do
98
+ BugGuard.new("#1", "1.8.6.114").match?.should == false
99
+ end
100
+
101
+ it "returns false when version argument is greater than RUBY_VERSION and RUBY_PATCHLEVEL" do
102
+ BugGuard.new("#1", "1.8.7").match?.should == false
103
+ BugGuard.new("#1", "1.8.6.115").match?.should == false
104
+ end
105
+ end
106
+
107
+ describe Object, "#ruby_bug" do
108
+ before :each do
109
+ @guard = BugGuard.new "#1234", "x.x.x.x"
110
+ BugGuard.stub!(:new).and_return(@guard)
111
+ ScratchPad.clear
112
+ end
113
+
114
+ it "yields when #match? returns false" do
115
+ @guard.stub!(:match?).and_return(false)
116
+ ruby_bug { ScratchPad.record :yield }
117
+ ScratchPad.recorded.should == :yield
118
+ end
119
+
120
+ it "does not yield when #match? returns true" do
121
+ @guard.stub!(:match?).and_return(true)
122
+ ruby_bug { ScratchPad.record :yield }
123
+ ScratchPad.recorded.should_not == :yield
124
+ end
125
+
126
+ it "accepts an optional String identifying the bug tracker number" do
127
+ @guard.stub!(:match?).and_return(false)
128
+ ruby_bug("#1234") { ScratchPad.record :yield }
129
+ ScratchPad.recorded.should == :yield
130
+ end
131
+
132
+ it "accepts an optional String identifying the version number" do
133
+ @guard.stub!(:match?).and_return(false)
134
+ ruby_bug("#1234", "1.8.6") { ScratchPad.record :yield }
135
+ ScratchPad.recorded.should == :yield
136
+ end
137
+ end
@@ -0,0 +1,70 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'mspec/guards/compliance'
3
+
4
+ describe Object, "#compliant_on" do
5
+ before :each do
6
+ @guard = ComplianceGuard.new
7
+ ComplianceGuard.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
+ compliant_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
+ compliant_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
+ compliant_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
+ compliant_on(:rbx) { ScratchPad.record :yield }
34
+ ScratchPad.recorded.should == :yield
35
+ end
36
+ end
37
+
38
+ describe Object, "#not_compliant_on" do
39
+ before :each do
40
+ @guard = ComplianceGuard.new
41
+ ComplianceGuard.stub!(:new).and_return(@guard)
42
+ ScratchPad.clear
43
+ end
44
+
45
+ it "does not yield when #implementation? and #platform? return true" do
46
+ @guard.stub!(:implementation?).and_return(true)
47
+ @guard.stub!(:platform?).and_return(true)
48
+ not_compliant_on(:rbx) { ScratchPad.record :yield }
49
+ ScratchPad.recorded.should_not == :yield
50
+ end
51
+
52
+ it "does not yield when #implementation? or #platform? return true" do
53
+ @guard.stub!(:implementation?).and_return(true)
54
+ @guard.stub!(:platform?).and_return(false)
55
+ not_compliant_on(:rbx) { ScratchPad.record :yield }
56
+ ScratchPad.recorded.should_not == :yield
57
+
58
+ @guard.stub!(:implementation?).and_return(false)
59
+ @guard.stub!(:platform?).and_return(true)
60
+ not_compliant_on(:rbx) { ScratchPad.record :yield }
61
+ ScratchPad.recorded.should_not == :yield
62
+ end
63
+
64
+ it "yields when #implementation? and #platform? return false" do
65
+ @guard.stub!(:implementation?).and_return(false)
66
+ @guard.stub!(:platform?).and_return(false)
67
+ not_compliant_on(:rbx) { ScratchPad.record :yield }
68
+ ScratchPad.recorded.should == :yield
69
+ end
70
+ end