mspec 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +9 -9
- data/lib/mspec.rb +5 -0
- data/lib/mspec/commands/mspec-ci.rb +1 -2
- data/lib/mspec/commands/mspec-run.rb +1 -2
- data/lib/mspec/commands/mspec-tag.rb +1 -2
- data/lib/mspec/helpers/const_lookup.rb +5 -1
- data/lib/mspec/matchers.rb +1 -0
- data/lib/mspec/matchers/match_yaml.rb +47 -0
- data/lib/mspec/mocks/mock.rb +56 -30
- data/lib/mspec/mocks/object.rb +3 -11
- data/lib/mspec/mocks/proxy.rb +24 -3
- data/lib/mspec/runner/mspec.rb +28 -15
- data/lib/mspec/utils/options.rb +0 -7
- data/lib/mspec/utils/script.rb +15 -5
- data/lib/mspec/version.rb +1 -1
- data/spec/commands/mspec_ci_spec.rb +3 -8
- data/spec/commands/mspec_run_spec.rb +3 -8
- data/spec/commands/mspec_tag_spec.rb +3 -8
- data/spec/helpers/const_lookup_spec.rb +29 -0
- data/spec/matchers/base_spec.rb +88 -52
- data/spec/matchers/eql_spec.rb +2 -2
- data/spec/matchers/equal_spec.rb +2 -2
- data/spec/matchers/equal_utf16_spec.rb +2 -2
- data/spec/matchers/match_yaml_spec.rb +39 -0
- data/spec/mocks/mock_spec.rb +191 -23
- data/spec/mocks/proxy_spec.rb +135 -28
- data/spec/runner/formatters/spinner_spec.rb +11 -4
- data/spec/runner/mspec_spec.rb +22 -23
- data/spec/spec_helper.rb +1 -6
- data/spec/utils/options_spec.rb +0 -21
- data/spec/utils/script_spec.rb +36 -11
- metadata +4 -2
@@ -70,9 +70,16 @@ describe SpinnerFormatter, "#after" do
|
|
70
70
|
@formatter.load
|
71
71
|
@formatter.after @state
|
72
72
|
@formatter.after @state
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
|
74
|
+
if ENV["TERM"] != "dumb"
|
75
|
+
$stdout.should == "\r[/ | ======== 20% | 00:00:00] " \
|
76
|
+
"\e[0;32m 0F \e[0;32m 0E\e[0m" \
|
77
|
+
"\r[- | ======== 20% | 00:00:00] " \
|
78
|
+
"\e[0;32m 0F \e[0;32m 0E\e[0m"
|
79
|
+
else
|
80
|
+
$stdout.should == "\r[/ | ======== 20% | 00:00:00] " \
|
81
|
+
" 0F 0E\r[- | ======== 20% " \
|
82
|
+
" | 00:00:00] 0F 0E"
|
83
|
+
end
|
77
84
|
end
|
78
85
|
end
|
data/spec/runner/mspec_spec.rb
CHANGED
@@ -17,10 +17,10 @@ describe MSpec, ".register_mode" do
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
describe MSpec, ".
|
21
|
-
it "records the
|
22
|
-
MSpec.
|
23
|
-
MSpec.retrieve(:
|
20
|
+
describe MSpec, ".register_tags_patterns" do
|
21
|
+
it "records the patterns for generating a tag file from a spec file" do
|
22
|
+
MSpec.register_tags_patterns [[/spec\/ruby/, "spec/tags"], [/frozen/, "ruby"]]
|
23
|
+
MSpec.retrieve(:tags_patterns).should == [[/spec\/ruby/, "spec/tags"], [/frozen/, "ruby"]]
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -288,34 +288,33 @@ describe MSpec, ".shuffle" do
|
|
288
288
|
end
|
289
289
|
end
|
290
290
|
|
291
|
-
describe MSpec, ".
|
291
|
+
describe MSpec, ".tags_file" do
|
292
292
|
before :each do
|
293
|
-
MSpec.store :
|
294
|
-
|
295
|
-
|
296
|
-
it "returns 'spec/tags' if no tags path has been registered" do
|
297
|
-
MSpec.tags_path.should == "spec/tags"
|
293
|
+
MSpec.store :file, "path/to/spec/something/some_spec.rb"
|
294
|
+
MSpec.store :tags_patterns, nil
|
298
295
|
end
|
299
296
|
|
300
|
-
it "returns the
|
301
|
-
MSpec.
|
302
|
-
MSpec.tags_path.should == "/path/to/tags"
|
297
|
+
it "returns the default tags file for the current spec file" do
|
298
|
+
MSpec.tags_file.should == "path/to/spec/tags/something/some_tags.txt"
|
303
299
|
end
|
304
|
-
end
|
305
300
|
|
306
|
-
|
307
|
-
|
308
|
-
MSpec.
|
309
|
-
MSpec.store :tags_path, nil
|
301
|
+
it "returns the tags file for the current spec file with custom tags_patterns" do
|
302
|
+
MSpec.register_tags_patterns [[/^(.*)\/spec/, '\1/tags'], [/_spec.rb/, "_tags.txt"]]
|
303
|
+
MSpec.tags_file.should == "path/to/tags/something/some_tags.txt"
|
310
304
|
end
|
311
305
|
|
312
|
-
it "
|
313
|
-
MSpec.
|
306
|
+
it "performs multiple substitutions" do
|
307
|
+
MSpec.register_tags_patterns [
|
308
|
+
[%r(/spec/something/), "/spec/other/"],
|
309
|
+
[%r(/spec/), "/spec/tags/"],
|
310
|
+
[/_spec.rb/, "_tags.txt"]
|
311
|
+
]
|
312
|
+
MSpec.tags_file.should == "path/to/spec/tags/other/some_tags.txt"
|
314
313
|
end
|
315
314
|
|
316
|
-
it "
|
317
|
-
MSpec.
|
318
|
-
MSpec.tags_file.should == "
|
315
|
+
it "handles cases where no substitution is performed" do
|
316
|
+
MSpec.register_tags_patterns [[/nothing/, "something"]]
|
317
|
+
MSpec.tags_file.should == "path/to/spec/something/some_spec.rb"
|
319
318
|
end
|
320
319
|
end
|
321
320
|
|
data/spec/spec_helper.rb
CHANGED
@@ -4,18 +4,13 @@ bin_path = File.expand_path(dir_path + '/..')
|
|
4
4
|
$:.unshift lib_path unless $:.include? lib_path
|
5
5
|
$:.unshift bin_path unless $:.include? bin_path
|
6
6
|
|
7
|
+
require 'pp'
|
7
8
|
require 'mspec/helpers/io'
|
8
9
|
require 'mspec/helpers/scratch'
|
9
10
|
|
10
11
|
# Remove this when MRI has intelligent warnings
|
11
12
|
$VERBOSE = nil unless $VERBOSE
|
12
13
|
|
13
|
-
module Kernel
|
14
|
-
def pretty_inspect
|
15
|
-
inspect
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
14
|
class MOSConfig < Hash
|
20
15
|
def initialize
|
21
16
|
self[:includes] = []
|
data/spec/utils/options_spec.rb
CHANGED
@@ -187,27 +187,6 @@ describe "The -r, --require LIBRARY option" do
|
|
187
187
|
end
|
188
188
|
end
|
189
189
|
|
190
|
-
describe "The -X, --tags-dir DIR option" do
|
191
|
-
before :each do
|
192
|
-
@options, @config = new_option
|
193
|
-
@options.add_tags_dir
|
194
|
-
end
|
195
|
-
|
196
|
-
it "is enabled with #add_tags_dir" do
|
197
|
-
@options.should_receive(:on).with("-X", "--tags-dir DIR",
|
198
|
-
String, an_instance_of(String))
|
199
|
-
@options.add_tags_dir
|
200
|
-
end
|
201
|
-
|
202
|
-
it "sets the tags directory to DIR" do
|
203
|
-
["-X", "--tags-dir"].each do |opt|
|
204
|
-
@config[:tags_dir] = nil
|
205
|
-
@options.parse [opt, "tags"]
|
206
|
-
@config[:tags_dir].should == "tags"
|
207
|
-
end
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
190
|
describe "The -f, --format FORMAT option" do
|
212
191
|
before :each do
|
213
192
|
@options, @config = new_option
|
data/spec/utils/script_spec.rb
CHANGED
@@ -80,17 +80,18 @@ describe MSpecScript, "#initialize" do
|
|
80
80
|
end
|
81
81
|
|
82
82
|
it "sets the default config values" do
|
83
|
-
@config[:tags_dir].should
|
84
|
-
@config[:formatter].should
|
85
|
-
@config[:includes].should
|
86
|
-
@config[:excludes].should
|
87
|
-
@config[:patterns].should
|
88
|
-
@config[:xpatterns].should
|
89
|
-
@config[:tags].should
|
90
|
-
@config[:xtags].should
|
91
|
-
@config[:atags].should
|
92
|
-
@config[:astrings].should
|
93
|
-
@config[:abort].should
|
83
|
+
@config[:tags_dir].should == 'spec/tags'
|
84
|
+
@config[:formatter].should == DottedFormatter
|
85
|
+
@config[:includes].should == []
|
86
|
+
@config[:excludes].should == []
|
87
|
+
@config[:patterns].should == []
|
88
|
+
@config[:xpatterns].should == []
|
89
|
+
@config[:tags].should == []
|
90
|
+
@config[:xtags].should == []
|
91
|
+
@config[:atags].should == []
|
92
|
+
@config[:astrings].should == []
|
93
|
+
@config[:abort].should == true
|
94
|
+
@config[:config_ext].should == '.mspec'
|
94
95
|
end
|
95
96
|
end
|
96
97
|
|
@@ -99,6 +100,7 @@ describe MSpecScript, "#load" do
|
|
99
100
|
File.stub!(:exist?).and_return(false)
|
100
101
|
@script = MSpecScript.new
|
101
102
|
@file = "default.mspec"
|
103
|
+
@base = "default"
|
102
104
|
end
|
103
105
|
|
104
106
|
it "attempts to locate the file through the expanded path name" do
|
@@ -108,6 +110,15 @@ describe MSpecScript, "#load" do
|
|
108
110
|
@script.load(@file).should == :loaded
|
109
111
|
end
|
110
112
|
|
113
|
+
it "appends config[:config_ext] to the name and attempts to locate the file through the expanded path name" do
|
114
|
+
File.should_receive(:expand_path).with(@base).and_return(@base)
|
115
|
+
File.should_receive(:expand_path).with(@file).and_return(@file)
|
116
|
+
File.should_receive(:exist?).with(@base).and_return(false)
|
117
|
+
File.should_receive(:exist?).with(@file).and_return(true)
|
118
|
+
Kernel.should_receive(:load).with(@file).and_return(:loaded)
|
119
|
+
@script.load(@base).should == :loaded
|
120
|
+
end
|
121
|
+
|
111
122
|
it "attemps to locate the file in '.'" do
|
112
123
|
path = File.join ".", @file
|
113
124
|
File.should_receive(:exist?).with(path).and_return(true)
|
@@ -115,12 +126,26 @@ describe MSpecScript, "#load" do
|
|
115
126
|
@script.load(@file).should == :loaded
|
116
127
|
end
|
117
128
|
|
129
|
+
it "appends config[:config_ext] to the name and attempts to locate the file in '.'" do
|
130
|
+
path = File.join ".", @file
|
131
|
+
File.should_receive(:exist?).with(path).and_return(true)
|
132
|
+
Kernel.should_receive(:load).with(path).and_return(:loaded)
|
133
|
+
@script.load(@base).should == :loaded
|
134
|
+
end
|
135
|
+
|
118
136
|
it "attemps to locate the file in 'spec'" do
|
119
137
|
path = File.join "spec", @file
|
120
138
|
File.should_receive(:exist?).with(path).and_return(true)
|
121
139
|
Kernel.should_receive(:load).with(path).and_return(:loaded)
|
122
140
|
@script.load(@file).should == :loaded
|
123
141
|
end
|
142
|
+
|
143
|
+
it "appends config[:config_ext] to the name and attempts to locate the file in 'spec'" do
|
144
|
+
path = File.join "spec", @file
|
145
|
+
File.should_receive(:exist?).with(path).and_return(true)
|
146
|
+
Kernel.should_receive(:load).with(path).and_return(:loaded)
|
147
|
+
@script.load(@base).should == :loaded
|
148
|
+
end
|
124
149
|
end
|
125
150
|
|
126
151
|
describe MSpecScript, "#register" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Ford
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- lib/mspec/matchers/equal.rb
|
70
70
|
- lib/mspec/matchers/equal_utf16.rb
|
71
71
|
- lib/mspec/matchers/include.rb
|
72
|
+
- lib/mspec/matchers/match_yaml.rb
|
72
73
|
- lib/mspec/matchers/output.rb
|
73
74
|
- lib/mspec/matchers/output_to_fd.rb
|
74
75
|
- lib/mspec/matchers/raise_error.rb
|
@@ -150,6 +151,7 @@ files:
|
|
150
151
|
- spec/matchers/equal_spec.rb
|
151
152
|
- spec/matchers/equal_utf16_spec.rb
|
152
153
|
- spec/matchers/include_spec.rb
|
154
|
+
- spec/matchers/match_yaml_spec.rb
|
153
155
|
- spec/matchers/output_spec.rb
|
154
156
|
- spec/matchers/output_to_fd_spec.rb
|
155
157
|
- spec/matchers/raise_error_spec.rb
|
@@ -212,6 +214,6 @@ rubyforge_project: http://rubyforge.org/projects/mspec
|
|
212
214
|
rubygems_version: 1.0.1
|
213
215
|
signing_key:
|
214
216
|
specification_version: 2
|
215
|
-
summary: MSpec is a specialized framework that is syntax-compatible
|
217
|
+
summary: MSpec is a specialized framework that is syntax-compatible with RSpec for basic things like describe, it blocks and before, after actions. MSpec contains additional features that assist in writing the RubySpecs used by multiple Ruby implementations. Also, MSpec attempts to use the simplest Ruby language features so that beginning Ruby implementations can run it.
|
216
218
|
test_files: []
|
217
219
|
|