mspec 1.5.17 → 1.5.18
Sign up to get free protection for your applications and to get access to all the features.
- 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/spec/guards/runner_spec.rb
CHANGED
data/spec/guards/support_spec.rb
CHANGED
data/spec/guards/tty_spec.rb
CHANGED
data/spec/guards/user_spec.rb
CHANGED
data/spec/guards/version_spec.rb
CHANGED
data/spec/helpers/argv_spec.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'mspec/guards'
|
3
|
+
require 'mspec/helpers'
|
4
|
+
|
5
|
+
describe Object, "#new_datetime" do
|
6
|
+
it "returns a default DateTime instance" do
|
7
|
+
new_datetime.should == DateTime.new
|
8
|
+
end
|
9
|
+
|
10
|
+
it "returns a DateTime instance with the specified year value" do
|
11
|
+
d = new_datetime :year => 1970
|
12
|
+
d.year.should == 1970
|
13
|
+
end
|
14
|
+
|
15
|
+
it "returns a DateTime instance with the specified month value" do
|
16
|
+
d = new_datetime :month => 11
|
17
|
+
d.mon.should == 11
|
18
|
+
end
|
19
|
+
|
20
|
+
it "returns a DateTime instance with the specified day value" do
|
21
|
+
d = new_datetime :day => 23
|
22
|
+
d.day.should == 23
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns a DateTime instance with the specified hour value" do
|
26
|
+
d = new_datetime :hour => 10
|
27
|
+
d.hour.should == 10
|
28
|
+
end
|
29
|
+
|
30
|
+
it "returns a DateTime instance with the specified minute value" do
|
31
|
+
d = new_datetime :minute => 10
|
32
|
+
d.min.should == 10
|
33
|
+
end
|
34
|
+
|
35
|
+
it "returns a DateTime instance with the specified second value" do
|
36
|
+
d = new_datetime :second => 2
|
37
|
+
d.sec.should == 2
|
38
|
+
end
|
39
|
+
|
40
|
+
it "returns a DateTime instance with the specified offset value" do
|
41
|
+
d = new_datetime :offset => Rational(3,24)
|
42
|
+
d.offset.should == Rational(3,24)
|
43
|
+
end
|
44
|
+
end
|
data/spec/helpers/encode_spec.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
require
|
2
|
-
require 'mspec/
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'mspec/guards'
|
3
|
+
require 'mspec/helpers'
|
3
4
|
|
4
5
|
describe "#enumerator_class" do
|
5
6
|
|
6
|
-
ruby_version_is ''...'1.
|
7
|
+
ruby_version_is ''...'1.9' do
|
7
8
|
it "returns Enumerable::Enumerator in Ruby 1.8.6-" do
|
8
|
-
lambda { enumerator_class }.should raise_error(NameError)
|
9
9
|
require 'enumerator'
|
10
10
|
enumerator_class.should == Enumerable::Enumerator
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
ruby_version_is '1.
|
14
|
+
ruby_version_is '1.9' do
|
15
15
|
it "returns Enumerator in Ruby 1.8.7+" do
|
16
16
|
enumerator_class.should == Enumerator
|
17
17
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require 'mspec/guards
|
3
|
-
require 'mspec/helpers
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'mspec/guards'
|
3
|
+
require 'mspec/helpers'
|
4
4
|
|
5
5
|
describe "#env" do
|
6
6
|
it "returns a hash of variables" do
|
@@ -61,3 +61,15 @@ describe "#username" do
|
|
61
61
|
username.should == "john"
|
62
62
|
end
|
63
63
|
end
|
64
|
+
|
65
|
+
describe "dev_null" do
|
66
|
+
it "returns 'NUL' on Windows" do
|
67
|
+
PlatformGuard.should_receive(:windows?).and_return(true)
|
68
|
+
dev_null().should == "NUL"
|
69
|
+
end
|
70
|
+
|
71
|
+
it "returns '/dev/null' on non-Windows" do
|
72
|
+
PlatformGuard.should_receive(:windows?).and_return(false)
|
73
|
+
dev_null().should == "/dev/null"
|
74
|
+
end
|
75
|
+
end
|
data/spec/helpers/flunk_spec.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'mspec/expectations/expectations'
|
3
|
-
require 'mspec/helpers/flunk'
|
4
3
|
require 'mspec/runner/mspec'
|
4
|
+
require 'mspec/guards'
|
5
|
+
require 'mspec/helpers'
|
5
6
|
|
6
7
|
describe Object, "#flunk" do
|
7
8
|
before :each do
|
8
9
|
MSpec.stub!(:actions)
|
9
|
-
MSpec.stub!(:current).and_return(mock("spec state"
|
10
|
+
MSpec.stub!(:current).and_return(mock("spec state").as_null_object)
|
10
11
|
end
|
11
12
|
|
12
13
|
it "raises an SpecExpectationNotMetError unconditionally" do
|
data/spec/helpers/fs_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require 'mspec/
|
3
|
-
require 'mspec/helpers
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'mspec/guards'
|
3
|
+
require 'mspec/helpers'
|
4
4
|
|
5
5
|
describe Object, "#cp" do
|
6
6
|
before :each do
|
@@ -59,13 +59,11 @@ end
|
|
59
59
|
|
60
60
|
describe Object, "#touch" do
|
61
61
|
before :all do
|
62
|
-
@dir = tmp("subdir")
|
63
62
|
@name = tmp("subdir/touched.txt")
|
64
63
|
end
|
65
64
|
|
66
65
|
after :each do
|
67
|
-
|
68
|
-
Dir.rmdir @dir if File.directory? @dir
|
66
|
+
rm_r File.dirname(@name)
|
69
67
|
end
|
70
68
|
|
71
69
|
it "creates all the directories in the path to the file" do
|
@@ -115,7 +113,7 @@ describe Object, "#rm_r" do
|
|
115
113
|
end
|
116
114
|
|
117
115
|
after :each do
|
118
|
-
File.delete @link if File.exists? @link
|
116
|
+
File.delete @link if File.exists? @link or File.symlink? @link
|
119
117
|
File.delete @socket if File.exists? @socket
|
120
118
|
File.delete @subfile if File.exists? @subfile
|
121
119
|
File.delete @topfile if File.exists? @topfile
|
@@ -140,17 +138,36 @@ describe Object, "#rm_r" do
|
|
140
138
|
File.exists?(@subfile).should be_false
|
141
139
|
end
|
142
140
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
141
|
+
platform_is_not :windows do
|
142
|
+
it "removes a symlink to a file" do
|
143
|
+
File.symlink @topfile, @link
|
144
|
+
rm_r @link
|
145
|
+
File.exists?(@link).should be_false
|
146
|
+
end
|
147
|
+
|
148
|
+
it "removes a symlink to a directory" do
|
149
|
+
File.symlink @subdir1, @link
|
150
|
+
rm_r @link
|
151
|
+
lambda do
|
152
|
+
File.lstat(@link)
|
153
|
+
end.should raise_error(Errno::ENOENT)
|
154
|
+
File.exists?(@subdir1).should be_true
|
155
|
+
end
|
156
|
+
|
157
|
+
it "removes a dangling symlink" do
|
158
|
+
File.symlink "non_existent_file", @link
|
159
|
+
rm_r @link
|
160
|
+
lambda do
|
161
|
+
File.lstat(@link)
|
162
|
+
end.should raise_error(Errno::ENOENT)
|
163
|
+
end
|
164
|
+
|
165
|
+
it "removes a socket" do
|
166
|
+
require 'socket'
|
167
|
+
UNIXServer.new(@socket).close
|
168
|
+
rm_r @socket
|
169
|
+
File.exists?(@socket).should be_false
|
170
|
+
end
|
154
171
|
end
|
155
172
|
|
156
173
|
it "removes a single directory" do
|
data/spec/helpers/hash_spec.rb
CHANGED
data/spec/helpers/io_spec.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require 'mspec/
|
3
|
-
require 'mspec/helpers
|
4
|
-
require 'mspec/helpers/tmp'
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'mspec/guards'
|
3
|
+
require 'mspec/helpers'
|
5
4
|
|
6
5
|
describe IOStub do
|
7
6
|
before :each do
|
@@ -51,7 +50,7 @@ describe Object, "#new_fd" do
|
|
51
50
|
end
|
52
51
|
|
53
52
|
after :each do
|
54
|
-
@io.close
|
53
|
+
@io.close if @io and not @io.closed?
|
55
54
|
rm_r @name
|
56
55
|
end
|
57
56
|
|
@@ -59,12 +58,29 @@ describe Object, "#new_fd" do
|
|
59
58
|
fd = new_fd @name
|
60
59
|
fd.should be_an_instance_of(Fixnum)
|
61
60
|
|
62
|
-
@io = IO.new fd
|
61
|
+
@io = IO.new fd, fmode('w:utf-8')
|
63
62
|
@io.sync = true
|
64
63
|
@io.print "io data"
|
65
64
|
|
66
65
|
IO.read(@name).should == "io data"
|
67
66
|
end
|
67
|
+
|
68
|
+
it "accepts an options Hash" do
|
69
|
+
FeatureGuard.stub!(:enabled?).and_return(true)
|
70
|
+
fd = new_fd @name, { :mode => 'w:utf-8' }
|
71
|
+
fd.should be_an_instance_of(Fixnum)
|
72
|
+
|
73
|
+
@io = IO.new fd, fmode('w:utf-8')
|
74
|
+
@io.sync = true
|
75
|
+
@io.print "io data"
|
76
|
+
|
77
|
+
IO.read(@name).should == "io data"
|
78
|
+
end
|
79
|
+
|
80
|
+
it "raises an ArgumentError if the options Hash does not include :mode" do
|
81
|
+
FeatureGuard.stub!(:enabled?).and_return(true)
|
82
|
+
lambda { new_fd @name, { :encoding => "utf-8" } }.should raise_error(ArgumentError)
|
83
|
+
end
|
68
84
|
end
|
69
85
|
|
70
86
|
describe Object, "#new_io" do
|
@@ -96,4 +112,57 @@ describe Object, "#new_io" do
|
|
96
112
|
@io.print "io data"
|
97
113
|
IO.read(@name).should == "io data"
|
98
114
|
end
|
115
|
+
|
116
|
+
it "opens the IO for reading if passed { :mode => 'r' }" do
|
117
|
+
touch(@name) { |f| f.print "io data" }
|
118
|
+
@io = new_io @name, { :mode => "r" }
|
119
|
+
@io.read.should == "io data"
|
120
|
+
lambda { @io.puts "more data" }.should raise_error(IOError)
|
121
|
+
end
|
122
|
+
|
123
|
+
it "opens the IO for writing if passed { :mode => 'w' }" do
|
124
|
+
@io = new_io @name, { :mode => "w" }
|
125
|
+
@io.sync = true
|
126
|
+
|
127
|
+
@io.print "io data"
|
128
|
+
IO.read(@name).should == "io data"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe Object, "#fmode" do
|
133
|
+
it "returns the argument unmodified if :encoding feature is enabled" do
|
134
|
+
FeatureGuard.should_receive(:enabled?).with(:encoding).and_return(true)
|
135
|
+
fmode("rb:binary:utf-8").should == "rb:binary:utf-8"
|
136
|
+
end
|
137
|
+
|
138
|
+
it "returns only the file access mode if :encoding feature is not enabled" do
|
139
|
+
FeatureGuard.should_receive(:enabled?).with(:encoding).and_return(false)
|
140
|
+
fmode("rb:binary:utf-8").should == "rb"
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe Object, "#options_or_mode" do
|
145
|
+
describe "if passed a Hash" do
|
146
|
+
it "returns a mode string if :encoding feature is not enabled" do
|
147
|
+
FeatureGuard.should_receive(:enabled?).with(:encoding).twice.and_return(false)
|
148
|
+
options_or_mode(:mode => "rb:binary").should == "rb"
|
149
|
+
end
|
150
|
+
|
151
|
+
it "returns a Hash if :encoding feature is enabled" do
|
152
|
+
FeatureGuard.should_receive(:enabled?).with(:encoding).and_return(true)
|
153
|
+
options_or_mode(:mode => "rb:utf-8").should == { :mode => "rb:utf-8" }
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
describe "if passed a String" do
|
158
|
+
it "returns only the file access mode if :encoding feature is not enabled" do
|
159
|
+
FeatureGuard.should_receive(:enabled?).with(:encoding).and_return(false)
|
160
|
+
options_or_mode("rb:binary:utf-8").should == "rb"
|
161
|
+
end
|
162
|
+
|
163
|
+
it "returns the argument unmodified if :encoding feature is enabled" do
|
164
|
+
FeatureGuard.should_receive(:enabled?).with(:encoding).and_return(true)
|
165
|
+
options_or_mode("rb:binary:utf-8").should == "rb:binary:utf-8"
|
166
|
+
end
|
167
|
+
end
|
99
168
|
end
|