rspec-core 2.6.4 → 2.7.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. data/README.md +1 -1
  2. data/{bin → exe}/autospec +0 -0
  3. data/{bin → exe}/rspec +0 -0
  4. data/features/Upgrade.md +11 -0
  5. data/features/command_line/exit_status.feature +20 -3
  6. data/features/command_line/format_option.feature +8 -0
  7. data/features/command_line/line_number_appended_to_path.feature +35 -1
  8. data/features/command_line/line_number_option.feature +16 -3
  9. data/features/command_line/pattern_option.feature +31 -0
  10. data/features/command_line/rake_task.feature +1 -1
  11. data/features/command_line/ruby.feature +22 -0
  12. data/features/configuration/default_path.feature +38 -0
  13. data/features/example_groups/{shared_example_group.feature → shared_examples.feature} +49 -26
  14. data/features/expectation_framework_integration/configure_expectation_framework.feature +1 -1
  15. data/features/filtering/inclusion_filters.feature +4 -5
  16. data/features/formatters/text_formatter.feature +16 -13
  17. data/features/helper_methods/let.feature +4 -4
  18. data/features/hooks/around_hooks.feature +1 -1
  19. data/features/hooks/before_and_after_hooks.feature +3 -3
  20. data/features/hooks/filtering.feature +13 -6
  21. data/features/metadata/user_defined.feature +12 -10
  22. data/features/pending/pending_examples.feature +21 -8
  23. data/features/step_definitions/additional_cli_steps.rb +1 -1
  24. data/features/subject/attribute_of_subject.feature +2 -2
  25. data/features/support/env.rb +1 -2
  26. data/lib/rspec/core.rb +1 -23
  27. data/lib/rspec/core/configuration.rb +64 -16
  28. data/lib/rspec/core/configuration_options.rb +11 -4
  29. data/lib/rspec/core/example.rb +10 -7
  30. data/lib/rspec/core/example_group.rb +34 -18
  31. data/lib/rspec/core/formatters/base_text_formatter.rb +10 -2
  32. data/lib/rspec/core/formatters/html_formatter.rb +3 -1
  33. data/lib/rspec/core/formatters/snippet_extractor.rb +9 -3
  34. data/lib/rspec/core/formatters/text_mate_formatter.rb +20 -6
  35. data/lib/rspec/core/hooks.rb +2 -2
  36. data/lib/rspec/core/let.rb +5 -5
  37. data/lib/rspec/core/metadata.rb +136 -94
  38. data/lib/rspec/core/option_parser.rb +10 -5
  39. data/lib/rspec/core/pending.rb +2 -1
  40. data/lib/rspec/core/rake_task.rb +26 -15
  41. data/lib/rspec/core/reporter.rb +2 -3
  42. data/lib/rspec/core/runner.rb +1 -1
  43. data/lib/rspec/core/shared_example_group.rb +4 -4
  44. data/lib/rspec/core/subject.rb +7 -7
  45. data/lib/rspec/core/version.rb +1 -1
  46. data/lib/rspec/core/world.rb +4 -8
  47. data/spec/autotest/discover_spec.rb +2 -2
  48. data/spec/autotest/failed_results_re_spec.rb +29 -21
  49. data/spec/autotest/rspec_spec.rb +3 -3
  50. data/spec/rspec/core/command_line_spec.rb +1 -6
  51. data/spec/rspec/core/configuration_options_spec.rb +65 -13
  52. data/spec/rspec/core/configuration_spec.rb +148 -37
  53. data/spec/rspec/core/deprecations_spec.rb +2 -2
  54. data/spec/rspec/core/drb_command_line_spec.rb +6 -6
  55. data/spec/rspec/core/example_group_spec.rb +197 -61
  56. data/spec/rspec/core/example_spec.rb +33 -16
  57. data/spec/rspec/core/formatters/base_formatter_spec.rb +3 -3
  58. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +149 -1
  59. data/spec/rspec/core/formatters/helpers_spec.rb +8 -8
  60. data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +85 -17
  61. data/spec/rspec/core/formatters/html_formatted-1.8.7.html +12 -11
  62. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +12 -11
  63. data/spec/rspec/core/formatters/{html_formatted-1.9.1.html → html_formatted-1.9.3.html} +12 -11
  64. data/spec/rspec/core/formatters/html_formatter_spec.rb +5 -5
  65. data/spec/rspec/core/formatters/progress_formatter_spec.rb +2 -2
  66. data/spec/rspec/core/formatters/snippet_extractor_spec.rb +2 -2
  67. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +86 -18
  68. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +13 -12
  69. data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +29 -28
  70. data/spec/rspec/core/formatters/{text_mate_formatted-1.9.1.html → text_mate_formatted-1.9.3.html} +29 -28
  71. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +2 -2
  72. data/spec/rspec/core/hooks_filtering_spec.rb +18 -18
  73. data/spec/rspec/core/let_spec.rb +19 -6
  74. data/spec/rspec/core/metadata_spec.rb +146 -61
  75. data/spec/rspec/core/pending_example_spec.rb +4 -4
  76. data/spec/rspec/core/rake_task_spec.rb +71 -50
  77. data/spec/rspec/core/reporter_spec.rb +2 -2
  78. data/spec/rspec/core/ruby_project_spec.rb +2 -2
  79. data/spec/rspec/core/runner_spec.rb +4 -1
  80. data/spec/rspec/core/shared_example_group_spec.rb +15 -119
  81. data/spec/rspec/core/subject_spec.rb +13 -13
  82. data/spec/rspec/core/world_spec.rb +31 -22
  83. data/spec/rspec/core_spec.rb +1 -29
  84. data/spec/spec_helper.rb +51 -49
  85. data/spec/support/shared_example_groups.rb +3 -3
  86. data/spec/support/spec_files.rb +8 -8
  87. metadata +79 -93
  88. data/.document +0 -5
  89. data/.gitignore +0 -12
  90. data/.rspec +0 -0
  91. data/.travis.yml +0 -9
  92. data/Changelog.md +0 -305
  93. data/Gemfile +0 -49
  94. data/Guardfile +0 -5
  95. data/License.txt +0 -23
  96. data/Rakefile +0 -93
  97. data/cucumber.yml +0 -2
  98. data/features/.nav +0 -57
  99. data/rspec-core.gemspec +0 -24
  100. data/script/FullBuildRakeFile +0 -63
  101. data/script/console +0 -8
  102. data/script/cucumber +0 -1
  103. data/script/full_build +0 -1
  104. data/script/spec +0 -1
  105. data/spec.txt +0 -1126
  106. data/spec/rspec/core/formatters/html_formatted-1.8.6.html +0 -398
  107. data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +0 -398
@@ -15,12 +15,12 @@ Feature: let and let!
15
15
  let(:count) { $count += 1 }
16
16
 
17
17
  it "memoizes the value" do
18
- count.should == 1
19
- count.should == 1
18
+ count.should eq(1)
19
+ count.should eq(1)
20
20
  end
21
21
 
22
22
  it "is not cached across examples" do
23
- count.should == 2
23
+ count.should eq(2)
24
24
  end
25
25
  end
26
26
  """
@@ -42,7 +42,7 @@ Feature: let and let!
42
42
  it "calls the helper method in a before hook" do
43
43
  invocation_order << :example
44
44
  invocation_order.should == [:let!, :example]
45
- count.should == 1
45
+ count.should eq(1)
46
46
  end
47
47
  end
48
48
  """
@@ -259,7 +259,7 @@ Feature: around hooks
259
259
 
260
260
  it "they should all be run" do
261
261
  puts "in the example"
262
- 1.should == 1
262
+ 1.should eq(1)
263
263
  end
264
264
  end
265
265
  """
@@ -187,12 +187,12 @@ Feature: before and after hooks
187
187
  describe "stuff in before blocks" do
188
188
  describe "with :all" do
189
189
  it "should be available in the example" do
190
- @before_all.should == "before all"
190
+ @before_all.should eq("before all")
191
191
  end
192
192
  end
193
193
  describe "with :each" do
194
194
  it "should be available in the example" do
195
- @before_each.should == "before each"
195
+ @before_each.should eq("before each")
196
196
  end
197
197
  end
198
198
  end
@@ -363,7 +363,7 @@ Feature: before and after hooks
363
363
 
364
364
  describe "nested in parallel" do
365
365
  it "access state set in before(:all)" do
366
- @value.should == 123
366
+ @value.should eq(123)
367
367
  end
368
368
  end
369
369
  end
@@ -1,12 +1,19 @@
1
1
  Feature: filters
2
2
 
3
- `before`/`after`/`around` hooks defined in the RSpec configuration block can
4
- be filtered using metadata. Arbitrary metadata can be applied to an example
5
- or example group, and used to make a hook only apply to examples with the
6
- given metadata.
3
+ `before`, `after`, and `around` hooks defined in the block passed to
4
+ `RSpec.configure` can be constrained to specific examples and/or groups using
5
+ metadata as a filter.
7
6
 
8
- If you set the `treat_symbols_as_metadata_keys_with_true_values` config option
9
- to `true`, you can specify metadata using only symbols.
7
+ RSpec.configure do |c|
8
+ c.before(:each, :type => :model) do
9
+ end
10
+ end
11
+
12
+ describe "something", :type => :model do
13
+ end
14
+
15
+ You can specify metadata using only symbols if you set the
16
+ `treat_symbols_as_metadata_keys_with_true_values` config option to `true`.
10
17
 
11
18
  Scenario: filter `before(:each)` hooks using arbitrary metadata
12
19
  Given a file named "filter_before_each_hooks_spec.rb" with:
@@ -12,9 +12,11 @@ Feature: User-defined metadata
12
12
  behavior in RSpec 3) that allows you to specify metadata using just
13
13
  symbols:
14
14
 
15
- RSpec.configure do |c|
16
- c.treat_symbols_as_metadata_keys_with_true_values = true
17
- end
15
+ ```ruby
16
+ RSpec.configure do |c|
17
+ c.treat_symbols_as_metadata_keys_with_true_values = true
18
+ end
19
+ ```
18
20
 
19
21
  Each symbol passed as an argument to `describe`, `context` or `it` will
20
22
  be a key in the metadata hash, with a corresponding value of `true`.
@@ -24,7 +26,7 @@ Feature: User-defined metadata
24
26
  """
25
27
  describe "a group with user-defined metadata", :foo => 17 do
26
28
  it 'has access to the metadata in the example' do
27
- example.metadata[:foo].should == 17
29
+ example.metadata[:foo].should eq(17)
28
30
  end
29
31
 
30
32
  it 'does not have access to metadata defined on sub-groups' do
@@ -33,11 +35,11 @@ Feature: User-defined metadata
33
35
 
34
36
  describe 'a sub-group with user-defined metadata', :bar => 12 do
35
37
  it 'has access to the sub-group metadata' do
36
- example.metadata[:foo].should == 17
38
+ example.metadata[:foo].should eq(17)
37
39
  end
38
40
 
39
41
  it 'also has access to metadata defined on parent groups' do
40
- example.metadata[:bar].should == 12
42
+ example.metadata[:bar].should eq(12)
41
43
  end
42
44
  end
43
45
  end
@@ -50,13 +52,13 @@ Feature: User-defined metadata
50
52
  """
51
53
  describe "a group with no user-defined metadata" do
52
54
  it 'has an example with metadata', :foo => 17 do
53
- example.metadata[:foo].should == 17
55
+ example.metadata[:foo].should eq(17)
54
56
  example.metadata.should_not include(:bar)
55
57
  end
56
58
 
57
59
  it 'has another example with metadata', :bar => 12, :bazz => 33 do
58
- example.metadata[:bar].should == 12
59
- example.metadata[:bazz].should == 33
60
+ example.metadata[:bar].should eq(12)
61
+ example.metadata[:bazz].should eq(33)
60
62
  example.metadata.should_not include(:foo)
61
63
  end
62
64
  end
@@ -99,7 +101,7 @@ Feature: User-defined metadata
99
101
  end
100
102
 
101
103
  it 'can still use a hash for metadata' do
102
- example.metadata[:bug].should == 73
104
+ example.metadata[:bug].should eq(73)
103
105
  end
104
106
 
105
107
  it 'can define simple metadata on an example', :special do
@@ -77,22 +77,35 @@ Feature: pending examples
77
77
  And the output should contain "Expected pending 'something else getting finished' to fail. No Error was raised."
78
78
  And the output should contain "pending_with_passing_block_spec.rb:3"
79
79
 
80
- Scenario: temporarily pending by changing "it" to "xit"
81
- Given a file named "pending_with_xit_spec.rb" with:
80
+ Scenario: temporarily pending by prefixing `it`, `specify`, or `example` with an x
81
+ Given a file named "temporarily_pending_spec.rb" with:
82
82
  """
83
83
  describe "an example" do
84
84
  xit "is pending using xit" do
85
- true.should be(true)
85
+ end
86
+
87
+ xspecify "is pending using xspecify" do
88
+ end
89
+
90
+ xexample "is pending using xexample" do
86
91
  end
87
92
  end
88
93
  """
89
- When I run `rspec pending_with_xit_spec.rb`
94
+ When I run `rspec temporarily_pending_spec.rb`
90
95
  Then the exit status should be 0
91
- And the output should contain "1 example, 0 failures, 1 pending"
96
+ And the output should contain "3 examples, 0 failures, 3 pending"
92
97
  And the output should contain:
93
98
  """
94
99
  Pending:
95
100
  an example is pending using xit
101
+ # Not Yet Implemented
102
+ # ./temporarily_pending_spec.rb:2
103
+ an example is pending using xspecify
104
+ # Not Yet Implemented
105
+ # ./temporarily_pending_spec.rb:5
106
+ an example is pending using xexample
107
+ # Not Yet Implemented
108
+ # ./temporarily_pending_spec.rb:8
96
109
  """
97
110
 
98
111
  Scenario: example with no docstring and pending method using documentation formatter
@@ -100,7 +113,7 @@ Feature: pending examples
100
113
  """
101
114
  describe "an example" do
102
115
  it "checks something" do
103
- (3+4).should == 7
116
+ (3+4).should eq(7)
104
117
  end
105
118
  specify do
106
119
  pending
@@ -122,10 +135,10 @@ Feature: pending examples
122
135
  """
123
136
  describe "an example" do
124
137
  it "checks something" do
125
- (3+4).should == 7
138
+ (3+4).should eq(7)
126
139
  end
127
140
  pending do
128
- "string".reverse.should == "gnirts"
141
+ "string".reverse.should eq("gnirts")
129
142
  end
130
143
  end
131
144
  """
@@ -1,6 +1,6 @@
1
1
  Then /^the output should contain all of these:$/ do |table|
2
2
  table.raw.flatten.each do |string|
3
- assert_partial_output(string)
3
+ assert_partial_output(string, all_output)
4
4
  end
5
5
  end
6
6
 
@@ -34,7 +34,7 @@ Feature: attribute of subject
34
34
  Array
35
35
  when first created
36
36
  size
37
- should == 0
37
+ should eq 0
38
38
  """
39
39
 
40
40
  Scenario: specify value of a nested attribute
@@ -65,7 +65,7 @@ Feature: attribute of subject
65
65
  Person
66
66
  with one phone number (555-1212)
67
67
  phone_numbers.first
68
- should == 555-1212
68
+ should eq 555-1212
69
69
  """
70
70
 
71
71
  Scenario: specify value of an attribute of a hash
@@ -1,6 +1,5 @@
1
1
  require 'aruba/cucumber'
2
2
 
3
3
  Before do
4
- @aruba_timeout_seconds = 3
4
+ RUBY_PLATFORM =~ /java/ ? @aruba_timeout_seconds = 60 : @aruba_timeout_seconds = 5
5
5
  end
6
-
@@ -1,3 +1,4 @@
1
+ $rspec_start_time ||= Time.now
1
2
  require 'rspec/core/dsl'
2
3
  require 'rspec/core/extensions'
3
4
  require 'rspec/core/load_path'
@@ -27,8 +28,6 @@ require 'rspec/core/example_group'
27
28
  require 'rspec/core/version'
28
29
  require 'rspec/core/errors'
29
30
 
30
- require 'rspec/autorun' if $0.split(File::SEPARATOR).last == 'rcov'
31
-
32
31
  module RSpec
33
32
  autoload :Matchers, 'rspec/matchers'
34
33
 
@@ -75,7 +74,6 @@ module RSpec
75
74
  # config.format = 'documentation'
76
75
  # end
77
76
  def self.configure
78
- warn_about_deprecated_configure if RSpec.world.example_groups.any?
79
77
  yield configuration if block_given?
80
78
  end
81
79
 
@@ -83,26 +81,6 @@ module RSpec
83
81
  def self.clear_remaining_example_groups
84
82
  world.example_groups.clear
85
83
  end
86
-
87
- private
88
-
89
- def self.warn_about_deprecated_configure
90
- warn <<-NOTICE
91
-
92
- *****************************************************************
93
- DEPRECATION WARNING: you are using deprecated behaviour that will
94
- be removed from RSpec 3.
95
-
96
- You have set some configuration options after an example group has
97
- already been defined. In RSpec 3, this will not be allowed. All
98
- configuration should happen before the first example group is
99
- defined. The configuration is happening at:
100
-
101
- #{caller[1]}
102
- *****************************************************************
103
-
104
- NOTICE
105
- end
106
84
  end
107
85
 
108
86
  require 'rspec/core/backward_compatibility'
@@ -6,6 +6,8 @@ module RSpec
6
6
  class Configuration
7
7
  include RSpec::Core::Hooks
8
8
 
9
+ class MustBeConfiguredBeforeExampleGroupsError < StandardError; end
10
+
9
11
  def self.add_setting(name, opts={})
10
12
  if opts[:alias]
11
13
  alias_method name, opts[:alias]
@@ -38,6 +40,8 @@ module RSpec
38
40
  add_setting :tty
39
41
  add_setting :treat_symbols_as_metadata_keys_with_true_values, :default => false
40
42
  add_setting :expecting_with_rspec
43
+ add_setting :default_path, :default => 'spec'
44
+ add_setting :show_failures_in_pending_blocks, :default => false
41
45
 
42
46
  CONDITIONAL_FILTERS = {
43
47
  :if => lambda { |value, metadata| metadata.has_key?(:if) && !value },
@@ -46,6 +50,7 @@ module RSpec
46
50
 
47
51
  DEFAULT_BACKTRACE_PATTERNS = [
48
52
  /\/lib\d*\/ruby\//,
53
+ /org\/jruby\//,
49
54
  /bin\//,
50
55
  /gems/,
51
56
  /spec\/spec_helper\.rb/,
@@ -62,6 +67,7 @@ module RSpec
62
67
 
63
68
  def reset
64
69
  @reporter = nil
70
+ @formatters.clear if @formatters
65
71
  end
66
72
 
67
73
  # :call-seq:
@@ -158,6 +164,7 @@ module RSpec
158
164
  # teardown_mocks_for_rspec
159
165
  # - called after verify_mocks_for_rspec (even if there are errors)
160
166
  def mock_framework=(framework)
167
+ assert_no_example_groups_defined(:mock_framework)
161
168
  case framework
162
169
  when Module
163
170
  settings[:mock_framework] = framework
@@ -198,6 +205,7 @@ module RSpec
198
205
  # Given :stdlib, configures test/unit/assertions
199
206
  # Given both, configures both
200
207
  def expect_with(*frameworks)
208
+ assert_no_example_groups_defined(:expect_with)
201
209
  settings[:expectation_frameworks] = []
202
210
  frameworks.each do |framework|
203
211
  case framework
@@ -252,22 +260,34 @@ module RSpec
252
260
  begin
253
261
  require 'ruby-debug'
254
262
  Debugger.start
255
- rescue LoadError
263
+ rescue LoadError => e
256
264
  raise <<-EOM
257
265
 
258
266
  #{'*'*50}
259
- You must install ruby-debug to run rspec with the --debug option.
267
+ #{e.message}
268
+
269
+ If you have it installed as a ruby gem, then you need to either require
270
+ 'rubygems' or configure the RUBYOPT environment variable with the value
271
+ 'rubygems'.
260
272
 
261
- If you have ruby-debug installed as a ruby gem, then you need to either
262
- require 'rubygems' or configure the RUBYOPT environment variable with
263
- the value 'rubygems'.
273
+ #{e.backtrace.join("\n")}
264
274
  #{'*'*50}
265
275
  EOM
266
276
  end
267
277
  end
268
278
 
269
- def line_number=(line_number)
270
- filter_run({ :line_number => line_number.to_i }, true)
279
+ # Run examples defined on +line_numbers+ in all files to run.
280
+ def line_numbers=(line_numbers)
281
+ filter_run({ :line_numbers => line_numbers.map{|l| l.to_i} }, true)
282
+ end
283
+
284
+ def add_location(file_path, line_numbers)
285
+ # Filter locations is a hash of expanded paths to arrays of line numbers
286
+ # to match against.
287
+ #
288
+ filter_locations = ((self.filter || {})[:locations] ||= {})
289
+ (filter_locations[File.expand_path(file_path)] ||= []).push(*line_numbers)
290
+ filter_run({ :locations => filter_locations })
271
291
  end
272
292
 
273
293
  def full_description=(description)
@@ -297,15 +317,31 @@ EOM
297
317
  end
298
318
 
299
319
  def files_or_directories_to_run=(*files)
300
- self.files_to_run = files.flatten.collect do |file|
320
+ files = files.flatten
321
+ files << default_path if command == 'rspec' && default_path && files.empty?
322
+ self.files_to_run = get_files_to_run(files)
323
+ end
324
+
325
+ def command
326
+ $0.split(File::SEPARATOR).last
327
+ end
328
+
329
+ def get_files_to_run(files)
330
+ patterns = pattern.split(",")
331
+ files.map do |file|
301
332
  if File.directory?(file)
302
- pattern.split(",").collect do |pattern|
303
- Dir["#{file}/#{pattern.strip}"]
333
+ patterns.map do |pattern|
334
+ if pattern =~ /^#{file}/
335
+ Dir[pattern.strip]
336
+ else
337
+ Dir["#{file}/{#{pattern.strip}}"]
338
+ end
304
339
  end
305
340
  else
306
- if file =~ /(\:(\d+))$/
307
- self.line_number = $2
308
- file.sub($1,'')
341
+ if file =~ /^(.*?)((?:\:\d+)+)$/
342
+ path, lines = $1, $2[1..-1].split(":").map{|n| n.to_i}
343
+ add_location path, lines
344
+ path
309
345
  else
310
346
  file
311
347
  end
@@ -345,10 +381,12 @@ EOM
345
381
  RSpec::Core::ExampleGroup.alias_it_should_behave_like_to(new_name, report_label)
346
382
  end
347
383
 
384
+ undef_method :exclusion_filter=
348
385
  def exclusion_filter=(filter)
349
386
  settings[:exclusion_filter] = filter
350
387
  end
351
388
 
389
+ undef_method :exclusion_filter
352
390
  def exclusion_filter
353
391
  settings[:exclusion_filter] || {}
354
392
  end
@@ -360,6 +398,7 @@ EOM
360
398
  def inclusion_filter
361
399
  settings[:inclusion_filter] || {}
362
400
  end
401
+
363
402
  def filter_run_including(*args)
364
403
  force_overwrite = if args.last.is_a?(Hash) || args.last.is_a?(Symbol)
365
404
  false
@@ -369,7 +408,7 @@ EOM
369
408
 
370
409
  options = build_metadata_hash_from(args)
371
410
 
372
- if inclusion_filter[:line_number] || inclusion_filter[:full_description]
411
+ if inclusion_filter and inclusion_filter[:line_numbers] || inclusion_filter[:full_description]
373
412
  warn "Filtering by #{options.inspect} is not possible since " \
374
413
  "you are already filtering by #{inclusion_filter.inspect}"
375
414
  else
@@ -400,7 +439,7 @@ EOM
400
439
 
401
440
  def configure_group(group)
402
441
  include_or_extend_modules.each do |include_or_extend, mod, filters|
403
- next unless filters.empty? || group.apply?(:any?, filters)
442
+ next unless filters.empty? || group.any_apply?(filters)
404
443
  group.send(include_or_extend, mod)
405
444
  end
406
445
  end
@@ -422,6 +461,15 @@ EOM
422
461
 
423
462
  private
424
463
 
464
+ def assert_no_example_groups_defined(config_option)
465
+ if RSpec.world.example_groups.any?
466
+ raise MustBeConfiguredBeforeExampleGroupsError.new(
467
+ "RSpec's #{config_option} configuration option must be configured before " +
468
+ "any example groups are defined, but you have already defined a group."
469
+ )
470
+ end
471
+ end
472
+
425
473
  def raise_if_rspec_1_is_loaded
426
474
  if defined?(Spec) && defined?(Spec::VERSION::MAJOR) && Spec::VERSION::MAJOR == 1
427
475
  raise <<-MESSAGE
@@ -475,7 +523,7 @@ MESSAGE
475
523
  end
476
524
  end
477
525
  end
478
-
526
+
479
527
  def string_const?(str)
480
528
  str.is_a?(String) && /\A[A-Z][a-zA-Z0-9_:]*\z/ =~ str
481
529
  end