rspec-core 2.8.0.rc1 → 2.8.0.rc2

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.
Files changed (73) hide show
  1. data/License.txt +24 -0
  2. data/README.md +197 -37
  3. data/features/command_line/format_option.feature +3 -3
  4. data/features/command_line/init.feature +18 -0
  5. data/features/example_groups/shared_examples.feature +1 -1
  6. data/features/hooks/around_hooks.feature +4 -4
  7. data/features/pending/pending_examples.feature +5 -5
  8. data/features/support/env.rb +8 -1
  9. data/lib/autotest/rspec2.rb +2 -6
  10. data/lib/rspec/core.rb +48 -158
  11. data/lib/rspec/core/backward_compatibility.rb +2 -0
  12. data/lib/rspec/core/command_line.rb +4 -0
  13. data/lib/rspec/core/configuration.rb +201 -106
  14. data/lib/rspec/core/configuration_options.rb +2 -1
  15. data/lib/rspec/core/deprecation.rb +2 -3
  16. data/lib/rspec/core/drb_options.rb +69 -58
  17. data/lib/rspec/core/dsl.rb +12 -0
  18. data/lib/rspec/core/example.rb +53 -18
  19. data/lib/rspec/core/example_group.rb +144 -54
  20. data/lib/rspec/core/extensions.rb +4 -4
  21. data/lib/rspec/core/extensions/instance_eval_with_args.rb +5 -0
  22. data/lib/rspec/core/extensions/kernel.rb +1 -1
  23. data/lib/rspec/core/extensions/module_eval_with_args.rb +4 -0
  24. data/lib/rspec/core/extensions/ordered.rb +7 -2
  25. data/lib/rspec/core/filter_manager.rb +69 -36
  26. data/lib/rspec/core/formatters/base_text_formatter.rb +1 -1
  27. data/lib/rspec/core/formatters/html_formatter.rb +10 -4
  28. data/lib/rspec/core/hooks.rb +93 -34
  29. data/lib/rspec/core/let.rb +62 -61
  30. data/lib/rspec/core/metadata.rb +103 -80
  31. data/lib/rspec/core/metadata_hash_builder.rb +4 -0
  32. data/lib/rspec/core/option_parser.rb +42 -44
  33. data/lib/rspec/core/pending.rb +25 -3
  34. data/lib/rspec/core/project_initializer.rb +62 -0
  35. data/lib/rspec/core/rake_task.rb +7 -13
  36. data/lib/rspec/core/runner.rb +2 -2
  37. data/lib/rspec/core/shared_context.rb +1 -1
  38. data/lib/rspec/core/shared_example_group.rb +11 -5
  39. data/lib/rspec/core/subject.rb +3 -3
  40. data/lib/rspec/core/version.rb +1 -1
  41. data/lib/rspec/monkey.rb +1 -1
  42. data/lib/rspec/monkey/spork/test_framework/rspec.rb +2 -0
  43. data/spec/command_line/order_spec.rb +19 -13
  44. data/spec/rspec/core/command_line_spec.rb +1 -5
  45. data/spec/rspec/core/configuration_options_spec.rb +22 -27
  46. data/spec/rspec/core/configuration_spec.rb +32 -14
  47. data/spec/rspec/core/drb_command_line_spec.rb +20 -37
  48. data/spec/rspec/core/drb_options_spec.rb +51 -3
  49. data/spec/rspec/core/example_group_spec.rb +101 -84
  50. data/spec/rspec/core/example_spec.rb +14 -0
  51. data/spec/rspec/core/filter_manager_spec.rb +114 -33
  52. data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +17 -69
  53. data/spec/rspec/core/formatters/html_formatted-1.8.7.html +14 -4
  54. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +14 -4
  55. data/spec/rspec/core/formatters/html_formatted-1.9.3.html +14 -4
  56. data/spec/rspec/core/formatters/html_formatter_spec.rb +1 -1
  57. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +20 -72
  58. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +24 -14
  59. data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +29 -19
  60. data/spec/rspec/core/formatters/text_mate_formatted-1.9.3.html +29 -19
  61. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +1 -2
  62. data/spec/rspec/core/metadata_spec.rb +77 -45
  63. data/spec/rspec/core/option_parser_spec.rb +5 -0
  64. data/spec/rspec/core/pending_example_spec.rb +44 -12
  65. data/spec/rspec/core/project_initializer_spec.rb +130 -0
  66. data/spec/rspec/core/rake_task_spec.rb +1 -1
  67. data/spec/spec_helper.rb +2 -0
  68. data/spec/support/matchers.rb +2 -12
  69. metadata +18 -16
  70. data/features/command_line/configure.feature +0 -22
  71. data/lib/rspec/core/command_line_configuration.rb +0 -62
  72. data/lib/rspec/core/errors.rb +0 -13
  73. data/spec/rspec/core/command_line_configuration_spec.rb +0 -26
@@ -11,7 +11,6 @@ class SelfObserver
11
11
  end
12
12
 
13
13
  module RSpec::Core
14
-
15
14
  describe ExampleGroup do
16
15
  it_behaves_like "metadata hash builder" do
17
16
  def metadata_hash(*args)
@@ -23,7 +22,6 @@ module RSpec::Core
23
22
  context 'when RSpec.configuration.treat_symbols_as_metadata_keys_with_true_values is set to false' do
24
23
  before(:each) do
25
24
  RSpec.configure { |c| c.treat_symbols_as_metadata_keys_with_true_values = false }
26
- Kernel.stub(:warn)
27
25
  end
28
26
 
29
27
  it 'processes string args as part of the description' do
@@ -32,6 +30,7 @@ module RSpec::Core
32
30
  end
33
31
 
34
32
  it 'processes symbol args as part of the description' do
33
+ Kernel.stub(:warn) # to silence Symbols as args warning
35
34
  group = ExampleGroup.describe(:some, :separate, :symbols)
36
35
  group.description.should eq("some separate symbols")
37
36
  end
@@ -39,6 +38,7 @@ module RSpec::Core
39
38
 
40
39
  context 'when RSpec.configuration.treat_symbols_as_metadata_keys_with_true_values is set to true' do
41
40
  let(:group) { ExampleGroup.describe(:symbol) }
41
+
42
42
  before(:each) do
43
43
  RSpec.configure { |c| c.treat_symbols_as_metadata_keys_with_true_values = true }
44
44
  end
@@ -265,17 +265,17 @@ module RSpec::Core
265
265
  end
266
266
  end
267
267
 
268
- describe '#describes' do
268
+ describe '#described_class' do
269
269
 
270
270
  context "with a constant as the first parameter" do
271
271
  it "is that constant" do
272
- ExampleGroup.describe(Object) { }.describes.should eq(Object)
272
+ ExampleGroup.describe(Object) { }.described_class.should eq(Object)
273
273
  end
274
274
  end
275
275
 
276
276
  context "with a string as the first parameter" do
277
277
  it "is nil" do
278
- ExampleGroup.describe("i'm a computer") { }.describes.should be_nil
278
+ ExampleGroup.describe("i'm a computer") { }.described_class.should be_nil
279
279
  end
280
280
  end
281
281
 
@@ -284,7 +284,7 @@ module RSpec::Core
284
284
  it "is the top level constant" do
285
285
  group = ExampleGroup.describe(String) do
286
286
  describe :symbol do
287
- example "describes is String" do
287
+ example "described_class is String" do
288
288
  described_class.should eq(String)
289
289
  end
290
290
  end
@@ -311,8 +311,8 @@ module RSpec::Core
311
311
  end
312
312
 
313
313
  describe '#described_class' do
314
- it "is the same as describes" do
315
- self.class.described_class.should eq(self.class.describes)
314
+ it "is the same as described_class" do
315
+ self.class.described_class.should eq(self.class.described_class)
316
316
  end
317
317
  end
318
318
 
@@ -618,19 +618,26 @@ module RSpec::Core
618
618
  end
619
619
  end
620
620
 
621
- matcher :add_a_pending_example_with do |method_name|
622
- match do |group|
623
- group = ExampleGroup.describe
624
- group.send(method_name, "is pending") { }
625
- group.run
626
- group.examples.first.should be_pending
627
- end
628
- end
629
-
630
621
  %w[pending xit xspecify xexample].each do |method_name|
631
- describe "##{method_name}" do
622
+ describe "::#{method_name}" do
623
+ before do
624
+ @group = ExampleGroup.describe
625
+ @group.send(method_name, "is pending") { }
626
+ end
627
+
632
628
  it "generates a pending example" do
633
- ExampleGroup.describe.should add_a_pending_example_with(method_name)
629
+ @group.run
630
+ @group.examples.first.should be_pending
631
+ end
632
+
633
+ it "sets the pending message", :if => method_name == 'pending' do
634
+ @group.run
635
+ @group.examples.first.metadata[:execution_result][:pending_message].should eq(RSpec::Core::Pending::NO_REASON_GIVEN)
636
+ end
637
+
638
+ it "sets the pending message", :unless => method_name == 'pending' do
639
+ @group.run
640
+ @group.examples.first.metadata[:execution_result][:pending_message].should eq("Temporarily disabled with #{method_name}")
634
641
  end
635
642
  end
636
643
  end
@@ -667,7 +674,7 @@ module RSpec::Core
667
674
 
668
675
  describe "A sample nested group", :nested_describe => "yep" do
669
676
  it "sets the described class to the described class of the outer most group" do
670
- example.example_group.describes.should eq(ExampleGroup)
677
+ example.example_group.described_class.should eq(ExampleGroup)
671
678
  end
672
679
 
673
680
  it "sets the description to 'A sample nested describe'" do
@@ -893,54 +900,66 @@ module RSpec::Core
893
900
  end
894
901
  end
895
902
 
896
- describe "#include_context" do
897
- before do
898
- shared_context "named this" do
899
- def foo; 'foo'; end
903
+ %w[include_examples include_context].each do |name|
904
+ describe "##{name}" do
905
+ before do
906
+ shared_examples "named this" do
907
+ example("does something") {}
908
+ end
900
909
  end
901
- end
902
910
 
903
- it "includes the named context" do
904
- group = ExampleGroup.describe do
905
- include_context "named this"
906
- it "accesses foo" do
907
- foo.should eq('foo')
908
- end
911
+ it "includes the named examples" do
912
+ group = ExampleGroup.describe
913
+ group.send(name, "named this")
914
+ group.examples.first.description.should eq("does something")
909
915
  end
910
- group.run.should be_true
911
- end
912
916
 
913
- it "raises a helpful error message when shared context is not found" do
914
- expect do
915
- ExampleGroup.describe do
916
- include_context "shared stuff"
917
+ it "raises a helpful error message when shared content is not found" do
918
+ group = ExampleGroup.describe
919
+ expect do
920
+ group.send(name, "shared stuff")
921
+ end.to raise_error(ArgumentError, /Could not find .* "shared stuff"/)
922
+ end
923
+
924
+ it "passes parameters to the shared content" do
925
+ passed_params = {}
926
+
927
+ shared_examples "named this with params" do |param1, param2|
928
+ it("has access to the given parameters") do
929
+ passed_params[:param1] = param1
930
+ passed_params[:param2] = param2
931
+ end
917
932
  end
918
- end.to raise_error(ArgumentError,%q|Could not find shared context "shared stuff"|)
919
- end
920
933
 
921
- end
934
+ group = ExampleGroup.describe
935
+ group.send(name, "named this with params", :value1, :value2)
936
+ group.run
922
937
 
923
- describe "#include_examples" do
924
- before do
925
- shared_examples "named this" do
926
- example("does something") do
938
+ passed_params.should eq({ :param1 => :value1, :param2 => :value2 })
939
+ end
940
+
941
+ it "adds shared instance methods to the group" do
942
+ shared_examples "named this with params" do |param1|
943
+ def foo; end
927
944
  end
945
+ group = ExampleGroup.describe('fake group')
946
+ group.send(name, "named this with params", :a)
947
+ group.public_instance_methods.map{|m| m.to_s}.should include("foo")
928
948
  end
929
- end
930
949
 
931
- it "includes the named examples" do
932
- group = ExampleGroup.describe do
933
- include_examples "named this"
950
+ it "evals the shared example group only once" do
951
+ eval_count = 0
952
+ shared_examples("named this with params") { |p| eval_count += 1 }
953
+ group = ExampleGroup.describe('fake group')
954
+ group.send(name, "named this with params", :a)
955
+ eval_count.should eq(1)
934
956
  end
935
- group.examples.first.description.should eq("does something")
936
- end
937
957
 
938
- it "raises a helpful error message when shared context is not found" do
939
- expect do
940
- ExampleGroup.describe do
941
- include_examples "shared stuff"
942
- end
943
- end.to raise_error(ArgumentError,%q|Could not find shared examples "shared stuff"|)
958
+ it "warns the user that blocks are not supported when given a block" do
959
+ group = ExampleGroup.describe
960
+ group.should_receive(:warn).with(/blocks not supported for #{name}/)
961
+ group.send(name, "named this with block") {}
962
+ end
944
963
  end
945
964
  end
946
965
 
@@ -987,41 +1006,39 @@ module RSpec::Core
987
1006
  shared_group.methods.map{|m| m.to_s}.should include("foo")
988
1007
  end
989
1008
 
990
- context "given some parameters" do
991
- it "passes the parameters to the shared example group" do
992
- passed_params = {}
993
-
994
- shared_examples_for("thing") do |param1, param2|
995
- it("has access to the given parameters") do
996
- passed_params[:param1] = param1
997
- passed_params[:param2] = param2
998
- end
999
- end
1009
+ it "passes parameters to the shared example group" do
1010
+ passed_params = {}
1000
1011
 
1001
- group = ExampleGroup.describe("group") do
1002
- it_should_behave_like "thing", :value1, :value2
1012
+ shared_examples_for("thing") do |param1, param2|
1013
+ it("has access to the given parameters") do
1014
+ passed_params[:param1] = param1
1015
+ passed_params[:param2] = param2
1003
1016
  end
1004
- group.run
1005
-
1006
- passed_params.should eq({ :param1 => :value1, :param2 => :value2 })
1007
1017
  end
1008
1018
 
1009
- it "adds shared instance methods to nested group" do
1010
- shared_examples_for("thing") do |param1|
1011
- def foo; end
1012
- end
1013
- group = ExampleGroup.describe('fake group')
1014
- shared_group = group.it_should_behave_like("thing", :a)
1015
- shared_group.public_instance_methods.map{|m| m.to_s}.should include("foo")
1019
+ group = ExampleGroup.describe("group") do
1020
+ it_should_behave_like "thing", :value1, :value2
1016
1021
  end
1022
+ group.run
1017
1023
 
1018
- it "evals the shared example group only once" do
1019
- eval_count = 0
1020
- shared_examples_for("thing") { |p| eval_count += 1 }
1021
- group = ExampleGroup.describe('fake group')
1022
- group.it_should_behave_like("thing", :a)
1023
- eval_count.should eq(1)
1024
+ passed_params.should eq({ :param1 => :value1, :param2 => :value2 })
1025
+ end
1026
+
1027
+ it "adds shared instance methods to nested group" do
1028
+ shared_examples_for("thing") do |param1|
1029
+ def foo; end
1024
1030
  end
1031
+ group = ExampleGroup.describe('fake group')
1032
+ shared_group = group.it_should_behave_like("thing", :a)
1033
+ shared_group.public_instance_methods.map{|m| m.to_s}.should include("foo")
1034
+ end
1035
+
1036
+ it "evals the shared example group only once" do
1037
+ eval_count = 0
1038
+ shared_examples_for("thing") { |p| eval_count += 1 }
1039
+ group = ExampleGroup.describe('fake group')
1040
+ group.it_should_behave_like("thing", :a)
1041
+ eval_count.should eq(1)
1025
1042
  end
1026
1043
 
1027
1044
  context "given a block" do
@@ -29,6 +29,20 @@ describe RSpec::Core::Example, :parent_metadata => 'sample' do
29
29
  example_group.run
30
30
  example.exception.should be_nil
31
31
  end
32
+
33
+ it "returns false for pending_fixed? if not pending fixed" do
34
+ example = example_group.example { fail }
35
+ example_group.run
36
+ example.exception.should_not be_pending_fixed
37
+ end
38
+
39
+ it "returns true for pending_fixed? if pending fixed" do
40
+ example = example_group.example do
41
+ pending("fixed") {}
42
+ end
43
+ example_group.run
44
+ example.exception.should be_pending_fixed
45
+ end
32
46
  end
33
47
 
34
48
  describe "auto-generated example descriptions" do
@@ -2,52 +2,112 @@ require 'spec_helper'
2
2
 
3
3
  module RSpec::Core
4
4
  describe FilterManager do
5
- %w[inclusions include exclusions exclude].each_slice(2) do |type, name|
6
- it "merges #{type}" do
7
- filter_manager = FilterManager.new
8
- filter_manager.exclusions.clear # defaults
9
- filter_manager.send name, :foo => :bar
10
- filter_manager.send name, :baz => :bam
11
- filter_manager.send(type).should eq(:foo => :bar, :baz => :bam)
5
+ def opposite(name)
6
+ name =~ /^in/ ? name.sub(/^(in)/,'ex') : name.sub(/^(ex)/,'in')
7
+ end
8
+
9
+ %w[include inclusions exclude exclusions].each_slice(2) do |name, type|
10
+ describe "##{name}" do
11
+ it "merges #{type}" do
12
+ filter_manager = FilterManager.new
13
+ filter_manager.exclusions.clear # defaults
14
+ filter_manager.send name, :foo => :bar
15
+ filter_manager.send name, :baz => :bam
16
+ filter_manager.send(type).should eq(:foo => :bar, :baz => :bam)
17
+ end
18
+
19
+ it "overrides previous #{type} with (via merge)" do
20
+ filter_manager = FilterManager.new
21
+ filter_manager.exclusions.clear # defaults
22
+ filter_manager.send name, :foo => 1
23
+ filter_manager.send name, :foo => 2
24
+ filter_manager.send(type).should eq(:foo => 2)
25
+ end
26
+
27
+ it "deletes matching opposites" do
28
+ filter_manager = FilterManager.new
29
+ filter_manager.exclusions.clear # defaults
30
+ filter_manager.send opposite(name), :foo => 1
31
+ filter_manager.send name, :foo => 2
32
+ filter_manager.send(type).should eq(:foo => 2)
33
+ filter_manager.send(opposite(type)).should be_empty
34
+ end
12
35
  end
13
36
 
14
- it "overrides previous #{type} (via merge)" do
15
- filter_manager = FilterManager.new
16
- filter_manager.exclusions.clear # defaults
17
- filter_manager.send name, :foo => 1
18
- filter_manager.send name, :foo => 2
19
- filter_manager.send(type).should eq(:foo => 2)
37
+ describe "##{name}!" do
38
+ it "replaces existing #{type}" do
39
+ filter_manager = FilterManager.new
40
+ filter_manager.exclusions.clear # defaults
41
+ filter_manager.send name, :foo => 1, :bar => 2
42
+ filter_manager.send "#{name}!", :foo => 3
43
+ filter_manager.send(type).should eq(:foo => 3)
44
+ end
45
+
46
+ it "deletes matching opposites" do
47
+ filter_manager = FilterManager.new
48
+ filter_manager.exclusions.clear # defaults
49
+ filter_manager.send opposite(name), :foo => 1
50
+ filter_manager.send "#{name}!", :foo => 2
51
+ filter_manager.send(type).should eq(:foo => 2)
52
+ filter_manager.send(opposite(type)).should be_empty
53
+ end
20
54
  end
21
55
 
22
- it "ignores new #{type} if same key exists and priority is low" do
23
- filter_manager = FilterManager.new
24
- filter_manager.exclusions.clear # defaults
25
- filter_manager.send name, :foo => 1
26
- filter_manager.send name, :weak, :foo => 2
27
- filter_manager.send(type).should eq(:foo => 1)
56
+ describe "##{name}_with_low_priority" do
57
+ it "ignores new #{type} if same key exists" do
58
+ filter_manager = FilterManager.new
59
+ filter_manager.exclusions.clear # defaults
60
+ filter_manager.send name, :foo => 1
61
+ filter_manager.send "#{name}_with_low_priority", :foo => 2
62
+ filter_manager.send(type).should eq(:foo => 1)
63
+ end
64
+
65
+ it "ignores new #{type} if same key exists in opposite" do
66
+ filter_manager = FilterManager.new
67
+ filter_manager.exclusions.clear # defaults
68
+ filter_manager.send opposite(name), :foo => 1
69
+ filter_manager.send "#{name}_with_low_priority", :foo => 1
70
+ filter_manager.send(type).should be_empty
71
+ filter_manager.send(opposite(type)).should eq(:foo => 1)
72
+ end
73
+
74
+ it "keeps new #{type} if same key exists in opposite but values are different" do
75
+ filter_manager = FilterManager.new
76
+ filter_manager.exclusions.clear # defaults
77
+ filter_manager.send opposite(name), :foo => 1
78
+ filter_manager.send "#{name}_with_low_priority", :foo => 2
79
+ filter_manager.send(type).should eq(:foo => 2)
80
+ filter_manager.send(opposite(type)).should eq(:foo => 1)
81
+ end
28
82
  end
29
83
  end
30
84
 
31
85
  describe "#prune" do
86
+ def filterable_object_with(args = {})
87
+ object = double('a filterable object')
88
+ object.stub(:any_apply?) { |f| Metadata.new(args).any_apply?(f) }
89
+ object
90
+ end
91
+
32
92
  it "includes objects with tags matching inclusions" do
33
- included = RSpec::Core::Metadata.new({:foo => :bar})
34
- excluded = RSpec::Core::Metadata.new
93
+ included = filterable_object_with({:foo => :bar})
94
+ excluded = filterable_object_with
35
95
  filter_manager = FilterManager.new
36
96
  filter_manager.include :foo => :bar
37
97
  filter_manager.prune([included, excluded]).should eq([included])
38
98
  end
39
99
 
40
100
  it "excludes objects with tags matching exclusions" do
41
- included = RSpec::Core::Metadata.new
42
- excluded = RSpec::Core::Metadata.new({:foo => :bar})
101
+ included = filterable_object_with
102
+ excluded = filterable_object_with({:foo => :bar})
43
103
  filter_manager = FilterManager.new
44
104
  filter_manager.exclude :foo => :bar
45
105
  filter_manager.prune([included, excluded]).should eq([included])
46
106
  end
47
107
 
48
108
  it "prefers exclusion when matches previously set inclusion" do
49
- included = RSpec::Core::Metadata.new
50
- excluded = RSpec::Core::Metadata.new({:foo => :bar})
109
+ included = filterable_object_with
110
+ excluded = filterable_object_with({:foo => :bar})
51
111
  filter_manager = FilterManager.new
52
112
  filter_manager.include :foo => :bar
53
113
  filter_manager.exclude :foo => :bar
@@ -55,8 +115,8 @@ module RSpec::Core
55
115
  end
56
116
 
57
117
  it "prefers inclusion when matches previously set exclusion" do
58
- included = RSpec::Core::Metadata.new({:foo => :bar})
59
- excluded = RSpec::Core::Metadata.new
118
+ included = filterable_object_with({:foo => :bar})
119
+ excluded = filterable_object_with
60
120
  filter_manager = FilterManager.new
61
121
  filter_manager.exclude :foo => :bar
62
122
  filter_manager.include :foo => :bar
@@ -64,20 +124,20 @@ module RSpec::Core
64
124
  end
65
125
 
66
126
  it "prefers previously set inclusion when exclusion matches but has lower priority" do
67
- included = RSpec::Core::Metadata.new({:foo => :bar})
68
- excluded = RSpec::Core::Metadata.new
127
+ included = filterable_object_with({:foo => :bar})
128
+ excluded = filterable_object_with
69
129
  filter_manager = FilterManager.new
70
130
  filter_manager.include :foo => :bar
71
- filter_manager.exclude :low, :foo => :bar
131
+ filter_manager.exclude_with_low_priority :foo => :bar
72
132
  filter_manager.prune([included, excluded]).should eq([included])
73
133
  end
74
134
 
75
135
  it "prefers previously set exclusion when inclusion matches but has lower priority" do
76
- included = RSpec::Core::Metadata.new
77
- excluded = RSpec::Core::Metadata.new({:foo => :bar})
136
+ included = filterable_object_with
137
+ excluded = filterable_object_with({:foo => :bar})
78
138
  filter_manager = FilterManager.new
79
139
  filter_manager.exclude :foo => :bar
80
- filter_manager.include :low, :foo => :bar
140
+ filter_manager.include_with_low_priority :foo => :bar
81
141
  filter_manager.prune([included, excluded]).should eq([included])
82
142
  end
83
143
  end
@@ -130,12 +190,24 @@ module RSpec::Core
130
190
  filter_manager.exclude :if => :custom_filter
131
191
  end
132
192
 
193
+ it 'deprecates an :if filter overridden with low priority' do
194
+ RSpec.should_receive(:warn_deprecation).with(/exclude\(:if.*is deprecated/)
195
+ filter_manager = FilterManager.new
196
+ filter_manager.exclude_with_low_priority :if => :custom_filter
197
+ end
198
+
133
199
  it 'deprecates an overridden :unless filter' do
134
200
  RSpec.should_receive(:warn_deprecation).with(/exclude\(:unless.*is deprecated/)
135
201
  filter_manager = FilterManager.new
136
202
  filter_manager.exclude :unless => :custom_filter
137
203
  end
138
204
 
205
+ it 'deprecates an :unless filter overridden with low priority' do
206
+ RSpec.should_receive(:warn_deprecation).with(/exclude\(:unless.*is deprecated/)
207
+ filter_manager = FilterManager.new
208
+ filter_manager.exclude_with_low_priority :unless => :custom_filter
209
+ end
210
+
139
211
  it 'includes an overriden :if filter' do
140
212
  RSpec.stub(:warn_deprecation)
141
213
  filter_manager = FilterManager.new
@@ -171,5 +243,14 @@ module RSpec::Core
171
243
  filter_manager.include :full_description => "this and that"
172
244
  filter_manager.inclusions.should eq(:full_description => "this and that")
173
245
  end
246
+
247
+ [:locations, :line_numbers, :full_description].each do |filter|
248
+ it "does nothing on include if already set standalone filter #{filter}" do
249
+ filter_manager = FilterManager.new
250
+ filter_manager.include filter => "a_value"
251
+ filter_manager.include :foo => :bar
252
+ filter_manager.inclusions.should eq(filter => "a_value")
253
+ end
254
+ end
174
255
  end
175
256
  end