rspec 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +8 -0
- data/Rakefile +1 -1
- data/examples/pure/shared_example_group_example.rb +28 -13
- data/lib/spec/example/example_group_methods.rb +9 -3
- data/lib/spec/extensions/main.rb +51 -3
- data/lib/spec/runner.rb +9 -9
- data/lib/spec/runner/formatter/specdoc_formatter.rb +1 -5
- data/lib/spec/version.rb +2 -2
- data/spec/spec/example/configuration_spec.rb +236 -244
- data/spec/spec/example/example_group_methods_spec.rb +17 -2
- data/spec/spec/extensions/main_spec.rb +28 -2
- data/spec/spec/runner/drb_command_line_spec.rb +3 -3
- metadata +3 -3
data/CHANGES
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== Version 1.1.1
|
2
|
+
|
3
|
+
Bug fix release.
|
4
|
+
|
5
|
+
* Fix regression in 1.1.0 that caused transactions to not get rolled back between examples.
|
6
|
+
* Applied patch from Bob Cotton to reintroduce ExampleGroup.description_options. Closes LH[#186]
|
7
|
+
|
1
8
|
== Version 1.1.0
|
2
9
|
|
3
10
|
The "tell me a story and go nest yourself" release.
|
@@ -39,6 +46,7 @@ rspec_on_rails users - don't forget to run script/generate rspec
|
|
39
46
|
* Applied LH[#134] Only load spec inside spec_helper.rb (Patch from Mark Van Holstyn)
|
40
47
|
* RSpec now bails immediately if there are examples with identical names.
|
41
48
|
* Applied LH[#132] Plain Text stories should support Given and Given: (Patch from Jarkko Laine)
|
49
|
+
* Applied patch from Pat Maddox: Story Mediator - the glue that binds the plain text story parser with the rest of the system
|
42
50
|
* Applied LH[#16] Have SimpleMatchers expose their description for specdocs (Patch from Bryan Helmkamp)
|
43
51
|
* Stories now support --colour
|
44
52
|
* Changed the DSL modules to Example (i.e. Spec::Example instead of Spec::DSL)
|
data/Rakefile
CHANGED
@@ -126,7 +126,7 @@ task :clobber do
|
|
126
126
|
core.clobber
|
127
127
|
end
|
128
128
|
|
129
|
-
task :release => [:clobber, :verify_committed, :verify_user, :spec, :publish_packages, :tag, :
|
129
|
+
task :release => [:clobber, :verify_committed, :verify_user, :spec, :publish_packages, :tag, :publish_news]
|
130
130
|
|
131
131
|
desc "Verifies that there is no uncommitted code"
|
132
132
|
task :verify_committed do
|
@@ -19,9 +19,9 @@ module SharedExampleGroupExample
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
# A SharedExampleGroup is
|
23
|
-
#
|
24
|
-
|
22
|
+
# A SharedExampleGroup is an example group that doesn't get run.
|
23
|
+
# You can create one like this:
|
24
|
+
share_examples_for "most things" do
|
25
25
|
def helper_method
|
26
26
|
"helper method"
|
27
27
|
end
|
@@ -30,17 +30,24 @@ module SharedExampleGroupExample
|
|
30
30
|
@thing.what_things_do.should == "stuff"
|
31
31
|
end
|
32
32
|
end
|
33
|
-
|
34
|
-
# TODO - it would be nice to be able to say this instead of the above:
|
35
|
-
|
36
|
-
# class AllThings < Spec::SharedExampleGroup
|
37
|
-
# ...
|
38
|
-
# end
|
39
33
|
|
34
|
+
# A SharedExampleGroup is also module. If you create one like this
|
35
|
+
# it gets assigned to the constant AllThings
|
36
|
+
share_as :MostThings do
|
37
|
+
def helper_method
|
38
|
+
"helper method"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should do what things do" do
|
42
|
+
@thing.what_things_do.should == "stuff"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
40
46
|
describe OneThing do
|
41
|
-
#
|
47
|
+
# Now you can include the shared example group like this, which
|
42
48
|
# feels more like what you might say ...
|
43
|
-
it_should_behave_like "
|
49
|
+
it_should_behave_like "most things"
|
50
|
+
|
44
51
|
before(:each) { @thing = OneThing.new }
|
45
52
|
|
46
53
|
it "should have access to helper methods defined in the shared example group" do
|
@@ -51,16 +58,24 @@ module SharedExampleGroupExample
|
|
51
58
|
describe AnotherThing do
|
52
59
|
# ... or you can include the example group like this, which
|
53
60
|
# feels more like the programming language we love.
|
54
|
-
it_should_behave_like
|
61
|
+
it_should_behave_like MostThings
|
55
62
|
|
56
63
|
before(:each) { @thing = AnotherThing.new }
|
64
|
+
|
65
|
+
it "should have access to helper methods defined in the shared example group" do
|
66
|
+
helper_method.should == "helper method"
|
67
|
+
end
|
57
68
|
end
|
58
69
|
|
59
70
|
describe YetAnotherThing do
|
60
71
|
# ... or you can include the example group like this, which
|
61
72
|
# feels more like the programming language we love.
|
62
|
-
include
|
73
|
+
include MostThings
|
63
74
|
|
64
75
|
before(:each) { @thing = AnotherThing.new }
|
76
|
+
|
77
|
+
it "should have access to helper methods defined in the shared example group" do
|
78
|
+
helper_method.should == "helper method"
|
79
|
+
end
|
65
80
|
end
|
66
81
|
end
|
@@ -11,7 +11,7 @@ module Spec
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
attr_reader :description_text, :description_args, :spec_path
|
14
|
+
attr_reader :description_text, :description_args, :description_options, :spec_path
|
15
15
|
|
16
16
|
def inherited(klass)
|
17
17
|
super
|
@@ -122,7 +122,12 @@ module Spec
|
|
122
122
|
end
|
123
123
|
|
124
124
|
def description
|
125
|
-
ExampleGroupMethods.description_text(*description_parts)
|
125
|
+
result = ExampleGroupMethods.description_text(*description_parts)
|
126
|
+
if result.nil? || result == ""
|
127
|
+
return to_s
|
128
|
+
else
|
129
|
+
result
|
130
|
+
end
|
126
131
|
end
|
127
132
|
|
128
133
|
def described_type
|
@@ -140,6 +145,7 @@ module Spec
|
|
140
145
|
def set_description(*args)
|
141
146
|
args, options = args_and_options(*args)
|
142
147
|
@description_args = args
|
148
|
+
@description_options = options
|
143
149
|
@description_text = ExampleGroupMethods.description_text(*args)
|
144
150
|
@spec_path = File.expand_path(options[:spec_path]) if options[:spec_path]
|
145
151
|
if described_type.class == Module
|
@@ -409,4 +415,4 @@ module Spec
|
|
409
415
|
end
|
410
416
|
|
411
417
|
end
|
412
|
-
end
|
418
|
+
end
|
data/lib/spec/extensions/main.rb
CHANGED
@@ -2,7 +2,7 @@ module Spec
|
|
2
2
|
module Extensions
|
3
3
|
module Main
|
4
4
|
# Creates and returns a class that includes the ExampleGroupMethods
|
5
|
-
# module.
|
5
|
+
# module. Which ExampleGroup type is created depends on the directory of the file
|
6
6
|
# calling this method. For example, Spec::Rails will use different
|
7
7
|
# classes for specs living in <tt>spec/models</tt>,
|
8
8
|
# <tt>spec/helpers</tt>, <tt>spec/views</tt> and
|
@@ -28,10 +28,58 @@ module Spec
|
|
28
28
|
end
|
29
29
|
alias :context :describe
|
30
30
|
|
31
|
-
#
|
32
|
-
|
31
|
+
# Creates an example group that can be shared by other example groups
|
32
|
+
#
|
33
|
+
# == Examples
|
34
|
+
#
|
35
|
+
# share_examples_for "All Editions" do
|
36
|
+
# it "all editions behaviour" ...
|
37
|
+
# end
|
38
|
+
#
|
39
|
+
# describe SmallEdition do
|
40
|
+
# it_should_behave_like "All Editions"
|
41
|
+
#
|
42
|
+
# it "should do small edition stuff" do
|
43
|
+
# ...
|
44
|
+
# end
|
45
|
+
# end
|
46
|
+
def share_examples_for(name, &block)
|
33
47
|
describe(name, :shared => true, &block)
|
34
48
|
end
|
49
|
+
|
50
|
+
alias :shared_examples_for :share_examples_for
|
51
|
+
|
52
|
+
# Creates a Shared Example Group and assigns it to a constant
|
53
|
+
#
|
54
|
+
# share_as :AllEditions do
|
55
|
+
# it "should do all editions stuff" ...
|
56
|
+
# end
|
57
|
+
#
|
58
|
+
# describe SmallEdition do
|
59
|
+
# it_should_behave_like AllEditions
|
60
|
+
#
|
61
|
+
# it "should do small edition stuff" do
|
62
|
+
# ...
|
63
|
+
# end
|
64
|
+
# end
|
65
|
+
#
|
66
|
+
# And, for those of you who prefer to use something more like Ruby, you
|
67
|
+
# can just include the module directly
|
68
|
+
#
|
69
|
+
# describe SmallEdition do
|
70
|
+
# include AllEditions
|
71
|
+
#
|
72
|
+
# it "should do small edition stuff" do
|
73
|
+
# ...
|
74
|
+
# end
|
75
|
+
# end
|
76
|
+
def share_as(name, &block)
|
77
|
+
begin
|
78
|
+
Object.const_set(name, share_examples_for(name, &block))
|
79
|
+
rescue NameError => e
|
80
|
+
raise NameError.new(e.message + "\nThe first argument to share_as must be a legal name for a constant\n")
|
81
|
+
end
|
82
|
+
end
|
35
83
|
|
36
84
|
private
|
37
85
|
|
data/lib/spec/runner.rb
CHANGED
@@ -9,12 +9,12 @@ require 'spec/runner/spec_parser'
|
|
9
9
|
require 'spec/runner/class_and_arguments_parser'
|
10
10
|
|
11
11
|
module Spec
|
12
|
-
# ==
|
12
|
+
# == ExampleGroups and Examples
|
13
13
|
#
|
14
|
-
# Rather than expressing examples in classes, RSpec uses a custom
|
15
|
-
# describe
|
14
|
+
# Rather than expressing examples in classes, RSpec uses a custom DSLL (DSL light) to
|
15
|
+
# describe groups of examples.
|
16
16
|
#
|
17
|
-
# A
|
17
|
+
# A ExampleGroup is the equivalent of a fixture in xUnit-speak. It is a metaphor for the context
|
18
18
|
# in which you will run your executable example - a set of known objects in a known starting state.
|
19
19
|
# We begin be describing
|
20
20
|
#
|
@@ -123,11 +123,11 @@ module Spec
|
|
123
123
|
# end
|
124
124
|
# end
|
125
125
|
#
|
126
|
-
# == Shared
|
126
|
+
# == Shared Example Groups
|
127
127
|
#
|
128
|
-
# You can define a shared
|
128
|
+
# You can define a shared Example Group, that may be used on other groups
|
129
129
|
#
|
130
|
-
#
|
130
|
+
# share_examples_for "All Editions" do
|
131
131
|
# it "all editions behaviour" ...
|
132
132
|
# end
|
133
133
|
#
|
@@ -139,9 +139,9 @@ module Spec
|
|
139
139
|
# end
|
140
140
|
# end
|
141
141
|
#
|
142
|
-
# You can also assign the shared
|
142
|
+
# You can also assign the shared group to a module and include that
|
143
143
|
#
|
144
|
-
#
|
144
|
+
# share_as :AllEditions do
|
145
145
|
# it "should do all editions stuff" ...
|
146
146
|
# end
|
147
147
|
#
|
@@ -7,11 +7,7 @@ module Spec
|
|
7
7
|
def add_example_group(example_group)
|
8
8
|
super
|
9
9
|
output.puts
|
10
|
-
|
11
|
-
output.puts example_group.to_s
|
12
|
-
else
|
13
|
-
output.puts example_group.description
|
14
|
-
end
|
10
|
+
output.puts example_group.description
|
15
11
|
output.flush
|
16
12
|
end
|
17
13
|
|
data/lib/spec/version.rb
CHANGED
@@ -3,10 +3,10 @@ module Spec
|
|
3
3
|
unless defined? MAJOR
|
4
4
|
MAJOR = 1
|
5
5
|
MINOR = 1
|
6
|
-
TINY =
|
6
|
+
TINY = 1
|
7
7
|
RELEASE_CANDIDATE = nil
|
8
8
|
|
9
|
-
BUILD_TIME_UTC =
|
9
|
+
BUILD_TIME_UTC = 20071217181808
|
10
10
|
|
11
11
|
STRING = [MAJOR, MINOR, TINY].join('.')
|
12
12
|
TAG = "REL_#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('_')}".upcase.gsub(/\.|-/, '_')
|
@@ -2,288 +2,280 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
2
2
|
|
3
3
|
module Spec
|
4
4
|
module Example
|
5
|
-
ConfigurationSpec =
|
6
|
-
describe Configuration, :shared => true do
|
7
|
-
before(:each) do
|
8
|
-
@config = Configuration.new
|
9
|
-
@example_group = mock("example_group")
|
10
|
-
end
|
11
|
-
end
|
12
5
|
|
13
|
-
describe Configuration
|
14
|
-
|
15
|
-
|
16
|
-
@
|
6
|
+
describe Configuration do
|
7
|
+
before(:each) do
|
8
|
+
@config = Configuration.new
|
9
|
+
@example_group = mock("example_group")
|
17
10
|
end
|
11
|
+
|
12
|
+
describe "#mock_with" do
|
18
13
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
14
|
+
it "should default mock framework to rspec" do
|
15
|
+
@config.mock_framework.should =~ /\/plugins\/mock_frameworks\/rspec$/
|
16
|
+
end
|
23
17
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
18
|
+
it "should let you set rspec mocking explicitly" do
|
19
|
+
@config.mock_with(:rspec)
|
20
|
+
@config.mock_framework.should =~ /\/plugins\/mock_frameworks\/rspec$/
|
21
|
+
end
|
28
22
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
23
|
+
it "should let you set mocha" do
|
24
|
+
@config.mock_with(:mocha)
|
25
|
+
@config.mock_framework.should =~ /\/plugins\/mock_frameworks\/mocha$/
|
26
|
+
end
|
33
27
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
28
|
+
it "should let you set flexmock" do
|
29
|
+
@config.mock_with(:flexmock)
|
30
|
+
@config.mock_framework.should =~ /\/plugins\/mock_frameworks\/flexmock$/
|
31
|
+
end
|
38
32
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
33
|
+
it "should let you set rr" do
|
34
|
+
@config.mock_with(:rr)
|
35
|
+
@config.mock_framework.should =~ /\/plugins\/mock_frameworks\/rr$/
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should let you set an arbitrary adapter module" do
|
39
|
+
adapter = Module.new
|
40
|
+
@config.mock_with(adapter)
|
41
|
+
@config.mock_framework.should == adapter
|
42
|
+
end
|
43
43
|
end
|
44
|
-
end
|
45
44
|
|
46
|
-
|
47
|
-
include ConfigurationSpec
|
45
|
+
describe "#include" do
|
48
46
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
47
|
+
before do
|
48
|
+
@original_configuration = Spec::Runner.configuration
|
49
|
+
spec_configuration = @config
|
50
|
+
Spec::Runner.instance_eval {@configuration = spec_configuration}
|
51
|
+
@example_group_class = Class.new(ExampleGroup) do
|
52
|
+
class << self
|
53
|
+
def this_class_has_special_methods
|
54
|
+
end
|
56
55
|
end
|
57
56
|
end
|
57
|
+
ExampleGroupFactory.register(:foobar, @example_group_class)
|
58
58
|
end
|
59
|
-
ExampleGroupFactory.register(:foobar, @example_group_class)
|
60
|
-
end
|
61
59
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
60
|
+
after do
|
61
|
+
original_configuration = @original_configuration
|
62
|
+
Spec::Runner.instance_eval {@configuration = original_configuration}
|
63
|
+
ExampleGroupFactory.reset
|
64
|
+
end
|
67
65
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
66
|
+
it "should include the submitted module in ExampleGroup subclasses" do
|
67
|
+
mod = Module.new
|
68
|
+
@config.include mod
|
69
|
+
Class.new(@example_group_class).included_modules.should include(mod)
|
70
|
+
end
|
73
71
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
72
|
+
it "should let you define modules to be included for a specific type" do
|
73
|
+
mod = Module.new
|
74
|
+
@config.include mod, :type => :foobar
|
75
|
+
Class.new(@example_group_class).included_modules.should include(mod)
|
76
|
+
end
|
79
77
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
78
|
+
it "should not include modules in a type they are not intended for" do
|
79
|
+
mod = Module.new
|
80
|
+
@other_example_group_class = Class.new(ExampleGroup)
|
81
|
+
ExampleGroupFactory.register(:baz, @other_example_group_class)
|
84
82
|
|
85
|
-
|
83
|
+
@config.include mod, :type => :foobar
|
84
|
+
|
85
|
+
Class.new(@other_example_group_class).included_modules.should_not include(mod)
|
86
|
+
end
|
86
87
|
|
87
|
-
Class.new(@other_example_group_class).included_modules.should_not include(mod)
|
88
|
-
end
|
89
|
-
|
90
|
-
it "should not extend the ExampleGroup baseclass (to enable the included hook to work properly)" do
|
91
|
-
pending("need to figure out how to best express this one")
|
92
88
|
end
|
89
|
+
|
93
90
|
end
|
94
91
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
end
|
108
|
-
|
109
|
-
after do
|
110
|
-
ExampleGroupFactory.reset
|
111
|
-
end
|
92
|
+
describe Configuration do
|
93
|
+
|
94
|
+
before(:each) do
|
95
|
+
@config = Configuration.new
|
96
|
+
@special_example_group = Class.new(ExampleGroup)
|
97
|
+
@special_child_example_group = Class.new(@special_example_group)
|
98
|
+
@nonspecial_example_group = Class.new(ExampleGroup)
|
99
|
+
ExampleGroupFactory.register(:special, @special_example_group)
|
100
|
+
ExampleGroupFactory.register(:special_child, @special_child_example_group)
|
101
|
+
ExampleGroupFactory.register(:non_special, @nonspecial_example_group)
|
102
|
+
@example_group = @special_child_example_group.describe "Special Example Group"
|
103
|
+
@unselected_example_group = Class.new(@nonspecial_example_group).describe "Non Special Example Group"
|
112
104
|
end
|
113
105
|
|
114
|
-
|
115
|
-
|
106
|
+
after(:each) do
|
107
|
+
ExampleGroupFactory.reset
|
108
|
+
end
|
116
109
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
110
|
+
describe "#prepend_before" do
|
111
|
+
it "prepends the before block on all instances of the passed in type" do
|
112
|
+
order = []
|
113
|
+
@config.prepend_before(:all) do
|
114
|
+
order << :prepend__before_all
|
115
|
+
end
|
116
|
+
@config.prepend_before(:all, :type => :special) do
|
117
|
+
order << :special_prepend__before_all
|
118
|
+
end
|
119
|
+
@config.prepend_before(:all, :type => :special_child) do
|
120
|
+
order << :special_child_prepend__before_all
|
121
|
+
end
|
122
|
+
@config.prepend_before(:each) do
|
123
|
+
order << :prepend__before_each
|
124
|
+
end
|
125
|
+
@config.prepend_before(:each, :type => :special) do
|
126
|
+
order << :special_prepend__before_each
|
127
|
+
end
|
128
|
+
@config.prepend_before(:each, :type => :special_child) do
|
129
|
+
order << :special_child_prepend__before_each
|
130
|
+
end
|
131
|
+
@config.prepend_before(:all, :type => :non_special) do
|
132
|
+
order << :special_prepend__before_all
|
133
|
+
end
|
134
|
+
@config.prepend_before(:each, :type => :non_special) do
|
135
|
+
order << :special_prepend__before_each
|
136
|
+
end
|
137
|
+
@example_group.it "calls prepend_before" do
|
138
|
+
end
|
145
139
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
140
|
+
@example_group.run
|
141
|
+
order.should == [
|
142
|
+
:prepend__before_all,
|
143
|
+
:special_prepend__before_all,
|
144
|
+
:special_child_prepend__before_all,
|
145
|
+
:prepend__before_each,
|
146
|
+
:special_prepend__before_each,
|
147
|
+
:special_child_prepend__before_each
|
148
|
+
]
|
149
|
+
end
|
155
150
|
end
|
156
|
-
end
|
157
151
|
|
158
|
-
|
159
|
-
include ConfigurationCallbacksSpec
|
152
|
+
describe "#append_before" do
|
160
153
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
154
|
+
it "calls append_before on the type" do
|
155
|
+
order = []
|
156
|
+
@config.append_before(:all) do
|
157
|
+
order << :append_before_all
|
158
|
+
end
|
159
|
+
@config.append_before(:all, :type => :special) do
|
160
|
+
order << :special_append_before_all
|
161
|
+
end
|
162
|
+
@config.append_before(:all, :type => :special_child) do
|
163
|
+
order << :special_child_append_before_all
|
164
|
+
end
|
165
|
+
@config.append_before(:each) do
|
166
|
+
order << :append_before_each
|
167
|
+
end
|
168
|
+
@config.append_before(:each, :type => :special) do
|
169
|
+
order << :special_append_before_each
|
170
|
+
end
|
171
|
+
@config.append_before(:each, :type => :special_child) do
|
172
|
+
order << :special_child_append_before_each
|
173
|
+
end
|
174
|
+
@config.append_before(:all, :type => :non_special) do
|
175
|
+
order << :special_append_before_all
|
176
|
+
end
|
177
|
+
@config.append_before(:each, :type => :non_special) do
|
178
|
+
order << :special_append_before_each
|
179
|
+
end
|
180
|
+
@example_group.it "calls append_before" do
|
181
|
+
end
|
189
182
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
183
|
+
@example_group.run
|
184
|
+
order.should == [
|
185
|
+
:append_before_all,
|
186
|
+
:special_append_before_all,
|
187
|
+
:special_child_append_before_all,
|
188
|
+
:append_before_each,
|
189
|
+
:special_append_before_each,
|
190
|
+
:special_child_append_before_each
|
191
|
+
]
|
192
|
+
end
|
199
193
|
end
|
200
|
-
end
|
201
194
|
|
202
|
-
|
203
|
-
include ConfigurationCallbacksSpec
|
195
|
+
describe "#prepend_after" do
|
204
196
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
197
|
+
it "prepends the after block on all instances of the passed in type" do
|
198
|
+
order = []
|
199
|
+
@config.prepend_after(:all) do
|
200
|
+
order << :prepend__after_all
|
201
|
+
end
|
202
|
+
@config.prepend_after(:all, :type => :special) do
|
203
|
+
order << :special_prepend__after_all
|
204
|
+
end
|
205
|
+
@config.prepend_after(:all, :type => :special) do
|
206
|
+
order << :special_child_prepend__after_all
|
207
|
+
end
|
208
|
+
@config.prepend_after(:each) do
|
209
|
+
order << :prepend__after_each
|
210
|
+
end
|
211
|
+
@config.prepend_after(:each, :type => :special) do
|
212
|
+
order << :special_prepend__after_each
|
213
|
+
end
|
214
|
+
@config.prepend_after(:each, :type => :special) do
|
215
|
+
order << :special_child_prepend__after_each
|
216
|
+
end
|
217
|
+
@config.prepend_after(:all, :type => :non_special) do
|
218
|
+
order << :special_prepend__after_all
|
219
|
+
end
|
220
|
+
@config.prepend_after(:each, :type => :non_special) do
|
221
|
+
order << :special_prepend__after_each
|
222
|
+
end
|
223
|
+
@example_group.it "calls prepend_after" do
|
224
|
+
end
|
233
225
|
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
226
|
+
@example_group.run
|
227
|
+
order.should == [
|
228
|
+
:special_child_prepend__after_each,
|
229
|
+
:special_prepend__after_each,
|
230
|
+
:prepend__after_each,
|
231
|
+
:special_child_prepend__after_all,
|
232
|
+
:special_prepend__after_all,
|
233
|
+
:prepend__after_all
|
234
|
+
]
|
235
|
+
end
|
243
236
|
end
|
244
|
-
end
|
245
237
|
|
246
|
-
|
247
|
-
include ConfigurationCallbacksSpec
|
238
|
+
describe "#append_after" do
|
248
239
|
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
240
|
+
it "calls append_after on the type" do
|
241
|
+
order = []
|
242
|
+
@config.append_after(:all) do
|
243
|
+
order << :append__after_all
|
244
|
+
end
|
245
|
+
@config.append_after(:all, :type => :special) do
|
246
|
+
order << :special_append__after_all
|
247
|
+
end
|
248
|
+
@config.append_after(:all, :type => :special_child) do
|
249
|
+
order << :special_child_append__after_all
|
250
|
+
end
|
251
|
+
@config.append_after(:each) do
|
252
|
+
order << :append__after_each
|
253
|
+
end
|
254
|
+
@config.append_after(:each, :type => :special) do
|
255
|
+
order << :special_append__after_each
|
256
|
+
end
|
257
|
+
@config.append_after(:each, :type => :special_child) do
|
258
|
+
order << :special_child_append__after_each
|
259
|
+
end
|
260
|
+
@config.append_after(:all, :type => :non_special) do
|
261
|
+
order << :non_special_append_after_all
|
262
|
+
end
|
263
|
+
@config.append_after(:each, :type => :non_special) do
|
264
|
+
order << :non_special_append_after_each
|
265
|
+
end
|
266
|
+
@example_group.it "calls append_after" do
|
267
|
+
end
|
277
268
|
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
269
|
+
@example_group.run
|
270
|
+
order.should == [
|
271
|
+
:special_child_append__after_each,
|
272
|
+
:special_append__after_each,
|
273
|
+
:append__after_each,
|
274
|
+
:special_child_append__after_all,
|
275
|
+
:special_append__after_all,
|
276
|
+
:append__after_all
|
277
|
+
]
|
278
|
+
end
|
287
279
|
end
|
288
280
|
end
|
289
281
|
end
|
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
2
|
|
3
3
|
module Spec
|
4
4
|
module Example
|
5
|
-
describe ExampleGroupMethods do
|
5
|
+
describe 'ExampleGroupMethods' do
|
6
6
|
it_should_behave_like "sandboxed rspec_options"
|
7
7
|
attr_reader :example_group, :result, :reporter
|
8
8
|
before(:each) do
|
@@ -294,6 +294,11 @@ module Spec
|
|
294
294
|
it ".spec_path should expand the passed in :spec_path option passed into the constructor" do
|
295
295
|
example_group.spec_path.should == File.expand_path("blah")
|
296
296
|
end
|
297
|
+
|
298
|
+
it ".description_options should return all the options passed in" do
|
299
|
+
example_group.description_options.should == {:a => "b", :spec_path => "blah"}
|
300
|
+
end
|
301
|
+
|
297
302
|
end
|
298
303
|
end
|
299
304
|
|
@@ -315,6 +320,16 @@ module Spec
|
|
315
320
|
end
|
316
321
|
child_example_group.description.should == "ExampleGroup.foobar Does something"
|
317
322
|
end
|
323
|
+
|
324
|
+
it "should return the class name if nil" do
|
325
|
+
example_group.set_description(nil)
|
326
|
+
example_group.description.should =~ /Class:/
|
327
|
+
end
|
328
|
+
|
329
|
+
it "should return the class name if nil" do
|
330
|
+
example_group.set_description("")
|
331
|
+
example_group.description.should =~ /Class:/
|
332
|
+
end
|
318
333
|
end
|
319
334
|
|
320
335
|
describe "#description_parts" do
|
@@ -340,7 +355,7 @@ module Spec
|
|
340
355
|
]
|
341
356
|
end
|
342
357
|
end
|
343
|
-
|
358
|
+
|
344
359
|
describe "#described_type" do
|
345
360
|
it "should return passed in type" do
|
346
361
|
child_example_group = Class.new(example_group) do
|
@@ -41,10 +41,36 @@ module Spec
|
|
41
41
|
rspec_options.example_groups.should_not include(example_group)
|
42
42
|
end
|
43
43
|
|
44
|
-
it "should create a shared ExampleGroup with
|
45
|
-
group = @main.
|
44
|
+
it "should create a shared ExampleGroup with share_examples_for" do
|
45
|
+
group = @main.share_examples_for "all things" do end
|
46
46
|
group.should be_an_instance_of(Spec::Example::SharedExampleGroup)
|
47
47
|
end
|
48
|
+
|
49
|
+
describe "#share_as" do
|
50
|
+
before(:each) do
|
51
|
+
$share_as_examples_example_module_number ||= 1
|
52
|
+
$share_as_examples_example_module_number += 1
|
53
|
+
t = Time.new.to_i
|
54
|
+
@group_name = "Group#{$share_as_examples_example_module_number}"
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should create a shared ExampleGroup" do
|
58
|
+
group = @main.share_as @group_name do end
|
59
|
+
group.should be_an_instance_of(Spec::Example::SharedExampleGroup)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should create a constant that points to a Module" do
|
63
|
+
group = @main.share_as @group_name do end
|
64
|
+
Object.const_get(@group_name).should equal(group)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should bark if you pass it something not-constantizable" do
|
68
|
+
lambda do
|
69
|
+
@group = @main.share_as "Non Constant" do end
|
70
|
+
end.should raise_error(NameError, /The first argument to share_as must be a legal name for a constant/)
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
48
74
|
end
|
49
75
|
end
|
50
76
|
end
|
@@ -43,17 +43,17 @@ module Spec
|
|
43
43
|
DRb.stop_service
|
44
44
|
end
|
45
45
|
|
46
|
-
|
46
|
+
it "should run against local server" do
|
47
47
|
out = run_spec_via_druby(['--version'])
|
48
48
|
out.should =~ /RSpec/n
|
49
49
|
end
|
50
50
|
|
51
|
-
|
51
|
+
it "should output green colorized text when running with --colour option" do
|
52
52
|
out = run_spec_via_druby(["--colour", @dummy_spec_filename])
|
53
53
|
out.should =~ /\e\[32m/n
|
54
54
|
end
|
55
55
|
|
56
|
-
|
56
|
+
it "should output red colorized text when running with -c option" do
|
57
57
|
out = run_spec_via_druby(["-c", @dummy_spec_filename])
|
58
58
|
out.should =~ /\e\[31m/n
|
59
59
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RSpec Development Team
|
@@ -9,7 +9,7 @@ autorequire: spec
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2007-12-
|
12
|
+
date: 2007-12-17 00:00:00 -06:00
|
13
13
|
default_executable: spec
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -385,6 +385,6 @@ rubyforge_project: rspec
|
|
385
385
|
rubygems_version: 0.9.5
|
386
386
|
signing_key:
|
387
387
|
specification_version: 2
|
388
|
-
summary: RSpec-1.1.
|
388
|
+
summary: RSpec-1.1.1 (build 20071217181808) - BDD for Ruby http://rspec.rubyforge.org/
|
389
389
|
test_files: []
|
390
390
|
|