rspec-core 2.5.0 → 2.6.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.
Files changed (125) hide show
  1. data/.travis.yml +7 -0
  2. data/Gemfile +12 -14
  3. data/README.md +4 -1
  4. data/Rakefile +29 -12
  5. data/cucumber.yml +1 -1
  6. data/features/.nav +15 -9
  7. data/features/Autotest.md +26 -32
  8. data/features/Changelog.md +62 -2
  9. data/features/Upgrade.md +35 -2
  10. data/features/command_line/README.md +22 -0
  11. data/features/command_line/configure.feature +2 -2
  12. data/features/command_line/example_name_option.feature +10 -10
  13. data/features/command_line/exit_status.feature +4 -4
  14. data/features/command_line/format_option.feature +4 -4
  15. data/features/command_line/line_number_appended_to_path.feature +11 -11
  16. data/features/command_line/line_number_option.feature +2 -2
  17. data/features/command_line/rake_task.feature +3 -3
  18. data/features/command_line/tag.feature +30 -14
  19. data/features/configuration/alias_example_to.feature +48 -0
  20. data/features/configuration/custom_settings.feature +3 -3
  21. data/features/configuration/fail_fast.feature +3 -3
  22. data/features/configuration/read_options_from_file.feature +4 -4
  23. data/features/example_groups/basic_structure.feature +11 -15
  24. data/features/example_groups/shared_context.feature +74 -0
  25. data/features/example_groups/shared_example_group.feature +21 -17
  26. data/features/expectation_framework_integration/configure_expectation_framework.feature +15 -4
  27. data/features/filtering/exclusion_filters.feature +28 -4
  28. data/features/filtering/{implicit_filters.feature → if_and_unless.feature} +9 -7
  29. data/features/filtering/inclusion_filters.feature +26 -3
  30. data/features/filtering/run_all_when_everything_filtered.feature +2 -2
  31. data/features/formatters/custom_formatter.feature +1 -1
  32. data/features/formatters/text_formatter.feature +43 -0
  33. data/features/helper_methods/arbitrary_methods.feature +2 -2
  34. data/features/helper_methods/let.feature +2 -2
  35. data/features/helper_methods/modules.feature +149 -0
  36. data/features/hooks/around_hooks.feature +18 -11
  37. data/features/hooks/before_and_after_hooks.feature +15 -19
  38. data/features/hooks/filtering.feature +160 -124
  39. data/features/metadata/current_example.feature +17 -0
  40. data/features/metadata/described_class.feature +2 -2
  41. data/features/metadata/user_defined.feature +111 -0
  42. data/features/mock_framework_integration/use_any_framework.feature +1 -1
  43. data/features/mock_framework_integration/use_flexmock.feature +83 -10
  44. data/features/mock_framework_integration/use_mocha.feature +84 -10
  45. data/features/mock_framework_integration/use_rr.feature +85 -10
  46. data/features/mock_framework_integration/use_rspec.feature +84 -10
  47. data/features/pending/pending_examples.feature +8 -8
  48. data/features/spec_files/arbitrary_file_suffix.feature +1 -1
  49. data/features/step_definitions/additional_cli_steps.rb +11 -1
  50. data/features/subject/attribute_of_subject.feature +24 -4
  51. data/features/subject/explicit_subject.feature +5 -5
  52. data/features/subject/implicit_receiver.feature +2 -2
  53. data/features/subject/implicit_subject.feature +2 -2
  54. data/features/support/env.rb +6 -1
  55. data/lib/autotest/rspec2.rb +2 -51
  56. data/lib/rspec/core/backward_compatibility.rb +12 -2
  57. data/lib/rspec/core/command_line.rb +2 -5
  58. data/lib/rspec/core/configuration.rb +70 -38
  59. data/lib/rspec/core/configuration_options.rb +6 -23
  60. data/lib/rspec/core/drb_command_line.rb +5 -11
  61. data/lib/rspec/core/example.rb +29 -21
  62. data/lib/rspec/core/example_group.rb +40 -8
  63. data/lib/rspec/core/extensions/object.rb +0 -1
  64. data/lib/rspec/core/formatters/base_formatter.rb +6 -0
  65. data/lib/rspec/core/formatters/base_text_formatter.rb +1 -1
  66. data/lib/rspec/core/formatters/helpers.rb +0 -4
  67. data/lib/rspec/core/hooks.rb +14 -4
  68. data/lib/rspec/core/metadata.rb +1 -1
  69. data/lib/rspec/core/metadata_hash_builder.rb +93 -0
  70. data/lib/rspec/core/mocking/with_flexmock.rb +2 -0
  71. data/lib/rspec/core/mocking/with_mocha.rb +2 -0
  72. data/lib/rspec/core/mocking/with_rr.rb +2 -0
  73. data/lib/rspec/core/mocking/with_rspec.rb +3 -1
  74. data/lib/rspec/core/option_parser.rb +9 -2
  75. data/lib/rspec/core/pending.rb +10 -3
  76. data/lib/rspec/core/reporter.rb +2 -2
  77. data/lib/rspec/core/runner.rb +38 -13
  78. data/lib/rspec/core/shared_example_group.rb +18 -4
  79. data/lib/rspec/core/subject.rb +4 -6
  80. data/lib/rspec/core/version.rb +1 -1
  81. data/lib/rspec/core/world.rb +70 -18
  82. data/lib/rspec/core.rb +29 -0
  83. data/lib/rspec/monkey/spork/test_framework/rspec.rb +1 -0
  84. data/rspec-core.gemspec +3 -5
  85. data/spec/autotest/failed_results_re_spec.rb +2 -2
  86. data/spec/autotest/rspec_spec.rb +4 -126
  87. data/spec/rspec/core/command_line_spec.rb +36 -2
  88. data/spec/rspec/core/configuration_spec.rb +150 -70
  89. data/spec/rspec/core/deprecations_spec.rb +21 -0
  90. data/spec/rspec/core/drb_command_line_spec.rb +21 -56
  91. data/spec/rspec/core/example_group_spec.rb +213 -56
  92. data/spec/rspec/core/example_spec.rb +110 -0
  93. data/spec/rspec/core/formatters/base_formatter_spec.rb +23 -2
  94. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +9 -0
  95. data/spec/rspec/core/formatters/helpers_spec.rb +1 -1
  96. data/spec/rspec/core/formatters/html_formatted-1.8.6.html +5 -5
  97. data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +8 -10
  98. data/spec/rspec/core/formatters/html_formatted-1.8.7.html +5 -5
  99. data/spec/rspec/core/formatters/html_formatted-1.9.1.html +5 -5
  100. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +5 -5
  101. data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -1
  102. data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +5 -5
  103. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +8 -10
  104. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +5 -5
  105. data/spec/rspec/core/formatters/text_mate_formatted-1.9.1.html +5 -5
  106. data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +5 -5
  107. data/spec/rspec/core/hooks_spec.rb +86 -0
  108. data/spec/rspec/core/metadata_spec.rb +7 -7
  109. data/spec/rspec/core/option_parser_spec.rb +26 -15
  110. data/spec/rspec/core/pending_example_spec.rb +12 -51
  111. data/spec/rspec/core/reporter_spec.rb +19 -3
  112. data/spec/rspec/core/resources/formatter_specs.rb +7 -1
  113. data/spec/rspec/core/rspec_matchers_spec.rb +45 -0
  114. data/spec/rspec/core/runner_spec.rb +42 -10
  115. data/spec/rspec/core/shared_example_group_spec.rb +57 -21
  116. data/spec/rspec/core/subject_spec.rb +32 -11
  117. data/spec/rspec/core/world_spec.rb +147 -15
  118. data/spec/rspec/core_spec.rb +28 -0
  119. data/spec/spec_helper.rb +22 -2
  120. data/spec/support/matchers.rb +44 -13
  121. data/spec/support/shared_example_groups.rb +41 -0
  122. data/spec/support/spec_files.rb +44 -0
  123. data/spec.txt +1126 -0
  124. metadata +34 -15
  125. data/spec/ruby_forker.rb +0 -13
@@ -6,135 +6,13 @@ describe Autotest::Rspec2 do
6
6
  let(:ruby_cmd) { "ruby" }
7
7
 
8
8
  before do
9
- RSpec.stub(:warn_deprecation)
10
9
  File.stub(:exist?) { false }
11
- @orig_argv = ARGV.dup; ARGV.clear
12
10
  end
13
11
 
14
- after { ARGV.clear; ARGV.concat(@orig_argv) }
15
-
16
- context "with ARGV" do
17
- it "passes ARGV to command" do
18
- ARGV.concat(%w[-c -f d])
19
- rspec_autotest.cl_args.should eq(%w[-c -f d --tty])
20
- end
21
-
22
- context "with --skip-bundler" do
23
- before do
24
- ARGV.concat(%w[--skip-bundler])
25
- end
26
- it "extracts --skip-bundler" do
27
- rspec_autotest.cl_args.should eq(%w[--tty])
28
- end
29
-
30
- it "sets skip_bundler? true" do
31
- rspec_autotest.skip_bundler?.should be_true
32
- end
33
- end
34
- end
35
-
36
- describe "handling bundler" do
37
- context "gemfile, no prefix" do
38
- before do
39
- File.stub(:exist?).with("./Gemfile") { true }
40
- end
41
-
42
- it "warns of deprecation of implicit inclusion of 'bundle exec'" do
43
- RSpec.should_receive(:warn_deprecation)
44
- rspec_autotest.make_test_cmd({})
45
- end
46
-
47
- it "includes bundle exec" do
48
- rspec_autotest.
49
- make_test_cmd({'a' => 'b'}).should match(/bundle exec/)
50
- end
51
- end
52
-
53
- context "gemfile, no prefix, --skip-bundler" do
54
- before do
55
- File.stub(:exist?).with("./Gemfile") { true }
56
- ARGV.concat(%w[--skip-bundler])
57
- end
58
-
59
- it "does not warn" do
60
- RSpec.should_not_receive(:warn_deprecation)
61
- rspec_autotest.make_test_cmd({})
62
- end
63
-
64
- it "does not include bundle exec" do
65
- rspec_autotest.
66
- make_test_cmd({'a' => 'b'}).should_not match(/bundle exec/)
67
- end
68
- end
69
-
70
- context "no gemfile, prefix" do
71
- before do
72
- File.stub(:exist?).with("./Gemfile") { false }
73
- end
74
-
75
- it "does not warn" do
76
- RSpec.should_not_receive(:warn_deprecation)
77
- rspec_autotest.make_test_cmd({'a' => 'b'})
78
- end
79
-
80
- it "includes bundle exec" do
81
- rspec_autotest.prefix = "bundle exec "
82
- rspec_autotest.
83
- make_test_cmd({'a' => 'b'}).should match(/bundle exec/)
84
- end
85
- end
86
-
87
- context "gemfile, prefix" do
88
- before do
89
- File.stub(:exist?).with("./Gemfile") { true }
90
- rspec_autotest.prefix = "bundle exec "
91
- end
92
-
93
- it "does not warn" do
94
- RSpec.should_not_receive(:warn_deprecation)
95
- rspec_autotest.make_test_cmd({'a' => 'b'})
96
- end
97
-
98
- it "includes bundle exec" do
99
- rspec_autotest.prefix = "bundle exec "
100
- rspec_autotest.
101
- make_test_cmd({'a' => 'b'}).should match(/bundle exec/)
102
- end
103
- end
104
-
105
- context "gemfile, prefix, --skip-bundler" do
106
- before do
107
- File.stub(:exist?).with("./Gemfile") { true }
108
- rspec_autotest.prefix = "bundle exec "
109
- rspec_autotest.stub(:skip_bundler?) { true }
110
- end
111
-
112
- it "does not warn" do
113
- RSpec.should_not_receive(:warn_deprecation)
114
- rspec_autotest.make_test_cmd({'a' => 'b'})
115
- end
116
-
117
- it "does not include bundle exec" do
118
- rspec_autotest.
119
- make_test_cmd({'a' => 'b'}).should_not match(/bundle exec/)
120
- end
121
- end
122
-
123
- context "no gemfile, no prefix" do
124
- before do
125
- File.stub(:exist?).with("./Gemfile") { false }
126
- end
127
-
128
- it "does not warn" do
129
- RSpec.should_not_receive(:warn_deprecation)
130
- rspec_autotest.make_test_cmd({'a' => 'b'})
131
- end
132
-
133
- it "does not include bundle exec" do
134
- rspec_autotest.
135
- make_test_cmd({'a' => 'b'}).should_not match(/bundle exec/)
136
- end
137
- end
12
+ it "uses autotest's prefix" do
13
+ rspec_autotest.prefix = "this is the prefix "
14
+ rspec_autotest.
15
+ make_test_cmd({'a' => 'b'}).should match(/this is the prefix/)
138
16
  end
139
17
 
140
18
  describe "commands" do
@@ -4,6 +4,42 @@ require 'tmpdir'
4
4
 
5
5
  module RSpec::Core
6
6
  describe CommandLine do
7
+
8
+ describe "#run" do
9
+ include_context "spec files"
10
+
11
+ let(:out) { StringIO.new }
12
+ let(:err) { StringIO.new }
13
+
14
+ def config_options(argv=[])
15
+ options = RSpec::Core::ConfigurationOptions.new(argv)
16
+ options.parse_options
17
+ options
18
+ end
19
+
20
+ def command_line(args)
21
+ RSpec::Core::CommandLine.new(config_options(args))
22
+ end
23
+
24
+ def config_options(argv=[])
25
+ options = RSpec::Core::ConfigurationOptions.new(argv)
26
+ options.parse_options
27
+ options
28
+ end
29
+
30
+ it "returns 0 if spec passes" do
31
+ err, out = StringIO.new, StringIO.new
32
+ result = command_line([passing_spec_filename]).run(err, out)
33
+ result.should be(0)
34
+ end
35
+
36
+ it "returns 1 if spec passes" do
37
+ err, out = StringIO.new, StringIO.new
38
+ result = command_line([failing_spec_filename]).run(err, out)
39
+ result.should be(1)
40
+ end
41
+ end
42
+
7
43
  context "given an Array of options" do
8
44
  it "assigns ConfigurationOptions built from Array to @options" do
9
45
  config_options = ConfigurationOptions.new(%w[--color])
@@ -50,8 +86,6 @@ module RSpec::Core
50
86
  config.stub(:run_hook)
51
87
 
52
88
  config.should_receive(:load_spec_files)
53
- config.should_receive(:configure_mock_framework)
54
- config.should_receive(:configure_expectation_framework)
55
89
 
56
90
  world.should_receive(:announce_inclusion_filter)
57
91
  world.should_receive(:announce_exclusion_filter)
@@ -5,7 +5,7 @@ module RSpec::Core
5
5
 
6
6
  describe Configuration do
7
7
 
8
- let(:config) { subject }
8
+ let(:config) { Configuration.new }
9
9
 
10
10
  describe "#load_spec_files" do
11
11
 
@@ -30,6 +30,17 @@ module RSpec::Core
30
30
  end
31
31
  end
32
32
 
33
+ describe "#treat_symbols_as_metadata_keys_with_true_values?" do
34
+ it 'defaults to false' do
35
+ config.treat_symbols_as_metadata_keys_with_true_values?.should be_false
36
+ end
37
+
38
+ it 'can be set to true' do
39
+ config.treat_symbols_as_metadata_keys_with_true_values = true
40
+ config.treat_symbols_as_metadata_keys_with_true_values?.should be_true
41
+ end
42
+ end
43
+
33
44
  describe "#mock_framework" do
34
45
  it "defaults to :rspec" do
35
46
  config.should_receive(:require).with('rspec/core/mocking/with_rspec')
@@ -100,16 +111,46 @@ module RSpec::Core
100
111
  end
101
112
  end
102
113
 
103
- context "setting the files to run" do
114
+ describe "#expecting_with_rspec?" do
115
+ before(:each) do
116
+ # prevent minitest assertions from being required and included,
117
+ # as that causes problems in some of our specs.
118
+ config.stub(:require)
119
+ end
120
+
121
+ it "returns false by default" do
122
+ config.should_not be_expecting_with_rspec
123
+ end
124
+
125
+ it "returns true when `expect_with :rspec` has been configured" do
126
+ config.expect_with :rspec
127
+ config.should be_expecting_with_rspec
128
+ end
129
+
130
+ it "returns true when `expect_with :rspec, :stdlib` has been configured" do
131
+ config.expect_with :rspec, :stdlib
132
+ config.should be_expecting_with_rspec
133
+ end
134
+
135
+ it "returns true when `expect_with :stdlib, :rspec` has been configured" do
136
+ config.expect_with :stdlib, :rspec
137
+ config.should be_expecting_with_rspec
138
+ end
104
139
 
140
+ it "returns false when `expect_with :stdlib` has been configured" do
141
+ config.expect_with :stdlib
142
+ config.should_not be_expecting_with_rspec
143
+ end
144
+ end
145
+
146
+ describe "#files_to_run" do
105
147
  it "loads files not following pattern if named explicitly" do
106
148
  file = "./spec/rspec/core/resources/a_bar.rb"
107
149
  config.files_or_directories_to_run = file
108
150
  config.files_to_run.should == [file]
109
151
  end
110
152
 
111
- describe "with default --pattern" do
112
-
153
+ context "with default pattern" do
113
154
  it "loads files named _spec.rb" do
114
155
  dir = "./spec/rspec/core/resources"
115
156
  config.files_or_directories_to_run = dir
@@ -121,80 +162,70 @@ module RSpec::Core
121
162
  config.files_or_directories_to_run = file
122
163
  config.files_to_run.should == [file]
123
164
  end
124
-
125
165
  end
166
+ end
126
167
 
127
- describe "with explicit pattern (single)" do
168
+ %w[pattern= filename_pattern=].each do |setter|
169
+ describe "##{setter}" do
170
+ context "with single pattern" do
171
+ before { config.send(setter, "**/*_foo.rb") }
172
+ it "loads files following pattern" do
173
+ file = File.expand_path(File.dirname(__FILE__) + "/resources/a_foo.rb")
174
+ config.files_or_directories_to_run = file
175
+ config.files_to_run.should include(file)
176
+ end
128
177
 
129
- before do
130
- config.filename_pattern = "**/*_foo.rb"
131
- end
178
+ it "loads files in directories following pattern" do
179
+ dir = File.expand_path(File.dirname(__FILE__) + "/resources")
180
+ config.files_or_directories_to_run = dir
181
+ config.files_to_run.should include("#{dir}/a_foo.rb")
182
+ end
132
183
 
133
- it "loads files following pattern" do
134
- file = File.expand_path(File.dirname(__FILE__) + "/resources/a_foo.rb")
135
- config.files_or_directories_to_run = file
136
- config.files_to_run.should include(file)
184
+ it "does not load files in directories not following pattern" do
185
+ dir = File.expand_path(File.dirname(__FILE__) + "/resources")
186
+ config.files_or_directories_to_run = dir
187
+ config.files_to_run.should_not include("#{dir}/a_bar.rb")
188
+ end
137
189
  end
138
190
 
139
- it "loads files in directories following pattern" do
140
- dir = File.expand_path(File.dirname(__FILE__) + "/resources")
141
- config.files_or_directories_to_run = dir
142
- config.files_to_run.should include("#{dir}/a_foo.rb")
143
- end
191
+ context "with multiple patterns" do
192
+ it "supports comma separated values" do
193
+ config.send(setter, "**/*_foo.rb,**/*_bar.rb")
194
+ dir = File.expand_path(File.dirname(__FILE__) + "/resources")
195
+ config.files_or_directories_to_run = dir
196
+ config.files_to_run.should include("#{dir}/a_foo.rb")
197
+ config.files_to_run.should include("#{dir}/a_bar.rb")
198
+ end
144
199
 
145
- it "does not load files in directories not following pattern" do
146
- dir = File.expand_path(File.dirname(__FILE__) + "/resources")
147
- config.files_or_directories_to_run = dir
148
- config.files_to_run.should_not include("#{dir}/a_bar.rb")
200
+ it "supports comma separated values with spaces" do
201
+ config.send(setter, "**/*_foo.rb, **/*_bar.rb")
202
+ dir = File.expand_path(File.dirname(__FILE__) + "/resources")
203
+ config.files_or_directories_to_run = dir
204
+ config.files_to_run.should include("#{dir}/a_foo.rb")
205
+ config.files_to_run.should include("#{dir}/a_bar.rb")
206
+ end
149
207
  end
150
-
151
208
  end
209
+ end
152
210
 
153
- context "with explicit pattern (comma,separated,values)" do
154
-
155
- before do
156
- config.filename_pattern = "**/*_foo.rb,**/*_bar.rb"
157
- end
158
-
159
- it "supports comma separated values" do
160
- dir = File.expand_path(File.dirname(__FILE__) + "/resources")
161
- config.files_or_directories_to_run = dir
162
- config.files_to_run.should include("#{dir}/a_foo.rb")
163
- config.files_to_run.should include("#{dir}/a_bar.rb")
164
- end
165
-
166
- it "supports comma separated values with spaces" do
167
- dir = File.expand_path(File.dirname(__FILE__) + "/resources")
168
- config.files_or_directories_to_run = dir
169
- config.files_to_run.should include("#{dir}/a_foo.rb")
170
- config.files_to_run.should include("#{dir}/a_bar.rb")
171
- end
172
-
211
+ describe "path with line number" do
212
+ it "assigns the line number as the filter" do
213
+ config.files_or_directories_to_run = "path/to/a_spec.rb:37"
214
+ config.filter.should == {:line_number => 37}
173
215
  end
216
+ end
174
217
 
175
- context "with line number" do
176
-
177
- it "assigns the line number as the filter" do
178
- config.files_or_directories_to_run = "path/to/a_spec.rb:37"
179
- config.filter.should == {:line_number => 37}
180
- end
181
-
218
+ context "with full_description" do
219
+ it "overrides :focused" do
220
+ config.filter_run :focused => true
221
+ config.full_description = "foo"
222
+ config.filter.should_not have_key(:focused)
182
223
  end
183
224
 
184
- context "with full_description" do
185
- it "overrides :focused" do
186
- config.filter_run :focused => true
187
- config.full_description = "foo"
188
- config.filter.should_not have_key(:focused)
189
- end
190
-
191
- it "assigns the example name as the filter on description" do
192
- config.full_description = "foo"
193
- config.filter.should == {:full_description => /foo/}
194
- end
195
-
225
+ it "assigns the example name as the filter on description" do
226
+ config.full_description = "foo"
227
+ config.filter.should == {:full_description => /foo/}
196
228
  end
197
-
198
229
  end
199
230
 
200
231
  describe "#include" do
@@ -205,6 +236,13 @@ module RSpec::Core
205
236
  end
206
237
  end
207
238
 
239
+ it_behaves_like "metadata hash builder" do
240
+ def metadata_hash(*args)
241
+ config.include(InstanceLevelMethods, *args)
242
+ config.include_or_extend_modules.last.last
243
+ end
244
+ end
245
+
208
246
  context "with no filter" do
209
247
  it "includes the given module into each example group" do
210
248
  RSpec.configure do |c|
@@ -238,6 +276,13 @@ module RSpec::Core
238
276
  end
239
277
  end
240
278
 
279
+ it_behaves_like "metadata hash builder" do
280
+ def metadata_hash(*args)
281
+ config.extend(ThatThingISentYou, *args)
282
+ config.include_or_extend_modules.last.last
283
+ end
284
+ end
285
+
241
286
  it "extends the given module into each matching example group" do
242
287
  RSpec.configure do |c|
243
288
  c.extend(ThatThingISentYou, :magic_key => :extend)
@@ -249,7 +294,7 @@ module RSpec::Core
249
294
 
250
295
  end
251
296
 
252
- describe "run_all_when_everything_filtered?" do
297
+ describe "#run_all_when_everything_filtered?" do
253
298
 
254
299
  it "defaults to false" do
255
300
  config.run_all_when_everything_filtered?.should be_false
@@ -350,14 +395,14 @@ module RSpec::Core
350
395
  end
351
396
  end
352
397
 
353
- describe 'formatter=' do
398
+ describe '#formatter=' do
354
399
  it "delegates to add_formatter (better API for user-facing configuration)" do
355
400
  config.should_receive(:add_formatter).with('these','options')
356
401
  config.add_formatter('these','options')
357
402
  end
358
403
  end
359
404
 
360
- describe "add_formatter" do
405
+ describe "#add_formatter" do
361
406
 
362
407
  it "adds to the list of formatters" do
363
408
  config.add_formatter :documentation
@@ -421,6 +466,13 @@ module RSpec::Core
421
466
  end
422
467
 
423
468
  describe "#filter_run" do
469
+ it_behaves_like "metadata hash builder" do
470
+ def metadata_hash(*args)
471
+ config.filter_run *args
472
+ config.filter
473
+ end
474
+ end
475
+
424
476
  it "sets the filter" do
425
477
  config.filter_run :focus => true
426
478
  config.filter[:focus].should == true
@@ -454,6 +506,13 @@ module RSpec::Core
454
506
  end
455
507
 
456
508
  describe "#filter_run_excluding" do
509
+ it_behaves_like "metadata hash builder" do
510
+ def metadata_hash(*args)
511
+ config.filter_run_excluding *args
512
+ config.exclusion_filter
513
+ end
514
+ end
515
+
457
516
  it "sets the filter" do
458
517
  config.filter_run_excluding :slow => true
459
518
  config.exclusion_filter[:slow].should == true
@@ -502,7 +561,7 @@ module RSpec::Core
502
561
  end
503
562
  end
504
563
 
505
- describe "line_number=" do
564
+ describe "#line_number=" do
506
565
  before { config.stub(:warn) }
507
566
 
508
567
  it "sets the line number" do
@@ -524,9 +583,18 @@ module RSpec::Core
524
583
  end
525
584
 
526
585
  describe "#full_backtrace=" do
527
- it "clears the backtrace clean patterns" do
528
- config.full_backtrace = true
529
- config.backtrace_clean_patterns.should == []
586
+ context "given true" do
587
+ it "clears the backtrace clean patterns" do
588
+ config.full_backtrace = true
589
+ config.backtrace_clean_patterns.should == []
590
+ end
591
+ end
592
+
593
+ context "given false" do
594
+ it "restores backtrace clean patterns" do
595
+ config.full_backtrace = false
596
+ config.backtrace_clean_patterns.should == RSpec::Core::Configuration::DEFAULT_BACKTRACE_PATTERNS
597
+ end
530
598
  end
531
599
 
532
600
  it "doesn't impact other instances of config" do
@@ -712,5 +780,17 @@ module RSpec::Core
712
780
  group.included_modules.should include(mod2)
713
781
  end
714
782
  end
783
+
784
+ describe "#alias_example_to" do
785
+ it_behaves_like "metadata hash builder" do
786
+ def metadata_hash(*args)
787
+ config.alias_example_to :my_example, *args
788
+ group = ExampleGroup.describe("group")
789
+ example = group.my_example("description")
790
+ example.metadata
791
+ end
792
+ end
793
+ end
794
+
715
795
  end
716
796
  end
@@ -11,6 +11,16 @@ describe "deprecations" do
11
11
  RSpec.stub(:warn_deprecation)
12
12
  Spec.should == RSpec
13
13
  end
14
+
15
+ it "doesn't include backward compatibility in const_missing backtrace" do
16
+ RSpec.stub(:warn_deprecation)
17
+ exception = nil
18
+ begin
19
+ ConstantThatDoesNotExist
20
+ rescue Exception => exception
21
+ end
22
+ exception.backtrace.find { |l| l =~ /lib\/rspec\/core\/backward_compatibility/ }.should be_nil
23
+ end
14
24
  end
15
25
 
16
26
  describe RSpec::Core::ExampleGroup do
@@ -41,5 +51,16 @@ describe "deprecations" do
41
51
  RSpec.should_receive(:deprecate)
42
52
  Spec::Rake::SpecTask
43
53
  end
54
+
55
+ it "doesn't include backward compatibility in const_missing backtrace" do
56
+ RSpec.stub(:warn_deprecation)
57
+ exception = nil
58
+ begin
59
+ Spec::Rake::ConstantThatDoesNotExist
60
+ rescue Exception => exception
61
+ end
62
+ exception.backtrace.find { |l| l =~ /lib\/rspec\/core\/backward_compatibility/ }.should be_nil
63
+ end
44
64
  end
65
+
45
66
  end