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.
- 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,107 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
|
+
require 'mspec/expectations/expectations'
|
|
3
|
+
require 'mspec/runner/actions/tally'
|
|
4
|
+
require 'mspec/runner/mspec'
|
|
5
|
+
require 'mspec/runner/state'
|
|
6
|
+
|
|
7
|
+
describe Tally do
|
|
8
|
+
before :each do
|
|
9
|
+
@tally = Tally.new
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "responds to #files! by incrementing the count returned by #files" do
|
|
13
|
+
@tally.files! 3
|
|
14
|
+
@tally.files.should == 3
|
|
15
|
+
@tally.files!
|
|
16
|
+
@tally.files.should == 4
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "responds to #examples! by incrementing the count returned by #examples" do
|
|
20
|
+
@tally.examples! 2
|
|
21
|
+
@tally.examples.should == 2
|
|
22
|
+
@tally.examples! 2
|
|
23
|
+
@tally.examples.should == 4
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "responds to #expectations! by incrementing the count returned by #expectations" do
|
|
27
|
+
@tally.expectations!
|
|
28
|
+
@tally.expectations.should == 1
|
|
29
|
+
@tally.expectations! 3
|
|
30
|
+
@tally.expectations.should == 4
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "responds to #failures! by incrementing the count returned by #failures" do
|
|
34
|
+
@tally.failures! 1
|
|
35
|
+
@tally.failures.should == 1
|
|
36
|
+
@tally.failures!
|
|
37
|
+
@tally.failures.should == 2
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "responds to #errors! by incrementing the count returned by #errors" do
|
|
41
|
+
@tally.errors!
|
|
42
|
+
@tally.errors.should == 1
|
|
43
|
+
@tally.errors! 2
|
|
44
|
+
@tally.errors.should == 3
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "responds to #format by returning a formatted string of counts" do
|
|
48
|
+
@tally.files!
|
|
49
|
+
@tally.examples! 2
|
|
50
|
+
@tally.expectations! 4
|
|
51
|
+
@tally.errors!
|
|
52
|
+
@tally.format.should == "1 file, 2 examples, 4 expectations, 0 failures, 1 error"
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
describe TallyAction do
|
|
57
|
+
before :each do
|
|
58
|
+
@tally = TallyAction.new
|
|
59
|
+
@state = SpecState.new("describe", "it")
|
|
60
|
+
@state.exceptions << ["msg", Exception.new("it broke")]
|
|
61
|
+
@state.exceptions << ["msg", ExpectationNotMetError.new("disappointment")]
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "responds to #counter by returning the Tally object" do
|
|
65
|
+
@tally.counter.should be_kind_of(Tally)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "responds to #load by incrementing the count returned by Tally#files" do
|
|
69
|
+
@tally.load
|
|
70
|
+
@tally.counter.files.should == 1
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "responds to #expectation by incrementing the count returned by Tally#expectations" do
|
|
74
|
+
@tally.expectation @state
|
|
75
|
+
@tally.counter.expectations.should == 1
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it "responds to #after by incrementing counts returned by Tally#examples, #failures, #errors" do
|
|
79
|
+
@tally.after @state
|
|
80
|
+
@tally.counter.examples.should == 1
|
|
81
|
+
@tally.counter.expectations.should == 0
|
|
82
|
+
@tally.counter.failures.should == 1
|
|
83
|
+
@tally.counter.errors.should == 1
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it "responds to #format by returning a readable string of counts" do
|
|
87
|
+
@tally.load
|
|
88
|
+
@tally.after @state
|
|
89
|
+
@tally.expectation @state
|
|
90
|
+
@tally.expectation @state
|
|
91
|
+
@tally.format.should == "1 file, 1 example, 2 expectations, 1 failure, 1 error"
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it "responds to #register by registering itself with MSpec for appropriate actions" do
|
|
95
|
+
MSpec.should_receive(:register).with(:load, @tally)
|
|
96
|
+
MSpec.should_receive(:register).with(:after, @tally)
|
|
97
|
+
MSpec.should_receive(:register).with(:expectation, @tally)
|
|
98
|
+
@tally.register
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it "responds to #unregister by unregistering itself with MSpec for appropriate actions" do
|
|
102
|
+
MSpec.should_receive(:unregister).with(:load, @tally)
|
|
103
|
+
MSpec.should_receive(:unregister).with(:after, @tally)
|
|
104
|
+
MSpec.should_receive(:unregister).with(:expectation, @tally)
|
|
105
|
+
@tally.unregister
|
|
106
|
+
end
|
|
107
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
|
+
require 'mspec/runner/actions/timer'
|
|
3
|
+
require 'mspec/runner/mspec'
|
|
4
|
+
require 'time'
|
|
5
|
+
|
|
6
|
+
describe TimerAction do
|
|
7
|
+
before :each do
|
|
8
|
+
@timer = TimerAction.new
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "responds to #start by recording the current time" do
|
|
12
|
+
Time.should_receive(:now)
|
|
13
|
+
@timer.start
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "responds to #finish by recording the current time" do
|
|
17
|
+
Time.should_receive(:now)
|
|
18
|
+
@timer.finish
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "responds to #elapsed by returning the difference between stop and start" do
|
|
22
|
+
Time.stub!(:now).and_return(Time.parse('10/18/2007 5:43:18'))
|
|
23
|
+
@timer.start
|
|
24
|
+
Time.stub!(:now).and_return(Time.parse('10/18/2007 5:43:51'))
|
|
25
|
+
@timer.finish
|
|
26
|
+
@timer.elapsed.should == 33
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "responds to #format by returning a readable string of elapsed time" do
|
|
30
|
+
Time.stub!(:now).and_return(Time.parse('10/18/2007 5:43:18'))
|
|
31
|
+
@timer.start
|
|
32
|
+
Time.stub!(:now).and_return(Time.parse('10/18/2007 5:43:51'))
|
|
33
|
+
@timer.finish
|
|
34
|
+
@timer.format.should == "Finished in 33.000000 seconds"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "responds to #register by registering itself with MSpec for appropriate actions" do
|
|
38
|
+
MSpec.should_receive(:register).with(:start, @timer)
|
|
39
|
+
MSpec.should_receive(:register).with(:finish, @timer)
|
|
40
|
+
@timer.register
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
|
+
require 'mspec/runner/mspec'
|
|
3
|
+
require 'mspec/runner/filters/match'
|
|
4
|
+
|
|
5
|
+
describe MatchFilter, "#to_regexp" do
|
|
6
|
+
before :each do
|
|
7
|
+
@filter = MatchFilter.new nil
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "converts its arguments to Regexp instances" do
|
|
11
|
+
@filter.to_regexp('a', 'b', 'c').should == [/a/, /b/, /c/]
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe MatchFilter, "#===" do
|
|
16
|
+
before :each do
|
|
17
|
+
@filter = MatchFilter.new nil, 'a', 'b', 'c'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "returns true if the argument matches any of the #initialize strings" do
|
|
21
|
+
@filter.===('aaa').should == true
|
|
22
|
+
@filter.===('bccb').should == true
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "returns false if the argument matches none of the #initialize strings" do
|
|
26
|
+
@filter.===('d').should == false
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe MatchFilter, "#register" do
|
|
31
|
+
it "registers itself with MSpec for the designated action list" do
|
|
32
|
+
filter = MatchFilter.new :include
|
|
33
|
+
MSpec.should_receive(:register).with(:include, filter)
|
|
34
|
+
filter.register
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe MatchFilter, "#unregister" do
|
|
39
|
+
it "unregisters itself with MSpec for the designated action list" do
|
|
40
|
+
filter = MatchFilter.new :exclude
|
|
41
|
+
MSpec.should_receive(:unregister).with(:exclude, filter)
|
|
42
|
+
filter.unregister
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
|
+
require 'mspec/runner/mspec'
|
|
3
|
+
require 'mspec/runner/filters/profile'
|
|
4
|
+
|
|
5
|
+
describe ProfileFilter, "#find" do
|
|
6
|
+
before :each do
|
|
7
|
+
@filter = ProfileFilter.new nil
|
|
8
|
+
File.stub!(:exist?).and_return(false)
|
|
9
|
+
@file = "rails.yaml"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "attempts to locate the file through the expanded path name" do
|
|
13
|
+
File.should_receive(:expand_path).with(@file).and_return(@file)
|
|
14
|
+
File.should_receive(:exist?).with(@file).and_return(true)
|
|
15
|
+
@filter.find(@file).should == @file
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "attemps to locate the file in 'spec/profiles'" do
|
|
19
|
+
path = File.join "spec/profiles", @file
|
|
20
|
+
File.should_receive(:exist?).with(path).and_return(true)
|
|
21
|
+
@filter.find(@file).should == path
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "attemps to locate the file in 'spec'" do
|
|
25
|
+
path = File.join "spec", @file
|
|
26
|
+
File.should_receive(:exist?).with(path).and_return(true)
|
|
27
|
+
@filter.find(@file).should == path
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "attemps to locate the file in 'profiles'" do
|
|
31
|
+
path = File.join "profiles", @file
|
|
32
|
+
File.should_receive(:exist?).with(path).and_return(true)
|
|
33
|
+
@filter.find(@file).should == path
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "attemps to locate the file in '.'" do
|
|
37
|
+
path = File.join ".", @file
|
|
38
|
+
File.should_receive(:exist?).with(path).and_return(true)
|
|
39
|
+
@filter.find(@file).should == path
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe ProfileFilter, "#parse" do
|
|
44
|
+
before :each do
|
|
45
|
+
@filter = ProfileFilter.new nil
|
|
46
|
+
@file = File.open(File.dirname(__FILE__) + "/b.yaml", "r")
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
after :each do
|
|
50
|
+
@file.close
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "creates a Hash of the contents of the YAML file" do
|
|
54
|
+
@filter.parse(@file).should == {
|
|
55
|
+
"B." => ["b", "bb"],
|
|
56
|
+
"B::C#" => ["b!", "b=", "b?", "-", "[]", "[]="]
|
|
57
|
+
}
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
describe ProfileFilter, "#load" do
|
|
62
|
+
before :each do
|
|
63
|
+
@filter = ProfileFilter.new nil
|
|
64
|
+
@files = [
|
|
65
|
+
File.dirname(__FILE__) + "/a.yaml",
|
|
66
|
+
File.dirname(__FILE__) + "/b.yaml"
|
|
67
|
+
]
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "generates a composite hash from multiple YAML files" do
|
|
71
|
+
@filter.load(*@files).should == {
|
|
72
|
+
"A#" => ["a", "aa"],
|
|
73
|
+
"B." => ["b", "bb"],
|
|
74
|
+
"B::C#" => ["b!", "b=", "b?", "-", "[]", "[]="]
|
|
75
|
+
}
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
describe ProfileFilter, "#===" do
|
|
80
|
+
before :each do
|
|
81
|
+
@filter = ProfileFilter.new nil
|
|
82
|
+
@filter.stub!(:load).and_return({ "A#" => ["[]=", "a", "a!", "a?", "aa="]})
|
|
83
|
+
@filter.send :initialize, nil
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it "returns true if the spec description is for a method in the profile" do
|
|
87
|
+
@filter.===("The A#[]= method").should == true
|
|
88
|
+
@filter.===("A#a returns").should == true
|
|
89
|
+
@filter.===("A#a! replaces").should == true
|
|
90
|
+
@filter.===("A#a? returns").should == true
|
|
91
|
+
@filter.===("A#aa= raises").should == true
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it "returns false if the spec description is for a method not in the profile" do
|
|
95
|
+
@filter.===("The A#[] method").should == false
|
|
96
|
+
@filter.===("B#a returns").should == false
|
|
97
|
+
@filter.===("A.a! replaces").should == false
|
|
98
|
+
@filter.===("AA#a? returns").should == false
|
|
99
|
+
@filter.===("A#aa raises").should == false
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
describe ProfileFilter, "#register" do
|
|
104
|
+
it "registers itself with MSpec for the designated action list" do
|
|
105
|
+
filter = ProfileFilter.new :include
|
|
106
|
+
MSpec.should_receive(:register).with(:include, filter)
|
|
107
|
+
filter.register
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
describe ProfileFilter, "#unregister" do
|
|
112
|
+
it "unregisters itself with MSpec for the designated action list" do
|
|
113
|
+
filter = ProfileFilter.new :exclude
|
|
114
|
+
MSpec.should_receive(:unregister).with(:exclude, filter)
|
|
115
|
+
filter.unregister
|
|
116
|
+
end
|
|
117
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
|
+
require 'mspec/runner/mspec'
|
|
3
|
+
require 'mspec/runner/filters/regexp'
|
|
4
|
+
|
|
5
|
+
describe RegexpFilter, "#to_regexp" do
|
|
6
|
+
before :each do
|
|
7
|
+
@filter = RegexpFilter.new nil
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "converts its arguments to Regexp instances" do
|
|
11
|
+
@filter.to_regexp('a(b|c)', 'b[^ab]', 'cc?').should == [/a(b|c)/, /b[^ab]/, /cc?/]
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
|
+
require 'mspec/runner/mspec'
|
|
3
|
+
require 'mspec/runner/filters/match'
|
|
4
|
+
require 'mspec/runner/filters/tag'
|
|
5
|
+
|
|
6
|
+
describe TagFilter, "#load" do
|
|
7
|
+
before :each do
|
|
8
|
+
@match = mock("match filter", :null_object => true)
|
|
9
|
+
@filter = TagFilter.new :include, "tag", "key"
|
|
10
|
+
@tag = SpecTag.new "tag(comment):description"
|
|
11
|
+
MSpec.stub!(:read_tags).and_return([@tag])
|
|
12
|
+
MSpec.stub!(:register)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "loads tags from the tag file" do
|
|
16
|
+
MSpec.should_receive(:read_tags).with("tag", "key").and_return([])
|
|
17
|
+
@filter.load
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "creates a MatchFilter from the descriptions matching the tags" do
|
|
21
|
+
MatchFilter.should_receive(:new).with(:include, "description").and_return(@match)
|
|
22
|
+
@filter.load
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "creates an empty MatchFilter if no tags were found" do
|
|
26
|
+
MSpec.should_receive(:read_tags).and_return([])
|
|
27
|
+
MatchFilter.should_receive(:new).with(:include).and_return(@match)
|
|
28
|
+
@filter.load
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "registers the MatchFilter if there were tags found in the tag file" do
|
|
32
|
+
@match.should_receive(:register)
|
|
33
|
+
MatchFilter.should_receive(:new).with(:include, "description").and_return(@match)
|
|
34
|
+
@filter.load
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "registers the empty MatchFilter if no tags were found" do
|
|
38
|
+
@match.should_receive(:register)
|
|
39
|
+
MSpec.should_receive(:read_tags).and_return([])
|
|
40
|
+
MatchFilter.should_receive(:new).with(:include).and_return(@match)
|
|
41
|
+
@filter.load
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe TagFilter, "#unload" do
|
|
46
|
+
before :each do
|
|
47
|
+
@filter = TagFilter.new :include, "tag", "key"
|
|
48
|
+
@tag = SpecTag.new "tag(comment):description"
|
|
49
|
+
MSpec.stub!(:read_tags).and_return([@tag])
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "unregisters the MatchFilter if one was registered" do
|
|
53
|
+
match = mock("match filter", :null_object => true)
|
|
54
|
+
match.should_receive(:unregister)
|
|
55
|
+
MatchFilter.stub!(:new).with(:include, "description").and_return(match)
|
|
56
|
+
@filter.load
|
|
57
|
+
@filter.unload
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
describe TagFilter, "#register" do
|
|
62
|
+
it "registers itself with MSpec for the :load, :unload actions" do
|
|
63
|
+
filter = TagFilter.new(nil)
|
|
64
|
+
MSpec.should_receive(:register).with(:load, filter)
|
|
65
|
+
MSpec.should_receive(:register).with(:unload, filter)
|
|
66
|
+
filter.register
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe TagFilter, "#unregister" do
|
|
71
|
+
it "unregisters itself with MSpec for the :load, :unload actions" do
|
|
72
|
+
filter = TagFilter.new(nil)
|
|
73
|
+
MSpec.should_receive(:unregister).with(:load, filter)
|
|
74
|
+
MSpec.should_receive(:unregister).with(:unload, filter)
|
|
75
|
+
filter.unregister
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
|
+
require 'mspec/runner/formatters/dotted'
|
|
3
|
+
require 'mspec/runner/mspec'
|
|
4
|
+
require 'mspec/runner/state'
|
|
5
|
+
|
|
6
|
+
describe DottedFormatter, "#initialize" do
|
|
7
|
+
it "permits zero arguments" do
|
|
8
|
+
DottedFormatter.new
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "accepts one argument" do
|
|
12
|
+
DottedFormatter.new nil
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe DottedFormatter, "#register" do
|
|
17
|
+
before :each do
|
|
18
|
+
@formatter = DottedFormatter.new
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "registers self with MSpec for appropriate actions" do
|
|
22
|
+
MSpec.stub!(:register)
|
|
23
|
+
MSpec.should_receive(:register).with(:after, @formatter)
|
|
24
|
+
MSpec.should_receive(:register).with(:finish, @formatter)
|
|
25
|
+
@formatter.register
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "creates TimerAction and TallyAction" do
|
|
29
|
+
timer = mock("timer")
|
|
30
|
+
tally = mock("tally")
|
|
31
|
+
timer.should_receive(:register)
|
|
32
|
+
tally.should_receive(:register)
|
|
33
|
+
tally.should_receive(:counter)
|
|
34
|
+
TimerAction.should_receive(:new).and_return(timer)
|
|
35
|
+
TallyAction.should_receive(:new).and_return(tally)
|
|
36
|
+
@formatter.register
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe DottedFormatter, "#print" do
|
|
41
|
+
after :each do
|
|
42
|
+
$stdout = STDOUT
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "writes to $stdout by default" do
|
|
46
|
+
$stdout = IOStub.new
|
|
47
|
+
formatter = DottedFormatter.new
|
|
48
|
+
formatter.print "begonias"
|
|
49
|
+
$stdout.should == "begonias"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "writes to the file specified when the formatter was created" do
|
|
53
|
+
out = IOStub.new
|
|
54
|
+
File.should_receive(:open).with("some/file", "w").and_return(out)
|
|
55
|
+
formatter = DottedFormatter.new "some/file"
|
|
56
|
+
formatter.print "begonias"
|
|
57
|
+
out.should == "begonias"
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
describe DottedFormatter, "#message" do
|
|
62
|
+
before :each do
|
|
63
|
+
@formatter = DottedFormatter.new
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it "returns <No message> if the exception message is empty" do
|
|
67
|
+
exc = Exception.new ""
|
|
68
|
+
@formatter.message(exc).should == "<No message>"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "returns the message without exception class when the exception is ExpectationNotMetError" do
|
|
72
|
+
exc = Exception.new "message"
|
|
73
|
+
@formatter.message(exc).should == "Exception: message"
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "returns the message with exception class when the exception is not ExpectationNotMetError" do
|
|
77
|
+
exc = ExpectationNotMetError.new "message"
|
|
78
|
+
@formatter.message(exc).should == "message"
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
describe DottedFormatter, "#after" do
|
|
83
|
+
before :each do
|
|
84
|
+
$stdout = @out = IOStub.new
|
|
85
|
+
@formatter = DottedFormatter.new
|
|
86
|
+
@state = SpecState.new("describe", "it")
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
after :each do
|
|
90
|
+
$stdout = STDOUT
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it "prints a '.' if there was no exception raised" do
|
|
94
|
+
@formatter.after(@state)
|
|
95
|
+
@out.should == "."
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it "prints an 'F' if there was an expectation failure" do
|
|
99
|
+
@state.exceptions << ["msg", ExpectationNotMetError.new("failed")]
|
|
100
|
+
@formatter.after(@state)
|
|
101
|
+
@out.should == "F"
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it "prints an 'E' if there was an exception other than expectation failure" do
|
|
105
|
+
@state.exceptions << ["msg", MSpecExampleError.new("boom!")]
|
|
106
|
+
@formatter.after(@state)
|
|
107
|
+
@out.should == "E"
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it "prints an 'E' if there are mixed exceptions and exepctation failures" do
|
|
111
|
+
@state.exceptions << ["msg", ExpectationNotMetError.new("failed")]
|
|
112
|
+
@state.exceptions << ["msg", MSpecExampleError.new("boom!")]
|
|
113
|
+
@formatter.after(@state)
|
|
114
|
+
@out.should == "E"
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
describe DottedFormatter, "#finish" do
|
|
119
|
+
before :each do
|
|
120
|
+
@tally = mock("tally", :null_object => true)
|
|
121
|
+
TallyAction.stub!(:new).and_return(@tally)
|
|
122
|
+
@timer = mock("timer", :null_object => true)
|
|
123
|
+
TimerAction.stub!(:new).and_return(@timer)
|
|
124
|
+
|
|
125
|
+
$stdout = @out = IOStub.new
|
|
126
|
+
@state = SpecState.new("describe", "it")
|
|
127
|
+
MSpec.stub!(:register)
|
|
128
|
+
@formatter = DottedFormatter.new
|
|
129
|
+
@formatter.register
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
after :each do
|
|
133
|
+
$stdout = STDOUT
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
it "prints a failure message for an exception" do
|
|
137
|
+
@state.exceptions << ["msg", MSpecExampleError.new("broken")]
|
|
138
|
+
@formatter.after @state
|
|
139
|
+
@formatter.finish
|
|
140
|
+
@out.should =~ /^1\)\ndescribe it ERROR$/
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
it "prints a backtrace for an exception" do
|
|
144
|
+
@formatter.stub!(:backtrace).and_return("path/to/some/file.rb:35:in method")
|
|
145
|
+
@state.exceptions << ["msg", MSpecExampleError.new("broken")]
|
|
146
|
+
@formatter.after @state
|
|
147
|
+
@formatter.finish
|
|
148
|
+
@out.should =~ %r[path/to/some/file.rb:35:in method$]
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
it "prints a summary of elapsed time" do
|
|
152
|
+
@timer.should_receive(:format).and_return("Finished in 2.0 seconds")
|
|
153
|
+
@formatter.finish
|
|
154
|
+
@out.should =~ /^Finished in 2.0 seconds$/
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
it "prints a tally of counts" do
|
|
158
|
+
@tally.should_receive(:format).and_return("1 example, 0 failures")
|
|
159
|
+
@formatter.finish
|
|
160
|
+
@out.should =~ /^1 example, 0 failures$/
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
it "prints errors, backtraces, elapsed time, and tallies" do
|
|
164
|
+
@state.exceptions << ["msg", MSpecExampleError.new("broken")]
|
|
165
|
+
@formatter.stub!(:backtrace).and_return("path/to/some/file.rb:35:in method")
|
|
166
|
+
@timer.should_receive(:format).and_return("Finished in 2.0 seconds")
|
|
167
|
+
@tally.should_receive(:format).and_return("1 example, 0 failures")
|
|
168
|
+
@formatter.after @state
|
|
169
|
+
@formatter.finish
|
|
170
|
+
@out.should ==
|
|
171
|
+
%[E
|
|
172
|
+
|
|
173
|
+
1)
|
|
174
|
+
describe it ERROR
|
|
175
|
+
MSpecExampleError occurred during: msg
|
|
176
|
+
MSpecExampleError: broken
|
|
177
|
+
path/to/some/file.rb:35:in method
|
|
178
|
+
|
|
179
|
+
Finished in 2.0 seconds
|
|
180
|
+
|
|
181
|
+
1 example, 0 failures
|
|
182
|
+
]
|
|
183
|
+
end
|
|
184
|
+
end
|