rspec-core 2.0.0.a2 → 2.0.0.a3
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +2 -2
- data/.gitignore +1 -0
- data/README.markdown +18 -4
- data/Rakefile +6 -17
- data/bin/rspec +0 -8
- data/example_specs/failing/README.txt +1 -1
- data/example_specs/failing/spec_helper.rb +7 -2
- data/example_specs/failing/team_spec.rb +0 -1
- data/features/before_and_after_blocks/around.feature +2 -0
- data/features/command_line/example_name_option.feature +54 -0
- data/features/command_line/line_number_appended_to_path.feature +39 -0
- data/features/command_line/line_number_option.feature +40 -0
- data/features/matchers/define_matcher.feature +18 -4
- data/features/matchers/define_matcher_outside_rspec.feature +1 -2
- data/features/mocks/mix_stubs_and_mocks.feature +2 -0
- data/features/subject/explicit_subject.feature +4 -0
- data/features/subject/implicit_subject.feature +4 -0
- data/features/support/env.rb +15 -1
- data/lib/rspec/core.rb +1 -1
- data/lib/rspec/core/command_line_options.rb +9 -0
- data/lib/rspec/core/configuration.rb +18 -8
- data/lib/rspec/core/example.rb +14 -23
- data/lib/rspec/core/example_group.rb +39 -30
- data/lib/rspec/core/formatters/base_formatter.rb +9 -7
- data/lib/rspec/core/formatters/base_text_formatter.rb +2 -2
- data/lib/rspec/core/formatters/documentation_formatter.rb +10 -12
- data/lib/rspec/core/kernel_extensions.rb +2 -2
- data/lib/rspec/core/load_path.rb +1 -2
- data/lib/rspec/core/metadata.rb +65 -27
- data/lib/rspec/core/ruby_project.rb +24 -10
- data/lib/rspec/core/runner.rb +3 -3
- data/lib/rspec/core/{shared_behaviour.rb → shared_example_group.rb} +5 -5
- data/lib/rspec/core/{shared_behaviour_kernel_extensions.rb → shared_example_group_kernel_extensions.rb} +3 -3
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +29 -50
- data/rspec-core.gemspec +22 -21
- data/spec/rspec/core/command_line_options_spec.rb +14 -0
- data/spec/rspec/core/configuration_spec.rb +51 -13
- data/spec/rspec/core/example_group_spec.rb +61 -68
- data/spec/rspec/core/example_group_subject_spec.rb +1 -1
- data/spec/rspec/core/example_spec.rb +19 -8
- data/spec/rspec/core/formatters/base_formatter_spec.rb +2 -2
- data/spec/rspec/core/metadata_spec.rb +52 -17
- data/spec/rspec/core/mocha_spec.rb +4 -4
- data/spec/rspec/core/pending_example_spec.rb +19 -0
- data/spec/rspec/core/ruby_project_spec.rb +24 -0
- data/spec/rspec/core/{shared_behaviour_spec.rb → shared_example_group_spec.rb} +31 -31
- data/spec/rspec/core/world_spec.rb +64 -83
- data/spec/spec_helper.rb +19 -30
- metadata +17 -17
- data/features-pending/command_line/line_number_option.feature +0 -56
- data/features-pending/command_line/line_number_option_with_example_with_no_name.feature +0 -22
- data/lib/rspec/core/extensions/instance_exec.rb +0 -31
- data/spec/resources/example_classes.rb +0 -67
- data/spec/rspec/core/resources/example_classes.rb +0 -67
@@ -3,13 +3,18 @@ require 'spec_helper'
|
|
3
3
|
describe Rspec::Core::Example, :parent_metadata => 'sample' do
|
4
4
|
|
5
5
|
before do
|
6
|
-
|
7
|
-
|
6
|
+
example_group = stub('example_group',
|
7
|
+
:metadata => Rspec::Core::Metadata.new.process(
|
8
|
+
'group description',
|
9
|
+
:caller => ['foo_spec.rb:37']
|
10
|
+
)
|
11
|
+
).as_null_object
|
12
|
+
@example = Rspec::Core::Example.new(example_group, 'example description', {}, (lambda {}))
|
8
13
|
end
|
9
14
|
|
10
15
|
describe "attr readers" do
|
11
|
-
it "should have one for the parent
|
12
|
-
@example.should respond_to(:
|
16
|
+
it "should have one for the parent example group" do
|
17
|
+
@example.should respond_to(:example_group)
|
13
18
|
end
|
14
19
|
|
15
20
|
it "should have one for it's description" do
|
@@ -26,8 +31,8 @@ describe Rspec::Core::Example, :parent_metadata => 'sample' do
|
|
26
31
|
end
|
27
32
|
|
28
33
|
describe '#inspect' do
|
29
|
-
it "should return '
|
30
|
-
@example.inspect.should == '
|
34
|
+
it "should return 'group description - description'" do
|
35
|
+
@example.inspect.should == 'group description example description'
|
31
36
|
end
|
32
37
|
end
|
33
38
|
|
@@ -37,13 +42,19 @@ describe Rspec::Core::Example, :parent_metadata => 'sample' do
|
|
37
42
|
end
|
38
43
|
end
|
39
44
|
|
45
|
+
describe '#described_class' do
|
46
|
+
it "returns the class (if any) of the outermost example group" do
|
47
|
+
described_class.should == Rspec::Core::Example
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
40
51
|
describe "accessing metadata within a running example" do
|
41
52
|
it "should have a reference to itself when running" do
|
42
53
|
running_example.description.should == "should have a reference to itself when running"
|
43
54
|
end
|
44
55
|
|
45
|
-
it "should be able to access the
|
46
|
-
running_example.
|
56
|
+
it "should be able to access the example group's top level metadata as if it were its own" do
|
57
|
+
running_example.example_group.metadata.should include(:parent_metadata => 'sample')
|
47
58
|
running_example.metadata.should include(:parent_metadata => 'sample')
|
48
59
|
end
|
49
60
|
end
|
@@ -68,8 +68,8 @@ describe Rspec::Core::Formatters::BaseFormatter do
|
|
68
68
|
@formatter.should have_interface_for(:start).with(1).argument
|
69
69
|
end
|
70
70
|
|
71
|
-
it "should have
|
72
|
-
@formatter.should have_interface_for(:
|
71
|
+
it "should have add_example_group as an interface with one argument" do
|
72
|
+
@formatter.should have_interface_for(:add_example_group).with(1).argument
|
73
73
|
end
|
74
74
|
|
75
75
|
it "should have example_finished as an interface with one argument" do
|
@@ -3,29 +3,41 @@ require 'spec_helper'
|
|
3
3
|
module Rspec
|
4
4
|
module Core
|
5
5
|
describe Metadata do
|
6
|
-
describe "
|
6
|
+
describe "[:example_group][:name]" do
|
7
7
|
it "generates name for top level example group" do
|
8
8
|
m = Metadata.new
|
9
9
|
m.process("description", :caller => caller(0))
|
10
|
-
m[:
|
10
|
+
m[:example_group][:name].should == "description"
|
11
11
|
end
|
12
12
|
|
13
13
|
it "concats args to describe()" do
|
14
14
|
m = Metadata.new
|
15
15
|
m.process(String, "with dots", :caller => caller(0))
|
16
|
-
m[:
|
16
|
+
m[:example_group][:name].should == "String with dots"
|
17
17
|
end
|
18
18
|
|
19
19
|
it "concats nested names" do
|
20
|
-
|
21
|
-
|
22
|
-
m
|
20
|
+
parent = Metadata.new
|
21
|
+
parent.process("parent", :caller => caller(0))
|
22
|
+
m = Metadata.new(parent)
|
23
|
+
m.process("child", :caller => caller(0))
|
24
|
+
m[:example_group][:name].should == "parent child"
|
23
25
|
end
|
24
26
|
|
25
27
|
it "strips the name" do
|
26
28
|
m = Metadata.new
|
27
29
|
m.process(" description \n", :caller => caller(0))
|
28
|
-
m[:
|
30
|
+
m[:example_group][:name].should == "description"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "[:full_description]" do
|
35
|
+
it "concats the example group name and description" do
|
36
|
+
m = Metadata.new
|
37
|
+
m[:example_group][:name] = "group"
|
38
|
+
|
39
|
+
m = m.for_example("example", {})
|
40
|
+
m[:full_description].should == "group example"
|
29
41
|
end
|
30
42
|
end
|
31
43
|
|
@@ -38,7 +50,7 @@ module Rspec
|
|
38
50
|
"bar_spec.rb:23",
|
39
51
|
"baz"
|
40
52
|
])
|
41
|
-
m[:
|
53
|
+
m[:example_group][:file_path].should == __FILE__
|
42
54
|
end
|
43
55
|
end
|
44
56
|
|
@@ -51,7 +63,7 @@ module Rspec
|
|
51
63
|
"bar_spec.rb:23",
|
52
64
|
"baz"
|
53
65
|
])
|
54
|
-
m[:
|
66
|
+
m[:example_group][:line_number].should == __LINE__ - 4
|
55
67
|
end
|
56
68
|
it "uses the number after the first : for ruby 1.9" do
|
57
69
|
m = Metadata.new
|
@@ -61,18 +73,22 @@ module Rspec
|
|
61
73
|
"bar_spec.rb:23",
|
62
74
|
"baz"
|
63
75
|
])
|
64
|
-
m[:
|
76
|
+
m[:example_group][:line_number].should == __LINE__ - 4
|
65
77
|
end
|
66
78
|
end
|
67
79
|
|
68
80
|
describe "#metadata_for_example" do
|
69
|
-
let(:
|
70
|
-
let(:
|
71
|
-
let(:metadata) { Metadata.new.process(:caller =>
|
72
|
-
let(:mfe) { metadata.for_example("
|
81
|
+
let(:caller_for_example) { caller(0) }
|
82
|
+
let(:line_number) { __LINE__ - 1 }
|
83
|
+
let(:metadata) { Metadata.new.process("group description", :caller => caller(0)) }
|
84
|
+
let(:mfe) { metadata.for_example("example description", {:caller => caller_for_example, :arbitrary => :options}) }
|
73
85
|
|
74
86
|
it "stores the description" do
|
75
|
-
mfe[:description].should == "
|
87
|
+
mfe[:description].should == "example description"
|
88
|
+
end
|
89
|
+
|
90
|
+
it "stores the full_description (group description + example description)" do
|
91
|
+
mfe[:full_description].should == "group description example description"
|
76
92
|
end
|
77
93
|
|
78
94
|
it "creates an empty execution result" do
|
@@ -80,7 +96,7 @@ module Rspec
|
|
80
96
|
end
|
81
97
|
|
82
98
|
it "stores the caller" do
|
83
|
-
mfe[:caller].should ==
|
99
|
+
mfe[:caller].should == caller_for_example
|
84
100
|
end
|
85
101
|
|
86
102
|
it "extracts file path from caller" do
|
@@ -88,14 +104,33 @@ module Rspec
|
|
88
104
|
end
|
89
105
|
|
90
106
|
it "extracts line number from caller" do
|
91
|
-
mfe[:line_number].should ==
|
107
|
+
mfe[:line_number].should == line_number
|
108
|
+
end
|
109
|
+
|
110
|
+
it "extracts location from caller" do
|
111
|
+
mfe[:location].should == "#{__FILE__}:#{line_number}"
|
92
112
|
end
|
93
113
|
|
94
114
|
it "merges arbitrary options" do
|
95
115
|
mfe[:arbitrary].should == :options
|
96
116
|
end
|
117
|
+
end
|
97
118
|
|
119
|
+
describe "#apply_condition" do
|
120
|
+
let(:group_metadata) { Metadata.new.process('group', :caller => ["foo_spec.rb:#{__LINE__}"]) }
|
121
|
+
let(:group_line_number) { __LINE__ -1 }
|
122
|
+
let(:example_metadata) { group_metadata.for_example('example', :caller => ["foo_spec.rb:#{__LINE__}"]) }
|
123
|
+
let(:example_line_number) { __LINE__ -1 }
|
124
|
+
|
125
|
+
it "matches when the line_number matches the group" do
|
126
|
+
group_metadata.apply_condition(:line_number, group_line_number).should be_true
|
127
|
+
end
|
128
|
+
|
129
|
+
it "matches when the line_number matches the example" do
|
130
|
+
example_metadata.apply_condition(:line_number, example_line_number).should be_true
|
131
|
+
end
|
98
132
|
end
|
133
|
+
|
99
134
|
end
|
100
135
|
end
|
101
136
|
end
|
@@ -10,15 +10,15 @@ describe "Mocha Regression involving double reporting of errors" do
|
|
10
10
|
|
11
11
|
use_formatter(formatter) do
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
disconnect_from_world do
|
14
|
+
group = Rspec::Core::ExampleGroup.describe("my favorite pony") do
|
15
15
|
example("showing a double fail") do
|
16
16
|
foo = "string"
|
17
17
|
foo.expects(:something)
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
21
|
-
|
20
|
+
group.examples_to_run.replace(group.examples)
|
21
|
+
group.run(formatter)
|
22
22
|
end
|
23
23
|
|
24
24
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
Rspec::Matchers.define :be_pending do
|
4
|
+
match do |example|
|
5
|
+
example.metadata[:pending]
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "an example" do
|
10
|
+
context "with no block" do
|
11
|
+
it "is listed as pending" do
|
12
|
+
group = isolated_example_group do
|
13
|
+
it "has no block"
|
14
|
+
end
|
15
|
+
group.run(stub('reporter').as_null_object)
|
16
|
+
group.examples.first.should be_pending
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Rspec
|
2
|
+
module Core
|
3
|
+
describe RubyProject do
|
4
|
+
|
5
|
+
describe "#determine_root" do
|
6
|
+
|
7
|
+
context "with ancestor containing spec directory" do
|
8
|
+
it "returns ancestor containing the spec directory" do
|
9
|
+
RubyProject.stub(:ascend_until).and_return('foodir')
|
10
|
+
RubyProject.determine_root.should == 'foodir'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context "without ancestor containing spec directory" do
|
15
|
+
it "returns current working directory" do
|
16
|
+
RubyProject.stub(:find_first_parent_containing).and_return(nil)
|
17
|
+
RubyProject.determine_root.should == '.'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Rspec::Core::
|
3
|
+
describe Rspec::Core::SharedExampleGroup do
|
4
4
|
|
5
5
|
it "should add the 'share_examples_for' method to the global namespace" do
|
6
6
|
Kernel.should respond_to(:share_examples_for)
|
@@ -14,8 +14,8 @@ describe Rspec::Core::SharedBehaviour do
|
|
14
14
|
Kernel.should respond_to(:share_as)
|
15
15
|
end
|
16
16
|
|
17
|
-
it "should raise an ArgumentError when adding a second shared
|
18
|
-
group =
|
17
|
+
it "should raise an ArgumentError when adding a second shared example group with the same name" do
|
18
|
+
group = isolated_example_group('example group')
|
19
19
|
group.share_examples_for('really important business value') { }
|
20
20
|
lambda do
|
21
21
|
group.share_examples_for('really important business value') { }
|
@@ -24,42 +24,42 @@ describe Rspec::Core::SharedBehaviour do
|
|
24
24
|
|
25
25
|
describe "share_examples_for" do
|
26
26
|
|
27
|
-
it "should capture the given name and block in the Worlds collection of shared
|
28
|
-
Rspec::Core.world.
|
27
|
+
it "should capture the given name and block in the Worlds collection of shared example groups" do
|
28
|
+
Rspec::Core.world.shared_example_groups.should_receive(:[]=).with(:foo, anything)
|
29
29
|
share_examples_for(:foo) { }
|
30
30
|
end
|
31
31
|
|
32
32
|
end
|
33
33
|
|
34
|
-
describe "including shared
|
34
|
+
describe "including shared example_groups using #it_should_behave_like" do
|
35
35
|
|
36
|
-
def
|
37
|
-
|
36
|
+
def cleanup_shared_example_groups
|
37
|
+
original_shared_example_groups = Rspec::Core.world.shared_example_groups
|
38
38
|
yield if block_given?
|
39
|
-
Rspec::Core.world.
|
39
|
+
Rspec::Core.world.shared_example_groups.replace(original_shared_example_groups)
|
40
40
|
end
|
41
41
|
|
42
|
-
it "should module_eval any found shared
|
43
|
-
group =
|
42
|
+
it "should module_eval any found shared example_groups" do
|
43
|
+
group = isolated_example_group('fake group')
|
44
44
|
block1 = lambda {}
|
45
45
|
block2 = lambda {
|
46
46
|
def extra_helper
|
47
47
|
'extra_helper'
|
48
48
|
end
|
49
49
|
}
|
50
|
-
Rspec::Core.world.stub!(:
|
50
|
+
Rspec::Core.world.stub!(:shared_example_groups).and_return({ :a => block1, :shared_example_group => block2 })
|
51
51
|
group.should_receive(:module_eval).once
|
52
|
-
group.it_should_behave_like :
|
52
|
+
group.it_should_behave_like :shared_example_group
|
53
53
|
end
|
54
54
|
|
55
|
-
it "should make any shared
|
56
|
-
group =
|
55
|
+
it "should make any shared example_group available at the correct level" do
|
56
|
+
group = isolated_example_group('fake group')
|
57
57
|
block = lambda {
|
58
58
|
def self.class_helper; end
|
59
59
|
def extra_helper; end
|
60
60
|
}
|
61
|
-
Rspec::Core.world.stub!(:
|
62
|
-
group.it_should_behave_like :
|
61
|
+
Rspec::Core.world.stub!(:shared_example_groups).and_return({ :shared_example_group => block })
|
62
|
+
group.it_should_behave_like :shared_example_group
|
63
63
|
with_ruby(1.8) do
|
64
64
|
group.instance_methods.should include('extra_helper')
|
65
65
|
group.singleton_methods.should include('class_helper')
|
@@ -73,9 +73,9 @@ describe Rspec::Core::SharedBehaviour do
|
|
73
73
|
it "should raise when named shared example_group can not be found"
|
74
74
|
|
75
75
|
it "adds examples to current example_group using it_should_behave_like" do
|
76
|
-
|
77
|
-
group =
|
78
|
-
|
76
|
+
cleanup_shared_example_groups do
|
77
|
+
group = isolated_example_group("example_group") do
|
78
|
+
it("i was already here") {}
|
79
79
|
end
|
80
80
|
|
81
81
|
group.examples.size.should == 1
|
@@ -92,8 +92,8 @@ describe Rspec::Core::SharedBehaviour do
|
|
92
92
|
end
|
93
93
|
|
94
94
|
it "adds examples to from two shared groups" do
|
95
|
-
|
96
|
-
group =
|
95
|
+
cleanup_shared_example_groups do
|
96
|
+
group = isolated_example_group("example_group") do |g|
|
97
97
|
g.it("i was already here") {}
|
98
98
|
end
|
99
99
|
|
@@ -116,17 +116,17 @@ describe Rspec::Core::SharedBehaviour do
|
|
116
116
|
end
|
117
117
|
|
118
118
|
share_as('Cornucopia') do
|
119
|
-
it "should do foo"
|
119
|
+
it "should do foo" do; end
|
120
120
|
end
|
121
121
|
|
122
|
-
|
123
|
-
group =
|
124
|
-
group.should
|
122
|
+
pending "adds examples to current example_group using include", :compat => 'rspec-1.2' do
|
123
|
+
group = isolated_example_group('group') { include Cornucopia }
|
124
|
+
group.examples.length.should == 1
|
125
125
|
end
|
126
126
|
|
127
127
|
it "adds examples to current example_group using it_should_behave_like with a module" do
|
128
|
-
|
129
|
-
group =
|
128
|
+
cleanup_shared_example_groups do
|
129
|
+
group = isolated_example_group("example_group") {}
|
130
130
|
|
131
131
|
shared_foo = group.share_as(:FooShared) do
|
132
132
|
it("shared example") {}
|
@@ -168,13 +168,13 @@ describe Rspec::Core::SharedBehaviour do
|
|
168
168
|
it "should run after(:all) only once from shared example_group", :compat => 'rspec-1.2'
|
169
169
|
|
170
170
|
it "should include modules, included into shared example_group, into current example_group", :compat => 'rspec-1.2' do
|
171
|
-
running_example.
|
171
|
+
running_example.example_group.included_modules.should include(RunningSharedExamplesJustForTesting)
|
172
172
|
end
|
173
173
|
|
174
174
|
it "should make methods defined in the shared example_group available in consuming example_group", :compat => 'rspec-1.2' do
|
175
175
|
# TODO: Consider should have_method(...) simple matcher
|
176
|
-
with_ruby('1.8') { running_example.
|
177
|
-
with_ruby('1.9') { running_example.
|
176
|
+
with_ruby('1.8') { running_example.example_group.methods.should include('magic') }
|
177
|
+
with_ruby('1.9') { running_example.example_group.methods.should include(:magic) }
|
178
178
|
end
|
179
179
|
|
180
180
|
end
|
@@ -7,14 +7,16 @@ describe Rspec::Core::World do
|
|
7
7
|
|
8
8
|
before do
|
9
9
|
@world = Rspec::Core::World.new
|
10
|
-
Rspec::Core.stub
|
10
|
+
Rspec::Core.stub(:world).and_return(@world)
|
11
11
|
end
|
12
12
|
|
13
|
-
describe "
|
13
|
+
describe "example groups" do
|
14
14
|
|
15
|
-
it "should contain all defined
|
16
|
-
|
17
|
-
|
15
|
+
it "should contain all defined example groups" do
|
16
|
+
disconnect_from_world do
|
17
|
+
example_group = Rspec::Core::ExampleGroup.describe(Bar, 'Empty Example Group') { }
|
18
|
+
@world.example_groups.should include(example_group)
|
19
|
+
end
|
18
20
|
end
|
19
21
|
|
20
22
|
end
|
@@ -24,7 +26,7 @@ describe Rspec::Core::World do
|
|
24
26
|
before(:all) do
|
25
27
|
options_1 = { :foo => 1, :color => 'blue', :feature => 'reporting' }
|
26
28
|
options_2 = { :pending => true, :feature => 'reporting' }
|
27
|
-
options_3 = { :array => [1,2,3,4], :color => 'blue'
|
29
|
+
options_3 = { :array => [1,2,3,4], :color => 'blue' }
|
28
30
|
@bg1 = Rspec::Core::ExampleGroup.describe(Bar, "find group-1", options_1) { }
|
29
31
|
@bg2 = Rspec::Core::ExampleGroup.describe(Bar, "find group-2", options_2) { }
|
30
32
|
@bg3 = Rspec::Core::ExampleGroup.describe(Bar, "find group-3", options_3) { }
|
@@ -35,64 +37,56 @@ describe Rspec::Core::World do
|
|
35
37
|
it("not so awesome", :awesome => false) {}
|
36
38
|
it("I also have no options") {}
|
37
39
|
end
|
38
|
-
@
|
40
|
+
@example_groups = [@bg1, @bg2, @bg3, @bg4]
|
39
41
|
end
|
40
42
|
|
41
43
|
after(:all) do
|
42
|
-
Rspec::Core.world.
|
43
|
-
Rspec::Core.world.
|
44
|
-
Rspec::Core.world.
|
45
|
-
Rspec::Core.world.
|
44
|
+
Rspec::Core.world.example_groups.delete(@bg1)
|
45
|
+
Rspec::Core.world.example_groups.delete(@bg2)
|
46
|
+
Rspec::Core.world.example_groups.delete(@bg3)
|
47
|
+
Rspec::Core.world.example_groups.delete(@bg4)
|
46
48
|
end
|
47
49
|
|
48
|
-
it "
|
49
|
-
@world.apply_inclusion_filters(@bg4.examples, :awesome => true).should == [@bg4.examples[1], @bg4.examples[2]]
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should find no groups when given no search parameters" do
|
50
|
+
it "finds no groups when given no search parameters" do
|
53
51
|
@world.apply_inclusion_filters([]).should == []
|
54
52
|
end
|
55
53
|
|
56
|
-
it "
|
57
|
-
@world.apply_inclusion_filters(@
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should find one group when searching for :description => 'find group-1'" do
|
61
|
-
@world.apply_inclusion_filters(@behaviours, :behaviour => { :description => 'find group-1' }).should == [@bg1]
|
54
|
+
it "finds matching groups when filtering on :describes (described class or module)" do
|
55
|
+
@world.apply_inclusion_filters(@example_groups, :example_group => { :describes => Bar }).should == [@bg1, @bg2, @bg3]
|
62
56
|
end
|
63
57
|
|
64
|
-
it "
|
65
|
-
@world.apply_inclusion_filters(@
|
58
|
+
it "finds matching groups when filtering on :description with text" do
|
59
|
+
@world.apply_inclusion_filters(@example_groups, :example_group => { :description => 'find group-1' }).should == [@bg1]
|
66
60
|
end
|
67
61
|
|
68
|
-
it "
|
69
|
-
@world.apply_inclusion_filters(@
|
62
|
+
it "finds matching groups when filtering on :description with a lambda" do
|
63
|
+
@world.apply_inclusion_filters(@example_groups, :example_group => { :description => lambda { |v| v.include?('-1') || v.include?('-3') } }).should == [@bg1, @bg3]
|
70
64
|
end
|
71
65
|
|
72
|
-
it "
|
73
|
-
@world.apply_inclusion_filters(@
|
66
|
+
it "finds matching groups when filtering on :description with a regular expression" do
|
67
|
+
@world.apply_inclusion_filters(@example_groups, :example_group => { :description => /find group/ }).should == [@bg1, @bg2, @bg3]
|
74
68
|
end
|
75
69
|
|
76
|
-
it "
|
77
|
-
@world.apply_inclusion_filters(@
|
70
|
+
it "finds one group when searching for :pending => true" do
|
71
|
+
@world.apply_inclusion_filters(@example_groups, :pending => true ).should == [@bg2]
|
78
72
|
end
|
79
73
|
|
80
|
-
it "
|
81
|
-
@world.apply_inclusion_filters(@
|
74
|
+
it "finds matching groups when filtering on arbitrary metadata with a number" do
|
75
|
+
@world.apply_inclusion_filters(@example_groups, :foo => 1 ).should == [@bg1]
|
76
|
+
end
|
77
|
+
|
78
|
+
it "finds matching groups when filtering on arbitrary metadata with an array" do
|
79
|
+
@world.apply_inclusion_filters(@example_groups, :array => [1,2,3,4]).should == [@bg3]
|
82
80
|
end
|
83
81
|
|
84
|
-
it "
|
85
|
-
@world.apply_inclusion_filters(@
|
82
|
+
it "finds no groups when filtering on arbitrary metadata with an array but the arrays do not match" do
|
83
|
+
@world.apply_inclusion_filters(@example_groups, :array => [4,3,2,1]).should be_empty
|
86
84
|
end
|
87
85
|
|
88
|
-
it "
|
89
|
-
@world.apply_inclusion_filters(@
|
90
|
-
end
|
91
|
-
|
92
|
-
it "should find two groups when searching for :feature => 'reporting' }" do
|
93
|
-
@world.apply_inclusion_filters(@behaviours, :feature => 'reporting').should == [@bg1, @bg2]
|
86
|
+
it "finds matching examples when filtering on arbitrary metadata" do
|
87
|
+
@world.apply_inclusion_filters(@bg4.examples, :awesome => true).should == [@bg4.examples[1], @bg4.examples[2]]
|
94
88
|
end
|
95
|
-
|
89
|
+
|
96
90
|
end
|
97
91
|
|
98
92
|
describe "applying exclusion filters" do
|
@@ -100,65 +94,52 @@ describe Rspec::Core::World do
|
|
100
94
|
it "should find nothing if all describes match the exclusion filter" do
|
101
95
|
options = { :network_access => true }
|
102
96
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
it("bar") {}
|
107
|
-
end
|
108
|
-
|
109
|
-
@world.apply_exclusion_filters(group1.examples, :network_access => true).should == []
|
97
|
+
group1 = isolated_example_group(Bar, "find group-1", options) do
|
98
|
+
it("foo") {}
|
99
|
+
it("bar") {}
|
110
100
|
end
|
111
101
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
@world.apply_exclusion_filters(group2.examples, :network_access => true).should == [group2.examples.last]
|
102
|
+
@world.apply_exclusion_filters(group1.examples, :network_access => true).should == []
|
103
|
+
|
104
|
+
group2 = isolated_example_group(Bar, "find group-1") do
|
105
|
+
it("foo", :network_access => true) {}
|
106
|
+
it("bar") {}
|
119
107
|
end
|
108
|
+
|
109
|
+
@world.apply_exclusion_filters(group2.examples, :network_access => true).should == [group2.examples.last]
|
120
110
|
|
121
111
|
end
|
122
112
|
|
123
113
|
it "should find nothing if a regexp matches the exclusion filter" do
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
it("bar") {}
|
128
|
-
end
|
129
|
-
@world.apply_exclusion_filters(group.examples, :name => /exclude/).should == []
|
130
|
-
@world.apply_exclusion_filters(group.examples, :name => /exclude/, :another => "foo").should == []
|
131
|
-
@world.apply_exclusion_filters(group.examples, :name => /exclude/, :another => "foo", :behaviour => {
|
132
|
-
:describes => lambda { |b| b == Bar } } ).should == []
|
133
|
-
|
134
|
-
@world.apply_exclusion_filters(group.examples, :name => /exclude not/).should == group.examples
|
135
|
-
@world.apply_exclusion_filters(group.examples, :name => /exclude/, "another_condition" => "foo").should == group.examples
|
136
|
-
@world.apply_exclusion_filters(group.examples, :name => /exclude/, "another_condition" => "foo1").should == group.examples
|
114
|
+
group = isolated_example_group(Bar, "find group-1", :name => "exclude me with a regex", :another => "foo") do
|
115
|
+
it("foo") {}
|
116
|
+
it("bar") {}
|
137
117
|
end
|
118
|
+
@world.apply_exclusion_filters(group.examples, :name => /exclude/).should == []
|
119
|
+
@world.apply_exclusion_filters(group.examples, :name => /exclude/, :another => "foo").should == []
|
120
|
+
@world.apply_exclusion_filters(group.examples, :name => /exclude/, :another => "foo", :example_group => {
|
121
|
+
:describes => lambda { |b| b == Bar } } ).should == []
|
122
|
+
|
123
|
+
@world.apply_exclusion_filters(group.examples, :name => /exclude not/).should == group.examples
|
124
|
+
@world.apply_exclusion_filters(group.examples, :name => /exclude/, "another_condition" => "foo").should == group.examples
|
125
|
+
@world.apply_exclusion_filters(group.examples, :name => /exclude/, "another_condition" => "foo1").should == group.examples
|
138
126
|
end
|
139
127
|
|
140
128
|
end
|
141
129
|
|
142
|
-
describe "filtering
|
130
|
+
describe "filtering example groups" do
|
143
131
|
|
144
|
-
|
145
|
-
@group1 =
|
132
|
+
it "should run matches" do
|
133
|
+
@group1 = isolated_example_group(Bar, "find these examples") do
|
146
134
|
it('I have no options', :color => :red, :awesome => true) {}
|
147
135
|
it("I also have no options", :color => :red, :awesome => true) {}
|
148
136
|
it("not so awesome", :color => :red, :awesome => false) {}
|
149
137
|
end
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
it "should run matches" do
|
157
|
-
Rspec::Core.world.stub!(:exclusion_filter).and_return({ :awesome => false })
|
158
|
-
Rspec::Core.world.stub!(:filter).and_return({ :color => :red })
|
159
|
-
Rspec::Core.world.stub!(:behaviours).and_return([@group1])
|
160
|
-
filtered_behaviours = @world.filter_behaviours
|
161
|
-
filtered_behaviours.should == [@group1]
|
138
|
+
Rspec::Core.world.stub(:exclusion_filter).and_return({ :awesome => false })
|
139
|
+
Rspec::Core.world.stub(:filter).and_return({ :color => :red })
|
140
|
+
Rspec::Core.world.stub(:example_groups).and_return([@group1])
|
141
|
+
filtered_example_groups = @world.filter_example_groups
|
142
|
+
filtered_example_groups.should == [@group1]
|
162
143
|
@group1.examples_to_run.should == @group1.examples[0..1]
|
163
144
|
end
|
164
145
|
|