mspec 1.8.0 → 1.9.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.
- checksums.yaml +4 -4
- data/lib/mspec/matchers.rb +1 -0
- data/lib/mspec/matchers/block_caller.rb +34 -0
- data/lib/mspec/runner/actions/timer.rb +6 -2
- data/lib/mspec/runner/context.rb +1 -1
- data/lib/mspec/version.rb +1 -1
- data/spec/commands/mspec_spec.rb +2 -2
- data/spec/commands/mspec_tag_spec.rb +3 -3
- data/spec/guards/background_spec.rb +1 -1
- data/spec/guards/feature_spec.rb +4 -4
- data/spec/guards/guard_spec.rb +2 -2
- data/spec/helpers/fs_spec.rb +12 -12
- data/spec/helpers/numeric_spec.rb +1 -1
- data/spec/matchers/be_an_instance_of_spec.rb +6 -6
- data/spec/matchers/be_computed_by_function_spec.rb +4 -4
- data/spec/matchers/be_computed_by_spec.rb +5 -5
- data/spec/matchers/be_valid_dns_name_spec.rb +8 -8
- data/spec/matchers/block_caller_spec.rb +13 -0
- data/spec/matchers/equal_element_spec.rb +32 -32
- data/spec/matchers/have_class_variable_spec.rb +4 -4
- data/spec/matchers/have_constant_spec.rb +2 -2
- data/spec/matchers/have_data_spec.rb +4 -4
- data/spec/matchers/have_instance_method_spec.rb +4 -4
- data/spec/matchers/have_instance_variable_spec.rb +4 -4
- data/spec/matchers/have_method_spec.rb +6 -6
- data/spec/matchers/have_private_instance_method_spec.rb +4 -4
- data/spec/matchers/have_private_method_spec.rb +2 -2
- data/spec/matchers/have_protected_instance_method_spec.rb +4 -4
- data/spec/matchers/have_public_instance_method_spec.rb +4 -4
- data/spec/matchers/have_singleton_method_spec.rb +2 -2
- data/spec/mocks/mock_spec.rb +5 -5
- data/spec/mocks/proxy_spec.rb +8 -8
- data/spec/runner/actions/tag_spec.rb +7 -7
- data/spec/runner/actions/taglist_spec.rb +3 -3
- data/spec/runner/actions/timer_spec.rb +4 -4
- data/spec/runner/context_spec.rb +17 -17
- data/spec/runner/exception_spec.rb +3 -3
- data/spec/runner/formatters/dotted_spec.rb +15 -15
- data/spec/runner/formatters/file_spec.rb +4 -4
- data/spec/runner/formatters/specdoc_spec.rb +2 -2
- data/spec/runner/mspec_spec.rb +19 -15
- data/spec/utils/options_spec.rb +9 -11
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20b523d18faeba6833feae1b3539abaaa165bd65
|
4
|
+
data.tar.gz: d36ed3f25a4ce40cd94f5343ba28143e46736460
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 253e777134a828707b7f30eff06808519ad4da111b51498bd4e1252834a783f98ce6fe700be8012f8dd835fc411b7e05eb0e4133107dcd95031a97105013b1be
|
7
|
+
data.tar.gz: b6b1f8e113718582d7ff11f157bc321db0e647064df41ff7f2db71c3ad2a997c7f44e24c8be07421564cd1fcec486ba8cff34844c488db16d93b3d9b4d410711
|
data/lib/mspec/matchers.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
class BlockingMatcher
|
2
|
+
def initialize(timeout = 0.1)
|
3
|
+
@timeout = timeout
|
4
|
+
end
|
5
|
+
|
6
|
+
def matches?(block)
|
7
|
+
blocking = true
|
8
|
+
|
9
|
+
thread = Thread.new do
|
10
|
+
block.call
|
11
|
+
|
12
|
+
blocking = false
|
13
|
+
end
|
14
|
+
|
15
|
+
thread.join(@timeout)
|
16
|
+
thread.kill
|
17
|
+
|
18
|
+
blocking
|
19
|
+
end
|
20
|
+
|
21
|
+
def failure_message
|
22
|
+
['Expected the given Proc', 'to block the caller']
|
23
|
+
end
|
24
|
+
|
25
|
+
def negative_failure_message
|
26
|
+
['Expected the given Proc', 'to not block the caller']
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class Object
|
31
|
+
def block_caller(timeout = 0.1)
|
32
|
+
BlockingMatcher.new(timeout)
|
33
|
+
end
|
34
|
+
end
|
@@ -5,11 +5,11 @@ class TimerAction
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def start
|
8
|
-
@start =
|
8
|
+
@start = current_time
|
9
9
|
end
|
10
10
|
|
11
11
|
def finish
|
12
|
-
@stop =
|
12
|
+
@stop = current_time
|
13
13
|
end
|
14
14
|
|
15
15
|
def elapsed
|
@@ -19,4 +19,8 @@ class TimerAction
|
|
19
19
|
def format
|
20
20
|
"Finished in %f seconds" % elapsed
|
21
21
|
end
|
22
|
+
|
23
|
+
def current_time
|
24
|
+
Time.now
|
25
|
+
end
|
22
26
|
end
|
data/lib/mspec/runner/context.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
#--
|
7
7
|
# A note on naming: this is named _ContextState_ rather
|
8
8
|
# than _DescribeState_ because +describe+ is the keyword
|
9
|
-
# in the DSL for
|
9
|
+
# in the DSL for referring to the context in which an example
|
10
10
|
# is evaluated, just as +it+ refers to the example itself.
|
11
11
|
#++
|
12
12
|
class ContextState
|
data/lib/mspec/version.rb
CHANGED
data/spec/commands/mspec_spec.rb
CHANGED
@@ -253,7 +253,7 @@ describe MSpecMain, "#run" do
|
|
253
253
|
end
|
254
254
|
|
255
255
|
it "calls #multi_exec if the command is 'ci' and the multi option is passed" do
|
256
|
-
@script.should_receive(:multi_exec)
|
256
|
+
@script.should_receive(:multi_exec) do |arg|
|
257
257
|
arg.length.should == 3
|
258
258
|
arg[0].should == "-v"
|
259
259
|
arg[1].should =~ %r"#{MSPEC_HOME}/bin/mspec-ci$"
|
@@ -282,7 +282,7 @@ describe "The -A, --valgrind option" do
|
|
282
282
|
["-A", "--valgrind"].each do |opt|
|
283
283
|
@config[:use_valgrind] = false
|
284
284
|
@script.options [opt]
|
285
|
-
@config[:use_valgrind].should
|
285
|
+
@config[:use_valgrind].should be_truthy
|
286
286
|
end
|
287
287
|
end
|
288
288
|
end
|
@@ -360,7 +360,7 @@ describe MSpecTag, "#register" do
|
|
360
360
|
|
361
361
|
it "sets config[:formatter] to false" do
|
362
362
|
@script.register
|
363
|
-
@config[:formatter].should
|
363
|
+
@config[:formatter].should be_falsey
|
364
364
|
end
|
365
365
|
end
|
366
366
|
|
@@ -382,7 +382,7 @@ describe MSpecTag, "#register" do
|
|
382
382
|
|
383
383
|
it "sets config[:formatter] to false" do
|
384
384
|
@script.register
|
385
|
-
@config[:formatter].should
|
385
|
+
@config[:formatter].should be_falsey
|
386
386
|
end
|
387
387
|
end
|
388
388
|
|
@@ -410,7 +410,7 @@ describe MSpecTag, "#register" do
|
|
410
410
|
|
411
411
|
it "sets config[:formatter] to false" do
|
412
412
|
@script.register
|
413
|
-
@config[:formatter].should
|
413
|
+
@config[:formatter].should be_falsey
|
414
414
|
end
|
415
415
|
end
|
416
416
|
end
|
@@ -11,7 +11,7 @@ describe Object, "#process_is_foreground" do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "yields if MSpec.mode?(:background) is false" do
|
14
|
-
MSpec.mode?(:background).should
|
14
|
+
MSpec.mode?(:background).should be_falsey
|
15
15
|
process_is_foreground { ScratchPad.record :yield }
|
16
16
|
ScratchPad.recorded.should == :yield
|
17
17
|
end
|
data/spec/guards/feature_spec.rb
CHANGED
@@ -4,24 +4,24 @@ require 'mspec/guards'
|
|
4
4
|
describe FeatureGuard, ".enabled?" do
|
5
5
|
it "returns true if the feature is enabled" do
|
6
6
|
MSpec.should_receive(:feature_enabled?).with(:encoding).and_return(true)
|
7
|
-
FeatureGuard.enabled?(:encoding).should
|
7
|
+
FeatureGuard.enabled?(:encoding).should be_truthy
|
8
8
|
end
|
9
9
|
|
10
10
|
it "returns false if the feature is not enabled" do
|
11
11
|
MSpec.should_receive(:feature_enabled?).with(:encoding).and_return(false)
|
12
|
-
FeatureGuard.enabled?(:encoding).should
|
12
|
+
FeatureGuard.enabled?(:encoding).should be_falsey
|
13
13
|
end
|
14
14
|
|
15
15
|
it "returns true if all the features are enabled" do
|
16
16
|
MSpec.should_receive(:feature_enabled?).with(:one).and_return(true)
|
17
17
|
MSpec.should_receive(:feature_enabled?).with(:two).and_return(true)
|
18
|
-
FeatureGuard.enabled?(:one, :two).should
|
18
|
+
FeatureGuard.enabled?(:one, :two).should be_truthy
|
19
19
|
end
|
20
20
|
|
21
21
|
it "returns false if any of the features are not enabled" do
|
22
22
|
MSpec.should_receive(:feature_enabled?).with(:one).and_return(true)
|
23
23
|
MSpec.should_receive(:feature_enabled?).with(:two).and_return(false)
|
24
|
-
FeatureGuard.enabled?(:one, :two).should
|
24
|
+
FeatureGuard.enabled?(:one, :two).should be_falsey
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
data/spec/guards/guard_spec.rb
CHANGED
@@ -240,12 +240,12 @@ describe SpecGuard, "#standard?" do
|
|
240
240
|
|
241
241
|
it "returns true if #implementation? returns true" do
|
242
242
|
@guard.should_receive(:implementation?).with(:ruby).and_return(true)
|
243
|
-
@guard.standard?.should
|
243
|
+
@guard.standard?.should be_truthy
|
244
244
|
end
|
245
245
|
|
246
246
|
it "returns false if #implementation? returns false" do
|
247
247
|
@guard.should_receive(:implementation?).with(:ruby).and_return(false)
|
248
|
-
@guard.standard?.should
|
248
|
+
@guard.standard?.should be_falsey
|
249
249
|
end
|
250
250
|
end
|
251
251
|
|
data/spec/helpers/fs_spec.rb
CHANGED
@@ -35,12 +35,12 @@ describe Object, "#touch" do
|
|
35
35
|
|
36
36
|
it "creates a file" do
|
37
37
|
touch @name
|
38
|
-
File.exist?(@name).should
|
38
|
+
File.exist?(@name).should be_truthy
|
39
39
|
end
|
40
40
|
|
41
41
|
it "accepts an optional mode argument" do
|
42
42
|
touch @name, "wb"
|
43
|
-
File.exist?(@name).should
|
43
|
+
File.exist?(@name).should be_truthy
|
44
44
|
end
|
45
45
|
|
46
46
|
it "overwrites an existing file" do
|
@@ -68,7 +68,7 @@ describe Object, "#touch" do
|
|
68
68
|
|
69
69
|
it "creates all the directories in the path to the file" do
|
70
70
|
touch @name
|
71
|
-
File.exist?(@name).should
|
71
|
+
File.exist?(@name).should be_truthy
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -86,7 +86,7 @@ describe Object, "#mkdir_p" do
|
|
86
86
|
|
87
87
|
it "creates all the directories in a path" do
|
88
88
|
mkdir_p @dir2
|
89
|
-
File.directory?(@dir2).should
|
89
|
+
File.directory?(@dir2).should be_truthy
|
90
90
|
end
|
91
91
|
|
92
92
|
it "raises an ArgumentError if a path component is a file" do
|
@@ -129,20 +129,20 @@ describe Object, "#rm_r" do
|
|
129
129
|
|
130
130
|
it "removes a single file" do
|
131
131
|
rm_r @subfile
|
132
|
-
File.exist?(@subfile).should
|
132
|
+
File.exist?(@subfile).should be_falsey
|
133
133
|
end
|
134
134
|
|
135
135
|
it "removes multiple files" do
|
136
136
|
rm_r @topfile, @subfile
|
137
|
-
File.exist?(@topfile).should
|
138
|
-
File.exist?(@subfile).should
|
137
|
+
File.exist?(@topfile).should be_falsey
|
138
|
+
File.exist?(@subfile).should be_falsey
|
139
139
|
end
|
140
140
|
|
141
141
|
platform_is_not :windows do
|
142
142
|
it "removes a symlink to a file" do
|
143
143
|
File.symlink @topfile, @link
|
144
144
|
rm_r @link
|
145
|
-
File.exist?(@link).should
|
145
|
+
File.exist?(@link).should be_falsey
|
146
146
|
end
|
147
147
|
|
148
148
|
it "removes a symlink to a directory" do
|
@@ -151,7 +151,7 @@ describe Object, "#rm_r" do
|
|
151
151
|
lambda do
|
152
152
|
File.lstat(@link)
|
153
153
|
end.should raise_error(Errno::ENOENT)
|
154
|
-
File.exist?(@subdir1).should
|
154
|
+
File.exist?(@subdir1).should be_truthy
|
155
155
|
end
|
156
156
|
|
157
157
|
it "removes a dangling symlink" do
|
@@ -166,17 +166,17 @@ describe Object, "#rm_r" do
|
|
166
166
|
require 'socket'
|
167
167
|
UNIXServer.new(@socket).close
|
168
168
|
rm_r @socket
|
169
|
-
File.exist?(@socket).should
|
169
|
+
File.exist?(@socket).should be_falsey
|
170
170
|
end
|
171
171
|
end
|
172
172
|
|
173
173
|
it "removes a single directory" do
|
174
174
|
rm_r @subdir2
|
175
|
-
File.directory?(@subdir2).should
|
175
|
+
File.directory?(@subdir2).should be_falsey
|
176
176
|
end
|
177
177
|
|
178
178
|
it "recursively removes a directory tree" do
|
179
179
|
rm_r @topdir
|
180
|
-
File.directory?(@topdir).should
|
180
|
+
File.directory?(@topdir).should be_falsey
|
181
181
|
end
|
182
182
|
end
|
@@ -16,22 +16,22 @@ end
|
|
16
16
|
describe BeAnInstanceOfMatcher do
|
17
17
|
it "matches when actual is an instance_of? expected" do
|
18
18
|
a = BeAnInOfSpecs::A.new
|
19
|
-
BeAnInstanceOfMatcher.new(BeAnInOfSpecs::A).matches?(a).should
|
19
|
+
BeAnInstanceOfMatcher.new(BeAnInOfSpecs::A).matches?(a).should be_truthy
|
20
20
|
|
21
21
|
b = BeAnInOfSpecs::B.new
|
22
|
-
BeAnInstanceOfMatcher.new(BeAnInOfSpecs::B).matches?(b).should
|
22
|
+
BeAnInstanceOfMatcher.new(BeAnInOfSpecs::B).matches?(b).should be_truthy
|
23
23
|
end
|
24
24
|
|
25
25
|
it "does not match when actual is not an instance_of? expected" do
|
26
26
|
a = BeAnInOfSpecs::A.new
|
27
|
-
BeAnInstanceOfMatcher.new(BeAnInOfSpecs::B).matches?(a).should
|
27
|
+
BeAnInstanceOfMatcher.new(BeAnInOfSpecs::B).matches?(a).should be_falsey
|
28
28
|
|
29
29
|
b = BeAnInOfSpecs::B.new
|
30
|
-
BeAnInstanceOfMatcher.new(BeAnInOfSpecs::A).matches?(b).should
|
30
|
+
BeAnInstanceOfMatcher.new(BeAnInOfSpecs::A).matches?(b).should be_falsey
|
31
31
|
|
32
32
|
c = BeAnInOfSpecs::C.new
|
33
|
-
BeAnInstanceOfMatcher.new(BeAnInOfSpecs::A).matches?(c).should
|
34
|
-
BeAnInstanceOfMatcher.new(BeAnInOfSpecs::B).matches?(c).should
|
33
|
+
BeAnInstanceOfMatcher.new(BeAnInOfSpecs::A).matches?(c).should be_falsey
|
34
|
+
BeAnInstanceOfMatcher.new(BeAnInOfSpecs::B).matches?(c).should be_falsey
|
35
35
|
end
|
36
36
|
|
37
37
|
it "provides a useful failure message" do
|
@@ -5,25 +5,25 @@ describe BeComputedByFunctionMatcher do
|
|
5
5
|
it "matches when all entries in the Array compute" do
|
6
6
|
array = [ ["%2d", 65, "65"],
|
7
7
|
["%04d", 90, "0090"] ]
|
8
|
-
BeComputedByFunctionMatcher.new(:sprintf).matches?(array).should
|
8
|
+
BeComputedByFunctionMatcher.new(:sprintf).matches?(array).should be_truthy
|
9
9
|
end
|
10
10
|
|
11
11
|
it "matches when all entries in the Array with arguments compute" do
|
12
12
|
array = [ ["%2d", "65"],
|
13
13
|
["%04d", "0065"] ]
|
14
|
-
BeComputedByFunctionMatcher.new(:sprintf, 65).matches?(array).should
|
14
|
+
BeComputedByFunctionMatcher.new(:sprintf, 65).matches?(array).should be_truthy
|
15
15
|
end
|
16
16
|
|
17
17
|
it "does not match when any entry in the Array does not compute" do
|
18
18
|
array = [ ["%2d", 65, "65"],
|
19
19
|
["%04d", 90, "00090"] ]
|
20
|
-
BeComputedByFunctionMatcher.new(:sprintf).matches?(array).should
|
20
|
+
BeComputedByFunctionMatcher.new(:sprintf).matches?(array).should be_falsey
|
21
21
|
end
|
22
22
|
|
23
23
|
it "does not match when any entry in the Array with arguments does not compute" do
|
24
24
|
array = [ ["%2d", "65"],
|
25
25
|
["%04d", "0065"] ]
|
26
|
-
BeComputedByFunctionMatcher.new(:sprintf, 91).matches?(array).should
|
26
|
+
BeComputedByFunctionMatcher.new(:sprintf, 91).matches?(array).should be_falsey
|
27
27
|
end
|
28
28
|
|
29
29
|
it "provides a useful failure message" do
|
@@ -5,31 +5,31 @@ describe BeComputedByMatcher do
|
|
5
5
|
it "matches when all entries in the Array compute" do
|
6
6
|
array = [ [65, "A"],
|
7
7
|
[90, "Z"] ]
|
8
|
-
BeComputedByMatcher.new(:chr).matches?(array).should
|
8
|
+
BeComputedByMatcher.new(:chr).matches?(array).should be_truthy
|
9
9
|
end
|
10
10
|
|
11
11
|
it "matches when all entries in the Array with arguments compute" do
|
12
12
|
array = [ [1, 2, 3],
|
13
13
|
[2, 4, 6] ]
|
14
|
-
BeComputedByMatcher.new(:+).matches?(array).should
|
14
|
+
BeComputedByMatcher.new(:+).matches?(array).should be_truthy
|
15
15
|
end
|
16
16
|
|
17
17
|
it "does not match when any entry in the Array does not compute" do
|
18
18
|
array = [ [65, "A" ],
|
19
19
|
[91, "Z" ] ]
|
20
|
-
BeComputedByMatcher.new(:chr).matches?(array).should
|
20
|
+
BeComputedByMatcher.new(:chr).matches?(array).should be_falsey
|
21
21
|
end
|
22
22
|
|
23
23
|
it "accepts an argument list to apply to each method call" do
|
24
24
|
array = [ [65, "1000001" ],
|
25
25
|
[90, "1011010" ] ]
|
26
|
-
BeComputedByMatcher.new(:to_s, 2).matches?(array).should
|
26
|
+
BeComputedByMatcher.new(:to_s, 2).matches?(array).should be_truthy
|
27
27
|
end
|
28
28
|
|
29
29
|
it "does not match when any entry in the Array with arguments does not compute" do
|
30
30
|
array = [ [1, 2, 3],
|
31
31
|
[2, 4, 7] ]
|
32
|
-
BeComputedByMatcher.new(:+).matches?(array).should
|
32
|
+
BeComputedByMatcher.new(:+).matches?(array).should be_falsey
|
33
33
|
end
|
34
34
|
|
35
35
|
it "provides a useful failure message" do
|
@@ -4,35 +4,35 @@ require 'mspec/matchers'
|
|
4
4
|
|
5
5
|
describe BeValidDNSName do
|
6
6
|
it "matches when actual is 'localhost'" do
|
7
|
-
BeValidDNSName.new.matches?("localhost").should
|
7
|
+
BeValidDNSName.new.matches?("localhost").should be_truthy
|
8
8
|
end
|
9
9
|
|
10
10
|
it "matches when actual is 'localhost.localdomain'" do
|
11
|
-
BeValidDNSName.new.matches?("localhost.localdomain").should
|
11
|
+
BeValidDNSName.new.matches?("localhost.localdomain").should be_truthy
|
12
12
|
end
|
13
13
|
|
14
14
|
it "matches when actual is hyphenated" do
|
15
|
-
BeValidDNSName.new.matches?("local-host").should
|
15
|
+
BeValidDNSName.new.matches?("local-host").should be_truthy
|
16
16
|
end
|
17
17
|
|
18
18
|
it "matches when actual is 'a.b.c'" do
|
19
|
-
BeValidDNSName.new.matches?("a.b.c").should
|
19
|
+
BeValidDNSName.new.matches?("a.b.c").should be_truthy
|
20
20
|
end
|
21
21
|
|
22
22
|
it "matches when actual has a trailing '.'" do
|
23
|
-
BeValidDNSName.new.matches?("a.com.").should
|
23
|
+
BeValidDNSName.new.matches?("a.com.").should be_truthy
|
24
24
|
end
|
25
25
|
|
26
26
|
it "does not match when actual is not a valid dns name" do
|
27
|
-
BeValidDNSName.new.matches?(".").should
|
27
|
+
BeValidDNSName.new.matches?(".").should be_falsey
|
28
28
|
end
|
29
29
|
|
30
30
|
it "does not match when actual contains a hyphen at the beginning" do
|
31
|
-
BeValidDNSName.new.matches?("-localhost").should
|
31
|
+
BeValidDNSName.new.matches?("-localhost").should be_falsey
|
32
32
|
end
|
33
33
|
|
34
34
|
it "does not match when actual contains a hyphen at the end" do
|
35
|
-
BeValidDNSName.new.matches?("localhost-").should
|
35
|
+
BeValidDNSName.new.matches?("localhost-").should be_falsey
|
36
36
|
end
|
37
37
|
|
38
38
|
it "provides a failure message" do
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'mspec/expectations/expectations'
|
3
|
+
require 'mspec/matchers'
|
4
|
+
|
5
|
+
describe BlockingMatcher do
|
6
|
+
it 'matches when a Proc blocks the caller' do
|
7
|
+
BlockingMatcher.new.matches?(proc { sleep }).should == true
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'does not match when a Proc does not block the caller' do
|
11
|
+
BlockingMatcher.new.matches?(proc { 1 }).should == false
|
12
|
+
end
|
13
|
+
end
|