mspec 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +22 -0
- data/README +101 -0
- data/Rakefile +44 -0
- data/bin/mkspec +7 -0
- data/bin/mspec +7 -0
- data/bin/mspec-ci +8 -0
- data/bin/mspec-run +8 -0
- data/bin/mspec-tag +8 -0
- data/lib/mspec.rb +6 -0
- data/lib/mspec/commands/mkspec.rb +147 -0
- data/lib/mspec/commands/mspec-ci.rb +71 -0
- data/lib/mspec/commands/mspec-run.rb +80 -0
- data/lib/mspec/commands/mspec-tag.rb +87 -0
- data/lib/mspec/commands/mspec.rb +143 -0
- data/lib/mspec/expectations.rb +2 -0
- data/lib/mspec/expectations/expectations.rb +12 -0
- data/lib/mspec/expectations/should.rb +23 -0
- data/lib/mspec/guards.rb +13 -0
- data/lib/mspec/guards/bug.rb +27 -0
- data/lib/mspec/guards/compliance.rb +18 -0
- data/lib/mspec/guards/conflict.rb +16 -0
- data/lib/mspec/guards/endian.rb +40 -0
- data/lib/mspec/guards/extensions.rb +12 -0
- data/lib/mspec/guards/guard.rb +120 -0
- data/lib/mspec/guards/noncompliance.rb +12 -0
- data/lib/mspec/guards/platform.rb +38 -0
- data/lib/mspec/guards/quarantine.rb +15 -0
- data/lib/mspec/guards/runner.rb +30 -0
- data/lib/mspec/guards/superuser.rb +15 -0
- data/lib/mspec/guards/support.rb +12 -0
- data/lib/mspec/guards/version.rb +40 -0
- data/lib/mspec/helpers.rb +6 -0
- data/lib/mspec/helpers/bignum.rb +5 -0
- data/lib/mspec/helpers/const_lookup.rb +5 -0
- data/lib/mspec/helpers/flunk.rb +5 -0
- data/lib/mspec/helpers/io.rb +13 -0
- data/lib/mspec/helpers/scratch.rb +17 -0
- data/lib/mspec/helpers/tmp.rb +32 -0
- data/lib/mspec/matchers.rb +16 -0
- data/lib/mspec/matchers/base.rb +95 -0
- data/lib/mspec/matchers/be_ancestor_of.rb +24 -0
- data/lib/mspec/matchers/be_close.rb +27 -0
- data/lib/mspec/matchers/be_empty.rb +20 -0
- data/lib/mspec/matchers/be_false.rb +20 -0
- data/lib/mspec/matchers/be_kind_of.rb +24 -0
- data/lib/mspec/matchers/be_nil.rb +20 -0
- data/lib/mspec/matchers/be_true.rb +20 -0
- data/lib/mspec/matchers/complain.rb +56 -0
- data/lib/mspec/matchers/eql.rb +26 -0
- data/lib/mspec/matchers/equal.rb +26 -0
- data/lib/mspec/matchers/equal_utf16.rb +34 -0
- data/lib/mspec/matchers/include.rb +32 -0
- data/lib/mspec/matchers/output.rb +67 -0
- data/lib/mspec/matchers/output_to_fd.rb +71 -0
- data/lib/mspec/matchers/raise_error.rb +48 -0
- data/lib/mspec/mocks.rb +3 -0
- data/lib/mspec/mocks/mock.rb +123 -0
- data/lib/mspec/mocks/object.rb +28 -0
- data/lib/mspec/mocks/proxy.rb +112 -0
- data/lib/mspec/runner.rb +13 -0
- data/lib/mspec/runner/actions.rb +6 -0
- data/lib/mspec/runner/actions/debug.rb +17 -0
- data/lib/mspec/runner/actions/filter.rb +40 -0
- data/lib/mspec/runner/actions/gdb.rb +17 -0
- data/lib/mspec/runner/actions/tag.rb +97 -0
- data/lib/mspec/runner/actions/tally.rb +80 -0
- data/lib/mspec/runner/actions/timer.rb +22 -0
- data/lib/mspec/runner/filters.rb +4 -0
- data/lib/mspec/runner/filters/match.rb +22 -0
- data/lib/mspec/runner/filters/profile.rb +54 -0
- data/lib/mspec/runner/filters/regexp.rb +7 -0
- data/lib/mspec/runner/filters/tag.rb +29 -0
- data/lib/mspec/runner/formatters.rb +7 -0
- data/lib/mspec/runner/formatters/dotted.rb +81 -0
- data/lib/mspec/runner/formatters/html.rb +87 -0
- data/lib/mspec/runner/formatters/specdoc.rb +27 -0
- data/lib/mspec/runner/formatters/spinner.rb +89 -0
- data/lib/mspec/runner/formatters/summary.rb +8 -0
- data/lib/mspec/runner/formatters/unit.rb +25 -0
- data/lib/mspec/runner/formatters/yaml.rb +43 -0
- data/lib/mspec/runner/mspec.rb +232 -0
- data/lib/mspec/runner/object.rb +20 -0
- data/lib/mspec/runner/shared.rb +12 -0
- data/lib/mspec/runner/state.rb +116 -0
- data/lib/mspec/runner/tag.rb +20 -0
- data/lib/mspec/utils/name_map.rb +130 -0
- data/lib/mspec/utils/options.rb +344 -0
- data/lib/mspec/utils/script.rb +77 -0
- data/lib/mspec/version.rb +3 -0
- data/spec/commands/mkspec_spec.rb +321 -0
- data/spec/commands/mspec_ci_spec.rb +139 -0
- data/spec/commands/mspec_run_spec.rb +146 -0
- data/spec/commands/mspec_spec.rb +359 -0
- data/spec/commands/mspec_tag_spec.rb +131 -0
- data/spec/expectations/expectations_spec.rb +16 -0
- data/spec/expectations/should_spec.rb +99 -0
- data/spec/guards/bug_spec.rb +137 -0
- data/spec/guards/compliance_spec.rb +70 -0
- data/spec/guards/conflict_spec.rb +20 -0
- data/spec/guards/endian_spec.rb +42 -0
- data/spec/guards/extensions_spec.rb +36 -0
- data/spec/guards/guard_spec.rb +355 -0
- data/spec/guards/noncompliance_spec.rb +36 -0
- data/spec/guards/platform_spec.rb +84 -0
- data/spec/guards/quarantine_spec.rb +19 -0
- data/spec/guards/runner_spec.rb +75 -0
- data/spec/guards/superuser_spec.rb +22 -0
- data/spec/guards/support_spec.rb +22 -0
- data/spec/guards/version_spec.rb +133 -0
- data/spec/helpers/bignum_spec.rb +11 -0
- data/spec/helpers/const_lookup_spec.rb +19 -0
- data/spec/helpers/flunk_spec.rb +15 -0
- data/spec/helpers/io_spec.rb +34 -0
- data/spec/helpers/scratch_spec.rb +22 -0
- data/spec/helpers/tmp_spec.rb +72 -0
- data/spec/matchers/base_spec.rb +180 -0
- data/spec/matchers/be_ancestor_of_spec.rb +28 -0
- data/spec/matchers/be_close_spec.rb +46 -0
- data/spec/matchers/be_empty_spec.rb +26 -0
- data/spec/matchers/be_false_spec.rb +28 -0
- data/spec/matchers/be_kind_of_spec.rb +29 -0
- data/spec/matchers/be_nil_spec.rb +27 -0
- data/spec/matchers/be_true_spec.rb +28 -0
- data/spec/matchers/complain_spec.rb +52 -0
- data/spec/matchers/eql_spec.rb +33 -0
- data/spec/matchers/equal_spec.rb +33 -0
- data/spec/matchers/equal_utf16_spec.rb +47 -0
- data/spec/matchers/include_spec.rb +37 -0
- data/spec/matchers/output_spec.rb +74 -0
- data/spec/matchers/output_to_fd_spec.rb +33 -0
- data/spec/matchers/raise_error_spec.rb +56 -0
- data/spec/mocks/mock_spec.rb +272 -0
- data/spec/mocks/proxy_spec.rb +259 -0
- data/spec/runner/actions/debug_spec.rb +61 -0
- data/spec/runner/actions/filter_spec.rb +84 -0
- data/spec/runner/actions/gdb_spec.rb +61 -0
- data/spec/runner/actions/tag_spec.rb +253 -0
- data/spec/runner/actions/tally_spec.rb +107 -0
- data/spec/runner/actions/timer_spec.rb +42 -0
- data/spec/runner/filters/a.yaml +4 -0
- data/spec/runner/filters/b.yaml +11 -0
- data/spec/runner/filters/match_spec.rb +44 -0
- data/spec/runner/filters/profile_spec.rb +117 -0
- data/spec/runner/filters/regexp_spec.rb +13 -0
- data/spec/runner/filters/tag_spec.rb +77 -0
- data/spec/runner/formatters/dotted_spec.rb +184 -0
- data/spec/runner/formatters/html_spec.rb +191 -0
- data/spec/runner/formatters/specdoc_spec.rb +57 -0
- data/spec/runner/formatters/spinner_spec.rb +78 -0
- data/spec/runner/formatters/summary_spec.rb +29 -0
- data/spec/runner/formatters/unit_spec.rb +71 -0
- data/spec/runner/formatters/yaml_spec.rb +123 -0
- data/spec/runner/mspec_spec.rb +393 -0
- data/spec/runner/shared_spec.rb +41 -0
- data/spec/runner/state_spec.rb +535 -0
- data/spec/runner/tag_spec.rb +93 -0
- data/spec/runner/tags.txt +3 -0
- data/spec/spec_helper.rb +46 -0
- data/spec/utils/name_map_spec.rb +178 -0
- data/spec/utils/options_spec.rb +862 -0
- data/spec/utils/script_spec.rb +240 -0
- metadata +217 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require 'mspec/guards/conflict'
|
3
|
+
|
4
|
+
describe Object, "#conflicts_with" do
|
5
|
+
before :each do
|
6
|
+
ScratchPad.clear
|
7
|
+
end
|
8
|
+
|
9
|
+
it "does not yield if Object.constants includes any of the arguments" do
|
10
|
+
Object.stub!(:constants).and_return(["SomeClass", "OtherClass"])
|
11
|
+
conflicts_with(:SomeClass, :AClass, :BClass) { ScratchPad.record :yield }
|
12
|
+
ScratchPad.recorded.should_not == :yield
|
13
|
+
end
|
14
|
+
|
15
|
+
it "yields if Object.constants does not include any of the arguments" do
|
16
|
+
Object.stub!(:constants).and_return(["SomeClass", "OtherClass"])
|
17
|
+
conflicts_with(:AClass, :BClass) { ScratchPad.record :yield }
|
18
|
+
ScratchPad.recorded.should == :yield
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require 'mspec/guards/endian'
|
3
|
+
|
4
|
+
describe Object, "#big_endian" do
|
5
|
+
before :each do
|
6
|
+
@guard = BigEndianGuard.new
|
7
|
+
BigEndianGuard.stub!(:new).and_return(@guard)
|
8
|
+
ScratchPad.clear
|
9
|
+
end
|
10
|
+
|
11
|
+
it "yields on big-endian platforms" do
|
12
|
+
@guard.stub!(:pattern).and_return([1])
|
13
|
+
big_endian { ScratchPad.record :yield }
|
14
|
+
ScratchPad.recorded.should == :yield
|
15
|
+
end
|
16
|
+
|
17
|
+
it "does not yield on little-endian platforms" do
|
18
|
+
@guard.stub!(:pattern).and_return([0])
|
19
|
+
big_endian { ScratchPad.record :yield }
|
20
|
+
ScratchPad.recorded.should_not == :yield
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe Object, "#little_endian" do
|
25
|
+
before :each do
|
26
|
+
@guard = LittleEndianGuard.new
|
27
|
+
LittleEndianGuard.stub!(:new).and_return(@guard)
|
28
|
+
ScratchPad.clear
|
29
|
+
end
|
30
|
+
|
31
|
+
it "yields on little-endian platforms" do
|
32
|
+
@guard.stub!(:pattern).and_return([0])
|
33
|
+
little_endian { ScratchPad.record :yield }
|
34
|
+
ScratchPad.recorded.should == :yield
|
35
|
+
end
|
36
|
+
|
37
|
+
it "does not yield on big-endian platforms" do
|
38
|
+
@guard.stub!(:pattern).and_return([1])
|
39
|
+
little_endian { ScratchPad.record :yield }
|
40
|
+
ScratchPad.recorded.should_not == :yield
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require 'mspec/guards/extensions'
|
3
|
+
|
4
|
+
describe Object, "#extended_on" do
|
5
|
+
before :each do
|
6
|
+
@guard = ExtensionsGuard.new
|
7
|
+
ExtensionsGuard.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
|
+
extended_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
|
+
extended_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
|
+
extended_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
|
+
extended_on(:rbx) { ScratchPad.record :yield }
|
34
|
+
ScratchPad.recorded.should == :yield
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,355 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require 'mspec/guards/guard'
|
3
|
+
require 'rbconfig'
|
4
|
+
|
5
|
+
describe SpecGuard, ".register" do
|
6
|
+
before :each do
|
7
|
+
@tally = mock("tally")
|
8
|
+
@tally.stub!(:register)
|
9
|
+
TallyAction.stub!(:new).and_return(@tally)
|
10
|
+
SpecGuard.instance_variable_set(:@registered, nil)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "creates a new TallyAction if one does not exist" do
|
14
|
+
TallyAction.should_receive(:new).and_return(@tally)
|
15
|
+
@tally.should_receive(:register)
|
16
|
+
SpecGuard.register
|
17
|
+
SpecGuard.register
|
18
|
+
end
|
19
|
+
|
20
|
+
it "registers itself with MSpec :finish actions" do
|
21
|
+
MSpec.should_receive(:register).with(:finish, SpecGuard)
|
22
|
+
SpecGuard.register
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe SpecGuard, ".unregister" do
|
27
|
+
before :each do
|
28
|
+
@tally = mock("tally")
|
29
|
+
@tally.stub!(:register)
|
30
|
+
TallyAction.stub!(:new).and_return(@tally)
|
31
|
+
SpecGuard.instance_variable_set(:@registered, nil)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "unregisters its tally action" do
|
35
|
+
@tally.should_receive(:unregister)
|
36
|
+
SpecGuard.register
|
37
|
+
SpecGuard.unregister
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe SpecGuard, "#yield?" do
|
42
|
+
before :each do
|
43
|
+
MSpec.store :mode, nil
|
44
|
+
@guard = SpecGuard.new
|
45
|
+
end
|
46
|
+
|
47
|
+
it "returns true if MSpec.verify_mode? is true" do
|
48
|
+
MSpec.should_receive(:verify_mode?).and_return(true)
|
49
|
+
@guard.yield?.should == true
|
50
|
+
end
|
51
|
+
|
52
|
+
it "returns true if MSpec.verify_mode? is true regardless of invert being true" do
|
53
|
+
MSpec.should_receive(:verify_mode?).and_return(true)
|
54
|
+
@guard.yield?(true).should == true
|
55
|
+
end
|
56
|
+
|
57
|
+
it "returns true if MSpec.report_mode? is true" do
|
58
|
+
MSpec.should_receive(:report_mode?).and_return(true)
|
59
|
+
@guard.yield?.should == true
|
60
|
+
end
|
61
|
+
|
62
|
+
it "returns true if MSpec.report_mode? is true regardless of invert being true" do
|
63
|
+
MSpec.should_receive(:report_mode?).and_return(true)
|
64
|
+
@guard.yield?(true).should == true
|
65
|
+
end
|
66
|
+
|
67
|
+
it "returns #match? if neither report nor verify mode are true" do
|
68
|
+
@guard.stub!(:match?).and_return(false)
|
69
|
+
@guard.yield?.should == false
|
70
|
+
@guard.stub!(:match?).and_return(true)
|
71
|
+
@guard.yield?.should == true
|
72
|
+
end
|
73
|
+
|
74
|
+
it "returns #match? if invert is true and neither report nor verify mode are true" do
|
75
|
+
@guard.stub!(:match?).and_return(false)
|
76
|
+
@guard.yield?(true).should == true
|
77
|
+
@guard.stub!(:match?).and_return(true)
|
78
|
+
@guard.yield?(true).should == false
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe SpecGuard, "#===" do
|
83
|
+
it "returns true" do
|
84
|
+
anything = mock("anything")
|
85
|
+
SpecGuard.new.===(anything).should == true
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe SpecGuard, "#implementation?" do
|
90
|
+
before :all do
|
91
|
+
@verbose = $VERBOSE
|
92
|
+
$VERBOSE = nil
|
93
|
+
end
|
94
|
+
|
95
|
+
after :all do
|
96
|
+
$VERBOSE = @verbose
|
97
|
+
end
|
98
|
+
|
99
|
+
before :each do
|
100
|
+
@ruby_name = Object.const_get :RUBY_NAME
|
101
|
+
@guard = SpecGuard.new
|
102
|
+
end
|
103
|
+
|
104
|
+
after :each do
|
105
|
+
Object.const_set :RUBY_NAME, @ruby_name
|
106
|
+
end
|
107
|
+
|
108
|
+
it "returns true if passed :ruby and RUBY_NAME == 'ruby'" do
|
109
|
+
Object.const_set :RUBY_NAME, 'ruby'
|
110
|
+
@guard.implementation?(:ruby).should == true
|
111
|
+
end
|
112
|
+
|
113
|
+
it "returns true if passed :rbx and RUBY_NAME == 'rbx'" do
|
114
|
+
Object.const_set :RUBY_NAME, 'rbx'
|
115
|
+
@guard.implementation?(:rbx).should == true
|
116
|
+
end
|
117
|
+
|
118
|
+
it "returns true if passed :rubinius and RUBY_NAME == 'rbx'" do
|
119
|
+
Object.const_set :RUBY_NAME, 'rbx'
|
120
|
+
@guard.implementation?(:rubinius).should == true
|
121
|
+
end
|
122
|
+
|
123
|
+
it "returns true if passed :jruby and RUBY_NAME == 'jruby'" do
|
124
|
+
Object.const_set :RUBY_NAME, 'jruby'
|
125
|
+
@guard.implementation?(:jruby).should == true
|
126
|
+
end
|
127
|
+
|
128
|
+
it "returns false when passed an unrecognized name" do
|
129
|
+
Object.const_set :RUBY_NAME, 'ruby'
|
130
|
+
@guard.implementation?(:python).should == false
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe SpecGuard, "#platform?" do
|
135
|
+
before :all do
|
136
|
+
@verbose = $VERBOSE
|
137
|
+
$VERBOSE = nil
|
138
|
+
end
|
139
|
+
|
140
|
+
after :all do
|
141
|
+
$VERBOSE = @verbose
|
142
|
+
end
|
143
|
+
|
144
|
+
before :each do
|
145
|
+
@ruby_platform = Object.const_get :RUBY_PLATFORM
|
146
|
+
Object.const_set :RUBY_PLATFORM, 'solarce'
|
147
|
+
@guard = SpecGuard.new
|
148
|
+
end
|
149
|
+
|
150
|
+
after :each do
|
151
|
+
Object.const_set :RUBY_PLATFORM, @ruby_platform
|
152
|
+
end
|
153
|
+
|
154
|
+
it "returns false when arg does not match RUBY_PLATFORM" do
|
155
|
+
@guard.platform?(:ruby).should == false
|
156
|
+
end
|
157
|
+
|
158
|
+
it "returns false when no arg matches RUBY_PLATFORM" do
|
159
|
+
@guard.platform?(:ruby, :jruby, :rubinius).should == false
|
160
|
+
end
|
161
|
+
|
162
|
+
it "returns true when arg matches RUBY_PLATFORM" do
|
163
|
+
@guard.platform?(:solarce).should == true
|
164
|
+
end
|
165
|
+
|
166
|
+
it "returns true when any arg matches RUBY_PLATFORM" do
|
167
|
+
@guard.platform?(:ruby, :jruby, :solarce, :rubinius).should == true
|
168
|
+
end
|
169
|
+
|
170
|
+
it "returns true when arg is :windows and RUBY_PLATFORM contains 'mswin'" do
|
171
|
+
Object.const_set :RUBY_PLATFORM, 'i386-mswin32'
|
172
|
+
@guard.platform?(:windows).should == true
|
173
|
+
end
|
174
|
+
|
175
|
+
it "returns true when arg is :windows and RUBY_PLATFORM contains 'mingw'" do
|
176
|
+
Object.const_set :RUBY_PLATFORM, 'i386-mingw32'
|
177
|
+
@guard.platform?(:windows).should == true
|
178
|
+
end
|
179
|
+
|
180
|
+
it "returns false when arg is not :windows and Config::CONFIG['host_os'] contains 'mswin'" do
|
181
|
+
Object.const_set :RUBY_PLATFORM, 'i386-mswin32'
|
182
|
+
@guard.platform?(:linux).should == false
|
183
|
+
end
|
184
|
+
|
185
|
+
it "returns false when arg is not :windows and Config::CONFIG['host_os'] contains 'mingw'" do
|
186
|
+
Object.const_set :RUBY_PLATFORM, 'i386-mingw32'
|
187
|
+
@guard.platform?(:linux).should == false
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
describe SpecGuard, "#platform? on JRuby" do
|
192
|
+
before :all do
|
193
|
+
@verbose = $VERBOSE
|
194
|
+
$VERBOSE = nil
|
195
|
+
end
|
196
|
+
|
197
|
+
after :all do
|
198
|
+
$VERBOSE = @verbose
|
199
|
+
end
|
200
|
+
|
201
|
+
before :each do
|
202
|
+
@ruby_platform = Object.const_get :RUBY_PLATFORM
|
203
|
+
Object.const_set :RUBY_PLATFORM, 'java'
|
204
|
+
@guard = SpecGuard.new
|
205
|
+
end
|
206
|
+
|
207
|
+
after :each do
|
208
|
+
Object.const_set :RUBY_PLATFORM, @ruby_platform
|
209
|
+
end
|
210
|
+
|
211
|
+
it "returns true when arg is :java and RUBY_PLATFORM contains 'java'" do
|
212
|
+
@guard.platform?(:java).should == true
|
213
|
+
end
|
214
|
+
|
215
|
+
it "returns true when arg is :windows and RUBY_PLATFORM contains 'java' and os?(:windows) is true" do
|
216
|
+
Config::CONFIG.stub!(:[]).and_return('mswin32')
|
217
|
+
@guard.platform?(:windows).should == true
|
218
|
+
end
|
219
|
+
|
220
|
+
it "returns true when RUBY_PLATFORM contains 'java' and os?(argument) is true" do
|
221
|
+
Config::CONFIG.stub!(:[]).and_return('amiga')
|
222
|
+
@guard.platform?(:amiga).should == true
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
describe SpecGuard, "#wordsize?" do
|
227
|
+
before :each do
|
228
|
+
@guard = SpecGuard.new
|
229
|
+
end
|
230
|
+
|
231
|
+
it "returns true when arg is 32 and 1.size is 4" do
|
232
|
+
@guard.wordsize?(32).should == (1.size == 4)
|
233
|
+
end
|
234
|
+
|
235
|
+
it "returns true when arg is 64 and 1.size is 8" do
|
236
|
+
@guard.wordsize?(64).should == (1.size == 8)
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
describe SpecGuard, "#os?" do
|
241
|
+
before :each do
|
242
|
+
@guard = SpecGuard.new
|
243
|
+
Config::CONFIG.stub!(:[]).and_return('unreal')
|
244
|
+
end
|
245
|
+
|
246
|
+
it "returns true if argument matches Config::CONFIG['host_os']" do
|
247
|
+
@guard.os?(:unreal).should == true
|
248
|
+
end
|
249
|
+
|
250
|
+
it "returns true if any argument matches Config::CONFIG['host_os']" do
|
251
|
+
@guard.os?(:bsd, :unreal, :amiga).should == true
|
252
|
+
end
|
253
|
+
|
254
|
+
it "returns false if no argument matches Config::CONFIG['host_os']" do
|
255
|
+
@guard.os?(:bsd, :netbsd, :amiga, :msdos).should == false
|
256
|
+
end
|
257
|
+
|
258
|
+
it "returns false if argument does not match Config::CONFIG['host_os']" do
|
259
|
+
@guard.os?(:amiga).should == false
|
260
|
+
end
|
261
|
+
|
262
|
+
it "returns true when arg is :windows and Config::CONFIG['host_os'] contains 'mswin'" do
|
263
|
+
Config::CONFIG.stub!(:[]).and_return('i386-mswin32')
|
264
|
+
@guard.os?(:windows).should == true
|
265
|
+
end
|
266
|
+
|
267
|
+
it "returns true when arg is :windows and Config::CONFIG['host_os'] contains 'mingw'" do
|
268
|
+
Config::CONFIG.stub!(:[]).and_return('i386-mingw32')
|
269
|
+
@guard.os?(:windows).should == true
|
270
|
+
end
|
271
|
+
|
272
|
+
it "returns false when arg is not :windows and Config::CONFIG['host_os'] contains 'mswin'" do
|
273
|
+
Config::CONFIG.stub!(:[]).and_return('i386-mingw32')
|
274
|
+
@guard.os?(:linux).should == false
|
275
|
+
end
|
276
|
+
|
277
|
+
it "returns false when arg is not :windows and Config::CONFIG['host_os'] contains 'mingw'" do
|
278
|
+
Config::CONFIG.stub!(:[]).and_return('i386-mingw32')
|
279
|
+
@guard.os?(:linux).should == false
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
describe SpecGuard, "windows?" do
|
284
|
+
before :each do
|
285
|
+
@guard = SpecGuard.new
|
286
|
+
end
|
287
|
+
|
288
|
+
it "returns false if not passed :windows" do
|
289
|
+
@guard.windows?(:linux, 'mswin32').should == false
|
290
|
+
@guard.windows?(:linux, 'i386-mingw32').should == false
|
291
|
+
end
|
292
|
+
|
293
|
+
it "returns true if passed :windows and the key matches 'mswin' or 'mingw'" do
|
294
|
+
@guard.windows?(:windows, 'mswin32').should == true
|
295
|
+
@guard.windows?(:windows, 'i386-mingw32').should == true
|
296
|
+
end
|
297
|
+
|
298
|
+
it "returns false if passed :windows and the key matches neither 'mswin' nor 'mingw'" do
|
299
|
+
@guard.windows?(:windows, 'darwin9.0').should == false
|
300
|
+
@guard.windows?(:windows, 'linux').should == false
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
describe SpecGuard, "#match?" do
|
305
|
+
before :each do
|
306
|
+
@guard = SpecGuard.new
|
307
|
+
SpecGuard.stub!(:new).and_return(@guard)
|
308
|
+
end
|
309
|
+
|
310
|
+
it "returns true if #platform? or #implementation? return true" do
|
311
|
+
@guard.stub!(:implementation?).and_return(true)
|
312
|
+
@guard.stub!(:platform?).and_return(false)
|
313
|
+
@guard.match?.should == true
|
314
|
+
|
315
|
+
@guard.stub!(:implementation?).and_return(false)
|
316
|
+
@guard.stub!(:platform?).and_return(true)
|
317
|
+
@guard.match?.should == true
|
318
|
+
end
|
319
|
+
|
320
|
+
it "returns false if #platform? and #implementation? return false" do
|
321
|
+
@guard.stub!(:implementation?).and_return(false)
|
322
|
+
@guard.stub!(:platform?).and_return(false)
|
323
|
+
@guard.match?.should == false
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
describe SpecGuard, "#unregister" do
|
328
|
+
before :each do
|
329
|
+
@tally = mock("tally")
|
330
|
+
@tally.stub!(:register)
|
331
|
+
TallyAction.stub!(:new).and_return(@tally)
|
332
|
+
MSpec.stub!(:unregister)
|
333
|
+
@guard = SpecGuard.new
|
334
|
+
|
335
|
+
SpecGuard.instance_variable_set(:@registered, nil)
|
336
|
+
SpecGuard.register
|
337
|
+
end
|
338
|
+
|
339
|
+
it "unregisters from MSpec :exclude actions" do
|
340
|
+
MSpec.should_receive(:unregister).with(:exclude, @guard)
|
341
|
+
@tally.should_receive(:unregister)
|
342
|
+
@guard.unregister
|
343
|
+
end
|
344
|
+
|
345
|
+
it "unregisters from MSpec :after actions" do
|
346
|
+
MSpec.should_receive(:unregister).with(:after, @guard)
|
347
|
+
@tally.should_receive(:unregister)
|
348
|
+
@guard.unregister
|
349
|
+
end
|
350
|
+
|
351
|
+
it "invokes the class's unregister method" do
|
352
|
+
SpecGuard.should_receive(:unregister)
|
353
|
+
@guard.unregister
|
354
|
+
end
|
355
|
+
end
|