rspec-core 2.6.0 → 2.7.0.rc1

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 (113) hide show
  1. data/README.md +1 -1
  2. data/features/Upgrade.md +11 -0
  3. data/features/command_line/exit_status.feature +20 -3
  4. data/features/command_line/format_option.feature +8 -0
  5. data/features/command_line/line_number_appended_to_path.feature +35 -1
  6. data/features/command_line/line_number_option.feature +16 -3
  7. data/features/command_line/pattern_option.feature +31 -0
  8. data/features/command_line/rake_task.feature +1 -1
  9. data/features/command_line/ruby.feature +22 -0
  10. data/features/configuration/default_path.feature +38 -0
  11. data/features/example_groups/{shared_example_group.feature → shared_examples.feature} +49 -26
  12. data/features/expectation_framework_integration/configure_expectation_framework.feature +1 -1
  13. data/features/filtering/inclusion_filters.feature +4 -5
  14. data/features/formatters/text_formatter.feature +16 -13
  15. data/features/helper_methods/let.feature +4 -4
  16. data/features/hooks/around_hooks.feature +1 -1
  17. data/features/hooks/before_and_after_hooks.feature +3 -3
  18. data/features/hooks/filtering.feature +13 -6
  19. data/features/metadata/user_defined.feature +12 -10
  20. data/features/pending/pending_examples.feature +21 -8
  21. data/features/step_definitions/additional_cli_steps.rb +1 -1
  22. data/features/subject/attribute_of_subject.feature +2 -2
  23. data/features/support/env.rb +1 -2
  24. data/lib/rspec/core/backward_compatibility.rb +1 -1
  25. data/lib/rspec/core/configuration.rb +71 -16
  26. data/lib/rspec/core/configuration_options.rb +46 -16
  27. data/lib/rspec/core/{extensions/object.rb → dsl.rb} +2 -4
  28. data/lib/rspec/core/example.rb +10 -7
  29. data/lib/rspec/core/example_group.rb +34 -18
  30. data/lib/rspec/core/expecting/with_rspec.rb +0 -2
  31. data/lib/rspec/core/extensions.rb +0 -1
  32. data/lib/rspec/core/formatters/base_formatter.rb +8 -4
  33. data/lib/rspec/core/formatters/base_text_formatter.rb +38 -18
  34. data/lib/rspec/core/formatters/html_formatter.rb +3 -1
  35. data/lib/rspec/core/formatters/snippet_extractor.rb +9 -3
  36. data/lib/rspec/core/formatters/text_mate_formatter.rb +20 -6
  37. data/lib/rspec/core/hooks.rb +7 -6
  38. data/lib/rspec/core/let.rb +5 -5
  39. data/lib/rspec/core/metadata.rb +136 -94
  40. data/lib/rspec/core/metadata_hash_builder.rb +1 -1
  41. data/lib/rspec/core/option_parser.rb +11 -7
  42. data/lib/rspec/core/pending.rb +2 -1
  43. data/lib/rspec/core/rake_task.rb +26 -15
  44. data/lib/rspec/core/reporter.rb +5 -6
  45. data/lib/rspec/core/runner.rb +1 -1
  46. data/lib/rspec/core/shared_example_group.rb +4 -4
  47. data/lib/rspec/core/subject.rb +7 -7
  48. data/lib/rspec/core/version.rb +1 -1
  49. data/lib/rspec/core/world.rb +9 -13
  50. data/lib/rspec/core.rb +14 -21
  51. data/spec/autotest/discover_spec.rb +2 -2
  52. data/spec/autotest/failed_results_re_spec.rb +29 -21
  53. data/spec/autotest/rspec_spec.rb +3 -3
  54. data/spec/rspec/core/command_line_spec.rb +1 -6
  55. data/spec/rspec/core/configuration_options_spec.rb +111 -27
  56. data/spec/rspec/core/configuration_spec.rb +161 -37
  57. data/spec/rspec/core/deprecations_spec.rb +2 -2
  58. data/spec/rspec/core/drb_command_line_spec.rb +6 -6
  59. data/spec/rspec/core/example_group_spec.rb +197 -61
  60. data/spec/rspec/core/example_spec.rb +33 -16
  61. data/spec/rspec/core/formatters/base_formatter_spec.rb +3 -3
  62. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +222 -71
  63. data/spec/rspec/core/formatters/helpers_spec.rb +8 -8
  64. data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +90 -26
  65. data/spec/rspec/core/formatters/html_formatted-1.8.7.html +12 -11
  66. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +12 -11
  67. data/spec/rspec/core/formatters/{html_formatted-1.9.1.html → html_formatted-1.9.3.html} +12 -11
  68. data/spec/rspec/core/formatters/html_formatter_spec.rb +5 -5
  69. data/spec/rspec/core/formatters/progress_formatter_spec.rb +2 -2
  70. data/spec/rspec/core/formatters/snippet_extractor_spec.rb +2 -2
  71. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +91 -27
  72. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +13 -12
  73. data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +29 -28
  74. data/spec/rspec/core/formatters/{text_mate_formatted-1.9.1.html → text_mate_formatted-1.9.3.html} +29 -28
  75. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +2 -2
  76. data/spec/rspec/core/hooks_filtering_spec.rb +18 -18
  77. data/spec/rspec/core/let_spec.rb +19 -6
  78. data/spec/rspec/core/metadata_spec.rb +146 -61
  79. data/spec/rspec/core/pending_example_spec.rb +4 -4
  80. data/spec/rspec/core/rake_task_spec.rb +71 -50
  81. data/spec/rspec/core/reporter_spec.rb +2 -2
  82. data/spec/rspec/core/ruby_project_spec.rb +2 -2
  83. data/spec/rspec/core/runner_spec.rb +4 -1
  84. data/spec/rspec/core/shared_example_group_spec.rb +15 -119
  85. data/spec/rspec/core/subject_spec.rb +13 -13
  86. data/spec/rspec/core/world_spec.rb +31 -22
  87. data/spec/rspec/core_spec.rb +1 -29
  88. data/spec/spec_helper.rb +51 -50
  89. data/spec/support/shared_example_groups.rb +3 -3
  90. data/spec/support/spec_files.rb +8 -8
  91. metadata +79 -94
  92. data/.document +0 -5
  93. data/.gitignore +0 -12
  94. data/.rspec +0 -0
  95. data/.travis.yml +0 -7
  96. data/Gemfile +0 -50
  97. data/Guardfile +0 -5
  98. data/License.txt +0 -23
  99. data/Rakefile +0 -89
  100. data/cucumber.yml +0 -2
  101. data/features/.nav +0 -57
  102. data/features/Changelog.md +0 -269
  103. data/rspec-core.gemspec +0 -24
  104. data/script/FullBuildRakeFile +0 -63
  105. data/script/console +0 -8
  106. data/script/cucumber +0 -1
  107. data/script/full_build +0 -1
  108. data/script/spec +0 -1
  109. data/spec/rspec/core/formatters/html_formatted-1.8.6.html +0 -398
  110. data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +0 -398
  111. data/spec.txt +0 -1126
  112. /data/{bin → exe}/autospec +0 -0
  113. /data/{bin → exe}/rspec +0 -0
@@ -14,6 +14,17 @@ describe RSpec::Core::ConfigurationOptions do
14
14
  config_options_object(*args).options
15
15
  end
16
16
 
17
+ it "warns when HOME env var is not set", :unless => (RUBY_PLATFORM == 'java') do
18
+ begin
19
+ orig_home = ENV.delete("HOME")
20
+ coo = RSpec::Core::ConfigurationOptions.new([])
21
+ coo.should_receive(:warn)
22
+ coo.parse_options
23
+ ensure
24
+ ENV["HOME"] = orig_home
25
+ end
26
+ end
27
+
17
28
  describe "#configure" do
18
29
  it "sends libs before requires" do
19
30
  opts = config_options_object(*%w[--require a/path -I a/lib])
@@ -30,6 +41,29 @@ describe RSpec::Core::ConfigurationOptions do
30
41
  config.should_receive(:add_formatter).ordered
31
42
  opts.configure(config)
32
43
  end
44
+
45
+ it "sends default_path before files_or_directories_to_run" do
46
+ opts = config_options_object(*%w[--default_path spec])
47
+ config = double("config").as_null_object
48
+ config.should_receive(:default_path=).ordered
49
+ config.should_receive(:files_or_directories_to_run=).ordered
50
+ opts.configure(config)
51
+ end
52
+
53
+ it "sends pattern before files_or_directories_to_run" do
54
+ opts = config_options_object(*%w[--pattern **/*.spec])
55
+ config = double("config").as_null_object
56
+ config.should_receive(:pattern=).ordered
57
+ config.should_receive(:files_or_directories_to_run=).ordered
58
+ opts.configure(config)
59
+ end
60
+
61
+ it "merges the :exclusion_filter option with the default exclusion_filter" do
62
+ opts = config_options_object(*%w[--tag ~slow])
63
+ config = RSpec::Core::Configuration.new
64
+ opts.configure(config)
65
+ config.exclusion_filter.should have_key(:slow)
66
+ end
33
67
  end
34
68
 
35
69
  describe "-c, --color, and --colour" do
@@ -44,6 +78,14 @@ describe RSpec::Core::ConfigurationOptions do
44
78
  it "sets :color_enabled => false" do
45
79
  parse_options('--no-color').should include(:color_enabled => false)
46
80
  end
81
+
82
+ it "overrides previous :color_enabled => true" do
83
+ parse_options('--color', '--no-color').should include(:color_enabled => false)
84
+ end
85
+
86
+ it "gets overriden by a subsequent :color_enabled => true" do
87
+ parse_options('--no-color', '--color').should include(:color_enabled => true)
88
+ end
47
89
  end
48
90
 
49
91
  describe "-I" do
@@ -85,8 +127,13 @@ describe RSpec::Core::ConfigurationOptions do
85
127
 
86
128
  describe '--line_number' do
87
129
  it "sets :line_number" do
88
- parse_options('-l','3').should include(:line_number => '3')
89
- parse_options('--line_number','3').should include(:line_number => '3')
130
+ parse_options('-l','3').should include(:line_numbers => ['3'])
131
+ parse_options('--line_number','3').should include(:line_numbers => ['3'])
132
+ end
133
+
134
+ it "can be specified multiple times" do
135
+ parse_options('-l','3', '-l', '6').should include(:line_numbers => ['3', '6'])
136
+ parse_options('--line_number','3', '--line_number', '6').should include(:line_numbers => ['3', '6'])
90
137
  end
91
138
  end
92
139
 
@@ -165,6 +212,21 @@ describe RSpec::Core::ConfigurationOptions do
165
212
 
166
213
  end
167
214
 
215
+ describe "--no-drb" do
216
+ it "disables drb" do
217
+ parse_options("--no-drb").should include(:drb => false)
218
+ end
219
+
220
+ it "overrides a previous drb => true" do
221
+ parse_options("--drb", "--no-drb").should include(:drb => false)
222
+ end
223
+
224
+ it "gets overriden by a subsquent drb => true" do
225
+ parse_options("--no-drb", "--drb").should include(:drb => true)
226
+ end
227
+ end
228
+
229
+
168
230
  describe "files_or_directories_to_run" do
169
231
  it "parses files from '-c file.rb dir/file.rb'" do
170
232
  parse_options("-c", "file.rb", "dir/file.rb").should include(:files_or_directories_to_run => ["file.rb", "dir/file.rb"])
@@ -185,9 +247,17 @@ describe RSpec::Core::ConfigurationOptions do
185
247
 
186
248
  it "parses dir and files from 'spec/file1_spec.rb, spec/file2_spec.rb'" do
187
249
  parse_options("dir", "spec/file1_spec.rb", "spec/file2_spec.rb").should include(:files_or_directories_to_run => ["dir", "spec/file1_spec.rb", "spec/file2_spec.rb"])
188
-
189
250
  end
251
+ end
190
252
 
253
+ describe "default_path" do
254
+ it "gets set before files_or_directories_to_run" do
255
+ config = double("config").as_null_object
256
+ config.should_receive(:default_path=).ordered
257
+ config.should_receive(:files_or_directories_to_run=).ordered
258
+ opts = config_options_object("--default_path", "foo")
259
+ opts.configure(config)
260
+ end
191
261
  end
192
262
 
193
263
  # TODO ensure all options are output
@@ -205,17 +275,38 @@ describe RSpec::Core::ConfigurationOptions do
205
275
  config_options_object(*%w[--options custom.opts]).drb_argv.should include("--options", "custom.opts")
206
276
  end
207
277
 
278
+ context "with --example" do
279
+ it "includes --example" do
280
+ config_options_object(*%w[--example foo]).drb_argv.should include("--example", "foo")
281
+ end
282
+
283
+ it "unescapes characters which were escaped upon storing --example originally" do
284
+ config_options_object("--example", "foo\\ bar").drb_argv.should include("--example", "foo bar")
285
+ end
286
+ end
287
+
208
288
  context "with tags" do
209
- it "includes the tags" do
289
+ it "includes the inclusion tags" do
210
290
  coo = config_options_object("--tag", "tag")
211
291
  coo.drb_argv.should eq(["--tag", "tag"])
212
292
  end
213
293
 
214
- it "leaves tags intact" do
294
+ it "leaves inclusion tags intact" do
215
295
  coo = config_options_object("--tag", "tag")
216
296
  coo.drb_argv
217
297
  coo.options[:filter].should eq( {:tag=>true} )
218
298
  end
299
+
300
+ it "includes the exclusion tags" do
301
+ coo = config_options_object("--tag", "~tag")
302
+ coo.drb_argv.should eq(["--tag", "~tag"])
303
+ end
304
+
305
+ it "leaves exclusion tags intact" do
306
+ coo = config_options_object("--tag", "~tag")
307
+ coo.drb_argv
308
+ coo.options[:exclusion_filter].should eq( {:tag=>true} )
309
+ end
219
310
  end
220
311
 
221
312
  context "with formatters" do
@@ -239,8 +330,8 @@ describe RSpec::Core::ConfigurationOptions do
239
330
 
240
331
  context "--drb specified in ARGV" do
241
332
  it "renders all the original arguments except --drb" do
242
- config_options_object(*%w[ --drb --color --format s --line_number 1 --example pattern --profile --backtrace -I path/a -I path/b --require path/c --require path/d]).
243
- drb_argv.should eq(%w[ --color --profile --backtrace --line_number 1 --example pattern --format s -I path/a -I path/b --require path/c --require path/d])
333
+ config_options_object(*%w[ --drb --color --format s --example pattern --line_number 1 --profile --backtrace -I path/a -I path/b --require path/c --require path/d]).
334
+ drb_argv.should eq(%w[ --color --profile --backtrace --example pattern --line_number 1 --format s -I path/a -I path/b --require path/c --require path/d])
244
335
  end
245
336
  end
246
337
 
@@ -248,8 +339,8 @@ describe RSpec::Core::ConfigurationOptions do
248
339
  it "renders all the original arguments except --drb" do
249
340
  File.stub(:exist?) { true }
250
341
  IO.stub(:read) { "--drb --color" }
251
- config_options_object(*%w[ --tty --format s --line_number 1 --example pattern --profile --backtrace ]).
252
- drb_argv.should eq(%w[ --color --profile --backtrace --tty --line_number 1 --example pattern --format s])
342
+ config_options_object(*%w[ --tty --format s --example pattern --line_number 1 --profile --backtrace ]).
343
+ drb_argv.should eq(%w[ --color --profile --backtrace --tty --example pattern --line_number 1 --format s])
253
344
  end
254
345
  end
255
346
 
@@ -257,8 +348,8 @@ describe RSpec::Core::ConfigurationOptions do
257
348
  it "renders all the original arguments except --drb" do
258
349
  File.stub(:exist?) { true }
259
350
  IO.stub(:read) { "--drb --color" }
260
- config_options_object(*%w[ --drb --format s --line_number 1 --example pattern --profile --backtrace]).
261
- drb_argv.should eq(%w[ --color --profile --backtrace --line_number 1 --example pattern --format s])
351
+ config_options_object(*%w[ --drb --format s --example pattern --line_number 1 --profile --backtrace]).
352
+ drb_argv.should eq(%w[ --color --profile --backtrace --example pattern --line_number 1 --format s])
262
353
  end
263
354
  end
264
355
 
@@ -266,8 +357,8 @@ describe RSpec::Core::ConfigurationOptions do
266
357
  it "renders all the original arguments except --drb and --options" do
267
358
  File.stub(:exist?) { true }
268
359
  IO.stub(:read) { "--drb --color" }
269
- config_options_object(*%w[ --drb --format s --line_number 1 --example pattern --profile --backtrace]).
270
- drb_argv.should eq(%w[ --color --profile --backtrace --line_number 1 --example pattern --format s ])
360
+ config_options_object(*%w[ --drb --format s --example pattern --line_number 1 --profile --backtrace]).
361
+ drb_argv.should eq(%w[ --color --profile --backtrace --example pattern --line_number 1 --format s ])
271
362
  end
272
363
  end
273
364
  end
@@ -279,23 +370,16 @@ describe RSpec::Core::ConfigurationOptions do
279
370
 
280
371
  before do
281
372
  @orig_spec_opts = ENV["SPEC_OPTS"]
282
- @orig_global_options_file = RSpec::Core::ConfigurationOptions::GLOBAL_OPTIONS_FILE
283
- @orig_local_options_file = RSpec::Core::ConfigurationOptions::LOCAL_OPTIONS_FILE
284
- RSpec::Core::ConfigurationOptions::__send__ :remove_const, :GLOBAL_OPTIONS_FILE
285
- RSpec::Core::ConfigurationOptions::__send__ :remove_const, :LOCAL_OPTIONS_FILE
286
- RSpec::Core::ConfigurationOptions::GLOBAL_OPTIONS_FILE = global_options_file
287
- RSpec::Core::ConfigurationOptions::LOCAL_OPTIONS_FILE = local_options_file
288
- FileUtils.rm local_options_file if File.exist? local_options_file
289
- FileUtils.rm global_options_file if File.exist? global_options_file
290
- FileUtils.rm custom_options_file if File.exist? custom_options_file
373
+ RSpec::Core::ConfigurationOptions::send :public, :global_options_file
374
+ RSpec::Core::ConfigurationOptions::send :public, :local_options_file
375
+ RSpec::Core::ConfigurationOptions::any_instance.stub(:global_options_file) { global_options_file }
376
+ RSpec::Core::ConfigurationOptions::any_instance.stub(:local_options_file) { local_options_file }
291
377
  end
292
378
 
293
379
  after do
294
380
  ENV["SPEC_OPTS"] = @orig_spec_opts
295
- RSpec::Core::ConfigurationOptions::__send__ :remove_const, :GLOBAL_OPTIONS_FILE
296
- RSpec::Core::ConfigurationOptions::__send__ :remove_const, :LOCAL_OPTIONS_FILE
297
- RSpec::Core::ConfigurationOptions::GLOBAL_OPTIONS_FILE = @orig_global_options_file
298
- RSpec::Core::ConfigurationOptions::LOCAL_OPTIONS_FILE = @orig_local_options_file
381
+ RSpec::Core::ConfigurationOptions::send :private, :global_options_file
382
+ RSpec::Core::ConfigurationOptions::send :private, :local_options_file
299
383
  end
300
384
 
301
385
  def write_options(scope, options)
@@ -308,7 +392,7 @@ describe RSpec::Core::ConfigurationOptions do
308
392
  ENV["SPEC_OPTS"] = "--debug"
309
393
  options = parse_options("--drb")
310
394
  options[:color_enabled].should be_true
311
- options[:line_number].should eq("37")
395
+ options[:line_numbers].should eq(["37"])
312
396
  options[:debug].should be_true
313
397
  options[:drb].should be_true
314
398
  end
@@ -71,6 +71,18 @@ module RSpec::Core
71
71
  config.should_receive(:require).with('rspec/core/mocking/with_absolutely_nothing')
72
72
  config.mock_framework = :crazy_new_mocking_framework_ive_not_yet_heard_of
73
73
  end
74
+
75
+ context 'when there are already some example groups defined' do
76
+ before(:each) do
77
+ RSpec.world.stub(:example_groups).and_return([double.as_null_object])
78
+ end
79
+
80
+ it 'raises an error since this setting must be applied before any groups are defined' do
81
+ expect {
82
+ config.mock_framework = :rspec
83
+ }.to raise_error(/must be configured before any example groups are defined/)
84
+ end
85
+ end
74
86
  end
75
87
 
76
88
  describe "#mock_with" do
@@ -109,6 +121,18 @@ module RSpec::Core
109
121
  config.expect_with :not_supported
110
122
  end.to raise_error(ArgumentError)
111
123
  end
124
+
125
+ context 'when there are already some example groups defined' do
126
+ before(:each) do
127
+ RSpec.world.stub(:example_groups).and_return([double.as_null_object])
128
+ end
129
+
130
+ it 'raises an error since this setting must be applied before any groups are defined' do
131
+ expect {
132
+ config.expect_with :rspec
133
+ }.to raise_error(/must be configured before any example groups are defined/)
134
+ end
135
+ end
112
136
  end
113
137
 
114
138
  describe "#expecting_with_rspec?" do
@@ -145,22 +169,47 @@ module RSpec::Core
145
169
 
146
170
  describe "#files_to_run" do
147
171
  it "loads files not following pattern if named explicitly" do
148
- file = "./spec/rspec/core/resources/a_bar.rb"
149
- config.files_or_directories_to_run = file
150
- config.files_to_run.should == [file]
172
+ config.files_or_directories_to_run = "spec/rspec/core/resources/a_bar.rb"
173
+ config.files_to_run.should eq([ "spec/rspec/core/resources/a_bar.rb"])
174
+ end
175
+
176
+ it "prevents repitition of dir when start of the pattern" do
177
+ config.pattern = "spec/**/a_spec.rb"
178
+ config.files_or_directories_to_run = "spec"
179
+ config.files_to_run.should eq(["spec/rspec/core/resources/a_spec.rb"])
180
+ end
181
+
182
+ it "does not prevent repitition of dir when later of the pattern" do
183
+ config.pattern = "rspec/**/a_spec.rb"
184
+ config.files_or_directories_to_run = "spec"
185
+ config.files_to_run.should eq(["spec/rspec/core/resources/a_spec.rb"])
151
186
  end
152
187
 
153
188
  context "with default pattern" do
154
189
  it "loads files named _spec.rb" do
155
- dir = "./spec/rspec/core/resources"
156
- config.files_or_directories_to_run = dir
157
- config.files_to_run.should == ["#{dir}/a_spec.rb"]
190
+ dir = "spec/rspec/core/resources"
191
+ config.files_or_directories_to_run = "spec/rspec/core/resources"
192
+ config.files_to_run.should eq([ "spec/rspec/core/resources/a_spec.rb"])
158
193
  end
159
194
 
160
195
  it "loads files in Windows" do
161
196
  file = "C:\\path\\to\\project\\spec\\sub\\foo_spec.rb"
162
197
  config.files_or_directories_to_run = file
163
- config.files_to_run.should == [file]
198
+ config.files_to_run.should eq([file])
199
+ end
200
+ end
201
+
202
+ context "with default default_path" do
203
+ it "loads files in the default path when run by rspec" do
204
+ config.stub(:command) { 'rspec' }
205
+ config.files_or_directories_to_run = []
206
+ config.files_to_run.should_not be_empty
207
+ end
208
+
209
+ it "does not load files in the default path when run by ruby" do
210
+ config.stub(:command) { 'ruby' }
211
+ config.files_or_directories_to_run = []
212
+ config.files_to_run.should be_empty
164
213
  end
165
214
  end
166
215
  end
@@ -209,9 +258,9 @@ module RSpec::Core
209
258
  end
210
259
 
211
260
  describe "path with line number" do
212
- it "assigns the line number as the filter" do
261
+ it "assigns the line number as a location filter" do
213
262
  config.files_or_directories_to_run = "path/to/a_spec.rb:37"
214
- config.filter.should == {:line_number => 37}
263
+ config.filter.should eq({:locations => {File.expand_path("path/to/a_spec.rb") => [37]}})
215
264
  end
216
265
  end
217
266
 
@@ -221,10 +270,42 @@ module RSpec::Core
221
270
  config.full_description = "foo"
222
271
  config.filter.should_not have_key(:focused)
223
272
  end
273
+ end
224
274
 
225
- it "assigns the example name as the filter on description" do
226
- config.full_description = "foo"
227
- config.filter.should == {:full_description => /foo/}
275
+ context "with line number" do
276
+
277
+ it "assigns the file and line number as a location filter" do
278
+ config.files_or_directories_to_run = "path/to/a_spec.rb:37"
279
+ config.filter.should eq({:locations => {File.expand_path("path/to/a_spec.rb") => [37]}})
280
+ end
281
+
282
+ it "assigns multiple files with line numbers as location filters" do
283
+ config.files_or_directories_to_run = "path/to/a_spec.rb:37", "other_spec.rb:44"
284
+ config.filter.should eq({:locations => {File.expand_path("path/to/a_spec.rb") => [37],
285
+ File.expand_path("other_spec.rb") => [44]}})
286
+ end
287
+
288
+ it "assigns files with multiple line numbers as location filters" do
289
+ config.files_or_directories_to_run = "path/to/a_spec.rb:37", "path/to/a_spec.rb:44"
290
+ config.filter.should eq({:locations => {File.expand_path("path/to/a_spec.rb") => [37, 44]}})
291
+ end
292
+ end
293
+
294
+ context "with multiple line numbers" do
295
+ it "assigns the file and line numbers as a location filter" do
296
+ config.files_or_directories_to_run = "path/to/a_spec.rb:1:3:5:7"
297
+ config.filter.should eq({:locations => {File.expand_path("path/to/a_spec.rb") => [1,3,5,7]}})
298
+ end
299
+ end
300
+
301
+ it "assigns the example name as the filter on description" do
302
+ config.full_description = "foo"
303
+ config.filter.should eq({:full_description => /foo/})
304
+ end
305
+
306
+ describe "#default_path" do
307
+ it 'defaults to "spec"' do
308
+ config.default_path.should eq('spec')
228
309
  end
229
310
  end
230
311
 
@@ -251,7 +332,7 @@ module RSpec::Core
251
332
 
252
333
  group = ExampleGroup.describe('does like, stuff and junk', :magic_key => :include) { }
253
334
  group.should_not respond_to(:you_call_this_a_blt?)
254
- group.new.you_call_this_a_blt?.should == "egad man, where's the mayo?!?!?"
335
+ group.new.you_call_this_a_blt?.should eq("egad man, where's the mayo?!?!?")
255
336
  end
256
337
  end
257
338
 
@@ -263,7 +344,7 @@ module RSpec::Core
263
344
 
264
345
  group = ExampleGroup.describe('does like, stuff and junk', :magic_key => :include) { }
265
346
  group.should_not respond_to(:you_call_this_a_blt?)
266
- group.new.you_call_this_a_blt?.should == "egad man, where's the mayo?!?!?"
347
+ group.new.you_call_this_a_blt?.should eq("egad man, where's the mayo?!?!?")
267
348
  end
268
349
  end
269
350
 
@@ -468,29 +549,29 @@ module RSpec::Core
468
549
  describe "#filter_run" do
469
550
  it_behaves_like "metadata hash builder" do
470
551
  def metadata_hash(*args)
471
- config.filter_run *args
552
+ config.filter_run(*args)
472
553
  config.filter
473
554
  end
474
555
  end
475
556
 
476
557
  it "sets the filter" do
477
558
  config.filter_run :focus => true
478
- config.filter[:focus].should == true
559
+ config.filter[:focus].should be(true)
479
560
  end
480
561
 
481
562
  it "merges with existing filters" do
482
563
  config.filter_run :filter1 => true
483
564
  config.filter_run :filter2 => false
484
565
 
485
- config.filter[:filter1].should == true
486
- config.filter[:filter2].should == false
566
+ config.filter[:filter1].should be(true)
567
+ config.filter[:filter2].should be(false)
487
568
  end
488
569
 
489
- it "warns if :line_number is already a filter" do
490
- config.filter_run :line_number => 100
570
+ it "warns if :line_numbers is already a filter" do
571
+ config.filter_run :line_numbers => [100]
491
572
  config.should_receive(:warn).with(
492
573
  "Filtering by {:focus=>true} is not possible since you " \
493
- "are already filtering by {:line_number=>100}"
574
+ "are already filtering by {:line_numbers=>[100]}"
494
575
  )
495
576
  config.filter_run :focus => true
496
577
  end
@@ -508,26 +589,39 @@ module RSpec::Core
508
589
  describe "#filter_run_excluding" do
509
590
  it_behaves_like "metadata hash builder" do
510
591
  def metadata_hash(*args)
511
- config.filter_run_excluding *args
592
+ config.filter_run_excluding(*args)
512
593
  config.exclusion_filter
513
594
  end
514
595
  end
515
596
 
516
597
  it "sets the filter" do
517
598
  config.filter_run_excluding :slow => true
518
- config.exclusion_filter[:slow].should == true
599
+ config.exclusion_filter[:slow].should be(true)
519
600
  end
520
601
 
521
602
  it "merges with existing filters" do
522
603
  config.filter_run_excluding :filter1 => true
523
604
  config.filter_run_excluding :filter2 => false
524
605
 
525
- config.exclusion_filter[:filter1].should == true
526
- config.exclusion_filter[:filter2].should == false
606
+ config.exclusion_filter[:filter1].should be(true)
607
+ config.exclusion_filter[:filter2].should be(false)
608
+ end
609
+ end
610
+
611
+ describe "#inclusion_filter" do
612
+ it "returns {} even if set to nil" do
613
+ config.inclusion_filter = nil
614
+ config.inclusion_filter.should eq({})
527
615
  end
528
616
  end
529
617
 
618
+
530
619
  describe "#exclusion_filter" do
620
+ it "returns {} even if set to nil" do
621
+ config.exclusion_filter = nil
622
+ config.exclusion_filter.should eq({})
623
+ end
624
+
531
625
  describe "the default :if filter" do
532
626
  it "does not exclude a spec with no :if metadata" do
533
627
  config.exclusion_filter[:if].call(nil, {}).should be_false
@@ -561,24 +655,24 @@ module RSpec::Core
561
655
  end
562
656
  end
563
657
 
564
- describe "#line_number=" do
658
+ describe "line_numbers=" do
565
659
  before { config.stub(:warn) }
566
660
 
567
- it "sets the line number" do
568
- config.line_number = '37'
569
- config.filter.should == {:line_number => 37}
661
+ it "sets the line numbers" do
662
+ config.line_numbers = ['37']
663
+ config.filter.should eq({:line_numbers => [37]})
570
664
  end
571
665
 
572
666
  it "overrides :focused" do
573
667
  config.filter_run :focused => true
574
- config.line_number = '37'
575
- config.filter.should == {:line_number => 37}
668
+ config.line_numbers = ['37']
669
+ config.filter.should eq({:line_numbers => [37]})
576
670
  end
577
671
 
578
672
  it "prevents :focused" do
579
- config.line_number = '37'
673
+ config.line_numbers = ['37']
580
674
  config.filter_run :focused => true
581
- config.filter.should == {:line_number => 37}
675
+ config.filter.should eq({:line_numbers => [37]})
582
676
  end
583
677
  end
584
678
 
@@ -586,14 +680,14 @@ module RSpec::Core
586
680
  context "given true" do
587
681
  it "clears the backtrace clean patterns" do
588
682
  config.full_backtrace = true
589
- config.backtrace_clean_patterns.should == []
683
+ config.backtrace_clean_patterns.should eq([])
590
684
  end
591
685
  end
592
686
 
593
687
  context "given false" do
594
688
  it "restores backtrace clean patterns" do
595
689
  config.full_backtrace = false
596
- config.backtrace_clean_patterns.should == RSpec::Core::Configuration::DEFAULT_BACKTRACE_PATTERNS
690
+ config.backtrace_clean_patterns.should eq(RSpec::Core::Configuration::DEFAULT_BACKTRACE_PATTERNS)
597
691
  end
598
692
  end
599
693
 
@@ -606,6 +700,23 @@ module RSpec::Core
606
700
  end
607
701
  end
608
702
 
703
+ describe "#cleaned_from_backtrace? defaults" do
704
+ it "returns true for rspec files" do
705
+ config.cleaned_from_backtrace?("lib/rspec/core.rb").
706
+ should be_true
707
+ end
708
+
709
+ it "returns true for spec_helper" do
710
+ config.cleaned_from_backtrace?("spec/spec_helper.rb").
711
+ should be_true
712
+ end
713
+
714
+ it "returns true for java files (for JRuby)" do
715
+ config.cleaned_from_backtrace?("org/jruby/RubyArray.java:2336").
716
+ should be_true
717
+ end
718
+ end
719
+
609
720
  describe "#debug=true" do
610
721
  before do
611
722
  if defined?(Debugger)
@@ -720,12 +831,12 @@ module RSpec::Core
720
831
 
721
832
  it "delegates the getter to the other option" do
722
833
  config.another_custom_option = "this value"
723
- config.custom_option.should == "this value"
834
+ config.custom_option.should eq("this value")
724
835
  end
725
836
 
726
837
  it "delegates the setter to the other option" do
727
838
  config.custom_option = "this value"
728
- config.another_custom_option.should == "this value"
839
+ config.another_custom_option.should eq("this value")
729
840
  end
730
841
 
731
842
  it "delegates the predicate to the other option" do
@@ -792,5 +903,18 @@ module RSpec::Core
792
903
  end
793
904
  end
794
905
 
906
+ describe "#reset" do
907
+ it "clears the reporter" do
908
+ config.reporter.should_not be_nil
909
+ config.reset
910
+ config.instance_variable_get("@reporter").should be_nil
911
+ end
912
+
913
+ it "clears the formatters" do
914
+ config.add_formatter "doc"
915
+ config.reset
916
+ config.formatters.should be_empty
917
+ end
918
+ end
795
919
  end
796
920
  end
@@ -9,7 +9,7 @@ describe "deprecations" do
9
9
 
10
10
  it "returns RSpec" do
11
11
  RSpec.stub(:warn_deprecation)
12
- Spec.should == RSpec
12
+ Spec.should eq(RSpec)
13
13
  end
14
14
 
15
15
  it "doesn't include backward compatibility in const_missing backtrace" do
@@ -32,7 +32,7 @@ describe "deprecations" do
32
32
 
33
33
  it "delegates to example" do
34
34
  RSpec.stub(:warn_deprecation)
35
- running_example.should == example
35
+ running_example.should eq(example)
36
36
  end
37
37
  end
38
38
  end
@@ -1,6 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "::DRbCommandLine", :ruby => "!jruby" do
3
+ describe "::DRbCommandLine", :type => :drb, :unless => RUBY_PLATFORM == 'java' do
4
4
  let(:config) { RSpec::Core::Configuration.new }
5
5
  let(:out) { StringIO.new }
6
6
  let(:err) { StringIO.new }
@@ -41,14 +41,14 @@ describe "::DRbCommandLine", :ruby => "!jruby" do
41
41
  context "without RSPEC_DRB environment variable set" do
42
42
  it "defaults to 8989" do
43
43
  with_RSPEC_DRB_set_to(nil) do
44
- command_line([]).drb_port.should == 8989
44
+ command_line([]).drb_port.should eq(8989)
45
45
  end
46
46
  end
47
47
 
48
48
  it "sets the DRb port" do
49
49
  with_RSPEC_DRB_set_to(nil) do
50
- command_line(["--drb-port", "1234"]).drb_port.should == 1234
51
- command_line(["--drb-port", "5678"]).drb_port.should == 5678
50
+ command_line(["--drb-port", "1234"]).drb_port.should eq(1234)
51
+ command_line(["--drb-port", "5678"]).drb_port.should eq(5678)
52
52
  end
53
53
  end
54
54
  end
@@ -58,7 +58,7 @@ describe "::DRbCommandLine", :ruby => "!jruby" do
58
58
  context "without config variable set" do
59
59
  it "uses RSPEC_DRB value" do
60
60
  with_RSPEC_DRB_set_to('9000') do
61
- command_line([]).drb_port.should == "9000"
61
+ command_line([]).drb_port.should eq("9000")
62
62
  end
63
63
  end
64
64
  end
@@ -66,7 +66,7 @@ describe "::DRbCommandLine", :ruby => "!jruby" do
66
66
  context "and config variable set" do
67
67
  it "uses configured value" do
68
68
  with_RSPEC_DRB_set_to('9000') do
69
- command_line(%w[--drb-port 5678]).drb_port.should == 5678
69
+ command_line(%w[--drb-port 5678]).drb_port.should eq(5678)
70
70
  end
71
71
  end
72
72
  end