rspec-core 2.13.1 → 2.14.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. data/Changelog.md +80 -0
  2. data/exe/autospec +1 -1
  3. data/features/README.md +2 -2
  4. data/features/command_line/format_option.feature +8 -14
  5. data/features/command_line/line_number_appended_to_path.feature +4 -4
  6. data/features/command_line/line_number_option.feature +1 -1
  7. data/features/command_line/rake_task.feature +2 -2
  8. data/features/command_line/require_option.feature +43 -0
  9. data/features/command_line/ruby.feature +2 -2
  10. data/features/command_line/warnings_option.feature +27 -0
  11. data/features/configuration/backtrace_clean_patterns.feature +2 -2
  12. data/features/configuration/deprecation_stream.feature +58 -0
  13. data/features/configuration/pattern.feature +8 -0
  14. data/features/configuration/profile.feature +59 -2
  15. data/features/configuration/read_options_from_file.feature +8 -5
  16. data/features/configuration/run_all_when_everything_filtered.feature +20 -4
  17. data/features/example_groups/basic_structure.feature +1 -1
  18. data/features/example_groups/shared_context.feature +1 -1
  19. data/features/example_groups/shared_examples.feature +72 -0
  20. data/features/filtering/exclusion_filters.feature +10 -10
  21. data/features/formatters/custom_formatter.feature +1 -1
  22. data/features/hooks/before_and_after_hooks.feature +19 -19
  23. data/features/mock_framework_integration/use_any_framework.feature +6 -6
  24. data/features/mock_framework_integration/use_flexmock.feature +3 -3
  25. data/features/mock_framework_integration/use_mocha.feature +3 -3
  26. data/features/mock_framework_integration/use_rr.feature +3 -3
  27. data/features/mock_framework_integration/use_rspec.feature +3 -3
  28. data/features/subject/implicit_subject.feature +1 -1
  29. data/lib/rspec/core.rb +20 -3
  30. data/lib/rspec/core/backtrace_cleaner.rb +46 -0
  31. data/lib/rspec/core/backward_compatibility.rb +3 -13
  32. data/lib/rspec/core/configuration.rb +136 -49
  33. data/lib/rspec/core/configuration_options.rb +19 -8
  34. data/lib/rspec/core/deprecation.rb +18 -30
  35. data/lib/rspec/core/example.rb +3 -3
  36. data/lib/rspec/core/example_group.rb +4 -3
  37. data/lib/rspec/core/extensions/kernel.rb +1 -1
  38. data/lib/rspec/core/filter_manager.rb +1 -1
  39. data/lib/rspec/core/formatters.rb +1 -1
  40. data/lib/rspec/core/formatters/base_formatter.rb +10 -1
  41. data/lib/rspec/core/formatters/base_text_formatter.rb +47 -10
  42. data/lib/rspec/core/formatters/deprecation_formatter.rb +35 -0
  43. data/lib/rspec/core/formatters/helpers.rb +12 -5
  44. data/lib/rspec/core/formatters/html_formatter.rb +7 -6
  45. data/lib/rspec/core/formatters/html_printer.rb +13 -12
  46. data/lib/rspec/core/formatters/json_formatter.rb +1 -2
  47. data/lib/rspec/core/formatters/text_mate_formatter.rb +1 -1
  48. data/lib/rspec/core/hooks.rb +9 -0
  49. data/lib/rspec/core/memoized_helpers.rb +19 -8
  50. data/lib/rspec/core/metadata.rb +3 -1
  51. data/lib/rspec/core/mocking/with_flexmock.rb +1 -1
  52. data/lib/rspec/core/mocking/with_rr.rb +1 -1
  53. data/lib/rspec/core/option_parser.rb +6 -2
  54. data/lib/rspec/core/pending.rb +1 -0
  55. data/lib/rspec/core/rake_task.rb +11 -19
  56. data/lib/rspec/core/reporter.rb +33 -4
  57. data/lib/rspec/core/shared_example_group.rb +56 -16
  58. data/lib/rspec/core/shared_example_group/collection.rb +42 -0
  59. data/lib/rspec/core/version.rb +1 -1
  60. data/lib/rspec/core/world.rb +2 -3
  61. data/spec/autotest/rspec_spec.rb +2 -2
  62. data/spec/rspec/core/backtrace_cleaner_spec.rb +68 -0
  63. data/spec/rspec/core/configuration_options_spec.rb +15 -4
  64. data/spec/rspec/core/configuration_spec.rb +202 -19
  65. data/spec/rspec/core/deprecation_spec.rb +41 -0
  66. data/spec/rspec/core/deprecations_spec.rb +10 -12
  67. data/spec/rspec/core/drb_command_line_spec.rb +1 -1
  68. data/spec/rspec/core/example_group_spec.rb +37 -36
  69. data/spec/rspec/core/example_spec.rb +25 -4
  70. data/spec/rspec/core/filter_manager_spec.rb +6 -6
  71. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +101 -36
  72. data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +78 -0
  73. data/spec/rspec/core/formatters/documentation_formatter_spec.rb +2 -2
  74. data/spec/rspec/core/formatters/helpers_spec.rb +23 -7
  75. data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +20 -14
  76. data/spec/rspec/core/formatters/html_formatted-1.8.7-rbx.html +69 -169
  77. data/spec/rspec/core/formatters/html_formatted-1.8.7.html +28 -23
  78. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +42 -33
  79. data/spec/rspec/core/formatters/html_formatted-1.9.3-jruby.html +17 -23
  80. data/spec/rspec/core/formatters/html_formatted-1.9.3-rbx.html +57 -157
  81. data/spec/rspec/core/formatters/html_formatted-1.9.3.html +42 -33
  82. data/spec/rspec/core/formatters/html_formatted-2.0.0.html +42 -33
  83. data/spec/rspec/core/formatters/html_formatter_spec.rb +1 -0
  84. data/spec/rspec/core/formatters/progress_formatter_spec.rb +3 -3
  85. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +11 -14
  86. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-rbx.html +103 -203
  87. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +30 -25
  88. data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +42 -33
  89. data/spec/rspec/core/formatters/text_mate_formatted-1.9.3-jruby.html +20 -14
  90. data/spec/rspec/core/formatters/text_mate_formatted-1.9.3-rbx.html +103 -203
  91. data/spec/rspec/core/formatters/text_mate_formatted-1.9.3.html +42 -33
  92. data/spec/rspec/core/formatters/text_mate_formatted-2.0.0.html +42 -33
  93. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +1 -0
  94. data/spec/rspec/core/memoized_helpers_spec.rb +28 -0
  95. data/spec/rspec/core/metadata_spec.rb +8 -3
  96. data/spec/rspec/core/option_parser_spec.rb +8 -0
  97. data/spec/rspec/core/project_initializer_spec.rb +2 -2
  98. data/spec/rspec/core/rake_task_spec.rb +8 -8
  99. data/spec/rspec/core/reporter_spec.rb +26 -6
  100. data/spec/rspec/core/resources/formatter_specs.rb +3 -3
  101. data/spec/rspec/core/shared_context_spec.rb +20 -0
  102. data/spec/rspec/core/shared_example_group/collection_spec.rb +70 -0
  103. data/spec/rspec/core/shared_example_group_spec.rb +4 -4
  104. data/spec/rspec/core/world_spec.rb +1 -3
  105. data/spec/rspec/core_spec.rb +20 -0
  106. data/spec/spec_helper.rb +29 -29
  107. data/spec/support/helper_methods.rb +9 -1
  108. data/spec/support/isolate_load_path_mutation.rb +6 -0
  109. data/spec/support/sandboxed_mock_space.rb +100 -0
  110. metadata +28 -13
  111. data/features/filtering/run_all_when_everything_filtered.feature +0 -46
  112. data/lib/rspec/core/load_path.rb +0 -3
@@ -2,12 +2,15 @@ Feature: read command line configuration options from files
2
2
 
3
3
  RSpec reads command line configuration options from files in two different
4
4
  locations:
5
-
6
- Local: "./.rspec" (i.e. in the project's root directory)
7
- Global: "~/.rspec" (i.e. in the user's home directory)
8
5
 
9
- Options declared in the local file override those in the global file, while
10
- those declared in RSpec.configure will override any ".rspec" file.
6
+ Local: `./.rspec-local` (i.e. in the project's root directory, can be gitignored)
7
+ Project: `./.rspec` (i.e. in the project's root directory, usually checked into the project)
8
+ Global: `~/.rspec` (i.e. in the user's home directory)
9
+
10
+ Configuration options are loaded from `~/.rspec`, `.rspec`,
11
+ `.rspec-local`, command line switches, and the `SPEC_OPTS` environment
12
+ variable (listed in lowest to highest precedence; for example, an option
13
+ in `~/.rspec` can be overridden by an option in `.rspec-local`).
11
14
 
12
15
  Scenario: color set in .rspec
13
16
  Given a file named ".rspec" with:
@@ -1,8 +1,10 @@
1
1
  Feature: run all when everything filtered
2
2
 
3
- Use the run_all_when_everything_filtered option to tell RSpec to run
4
- all the specs in the case where you try to run a filtered list of
5
- specs but no specs match that filter.
3
+ Use the run_all_when_everything_filtered option to tell RSpec to run all the
4
+ specs in the case where you try to run a filtered list of specs but no specs
5
+ match that filter. This works well when paired with an inclusion filter like
6
+ `:focus => true`, as it will run all the examples when none match the
7
+ inclusion filter.
6
8
 
7
9
  RSpec.configure { |c| c.run_all_when_everything_filtered = true }
8
10
 
@@ -12,7 +14,7 @@ Feature: run all when everything filtered
12
14
  RSpec.configure {|c| c.run_all_when_everything_filtered = true}
13
15
  """
14
16
 
15
- Scenario: by default, no specs are run if they are all filtered out
17
+ Scenario: by default, no specs are run if they are all filtered out by an inclusion tag
16
18
  Given a file named "spec/example_spec.rb" with:
17
19
  """ruby
18
20
  describe "examples" do
@@ -26,6 +28,20 @@ Feature: run all when everything filtered
26
28
  When I run `rspec spec/example_spec.rb --tag some_tag`
27
29
  Then the output should contain "0 examples, 0 failures"
28
30
 
31
+ Scenario: specs are still run if they are filtered out by an exclusion tag
32
+ Given a file named "spec/example_spec.rb" with:
33
+ """ruby
34
+ describe "examples" do
35
+ it "with no tag" do
36
+ end
37
+
38
+ it "with no tag as well" do
39
+ end
40
+ end
41
+ """
42
+ When I run `rspec spec/example_spec.rb --tag ~some_tag`
43
+ Then the output should contain "2 examples, 0 failures"
44
+
29
45
  Scenario: when the run_all_when_everything_filtered option is turned on, if there are any matches for the filtering tag, only those features are run
30
46
  Given a file named "spec/example_spec.rb" with:
31
47
  """ruby
@@ -14,7 +14,7 @@ Feature: basic structure (describe/it)
14
14
  Under the hood, an example group is a class in which the block passed to
15
15
  `describe` or `context` is evaluated. The blocks passed to `it` are evaluated
16
16
  in the context of an _instance_ of that class.
17
-
17
+
18
18
  Scenario: one group, one example
19
19
  Given a file named "sample_spec.rb" with:
20
20
  """ruby
@@ -18,7 +18,7 @@ Feature: shared context
18
18
  end
19
19
  end
20
20
  """
21
-
21
+
22
22
  Scenario: declare shared context and include it with include_context
23
23
  Given a file named "shared_context_example.rb" with:
24
24
  """ruby
@@ -220,3 +220,75 @@ Feature: shared examples
220
220
  """
221
221
  1 example, 0 failures
222
222
  """
223
+
224
+ Scenario: Shared examples are nestable by context
225
+ Given a file named "context_specific_examples_spec.rb" with:
226
+ """Ruby
227
+ describe "shared examples" do
228
+ context "per context" do
229
+
230
+ shared_examples "shared examples are nestable" do
231
+ specify { expect(true).to eq true }
232
+ end
233
+
234
+ it_behaves_like "shared examples are nestable"
235
+ end
236
+ end
237
+ """
238
+ When I run `rspec context_specific_examples_spec.rb`
239
+ Then the output should contain:
240
+ """
241
+ 1 example, 0 failures
242
+ """
243
+
244
+ Scenario: Shared examples are accessible from offspring contexts
245
+ Given a file named "context_specific_examples_spec.rb" with:
246
+ """Ruby
247
+ describe "shared examples" do
248
+ shared_examples "shared examples are nestable" do
249
+ specify { expect(true).to eq true }
250
+ end
251
+
252
+ context "per context" do
253
+ it_behaves_like "shared examples are nestable"
254
+ end
255
+ end
256
+ """
257
+ When I run `rspec context_specific_examples_spec.rb`
258
+ Then the output should contain:
259
+ """
260
+ 1 example, 0 failures
261
+ """
262
+ And the output should not contain:
263
+ """
264
+ Accessing shared_examples defined across contexts is deprecated
265
+ """
266
+
267
+ Scenario: Shared examples are isolated per context
268
+ Given a file named "isolated_shared_examples_spec.rb" with:
269
+ """Ruby
270
+ describe "shared examples" do
271
+ context do
272
+ shared_examples "shared examples are isolated" do
273
+ specify { expect(true).to eq true }
274
+ end
275
+ end
276
+
277
+ context do
278
+ it_behaves_like "shared examples are isolated"
279
+ end
280
+ end
281
+ """
282
+ When I run `rspec isolated_shared_examples_spec.rb`
283
+ Then the output should contain:
284
+ """
285
+ 1 example, 0 failures
286
+ """
287
+ But the output should contain:
288
+ """
289
+ Accessing shared_examples defined across contexts is deprecated
290
+ """
291
+ And the output should contain:
292
+ """
293
+ isolated_shared_examples_spec.rb:9
294
+ """
@@ -5,7 +5,7 @@ Feature: exclusion filters
5
5
 
6
6
  If you set the `treat_symbols_as_metadata_keys_with_true_values` config option
7
7
  to `true`, you can specify metadata using only symbols.
8
-
8
+
9
9
  Scenario: exclude an example
10
10
  Given a file named "spec/sample_spec.rb" with:
11
11
  """ruby
@@ -33,15 +33,15 @@ Feature: exclusion filters
33
33
  RSpec.configure do |c|
34
34
  c.filter_run_excluding :broken => true
35
35
  end
36
-
36
+
37
37
  describe "group 1", :broken => true do
38
38
  it "group 1 example 1" do
39
39
  end
40
-
40
+
41
41
  it "group 1 example 2" do
42
42
  end
43
43
  end
44
-
44
+
45
45
  describe "group 2" do
46
46
  it "group 2 example 1" do
47
47
  end
@@ -51,31 +51,31 @@ Feature: exclusion filters
51
51
  Then the output should contain "group 2 example 1"
52
52
  And the output should not contain "group 1 example 1"
53
53
  And the output should not contain "group 1 example 2"
54
-
54
+
55
55
  Scenario: exclude multiple groups
56
56
  Given a file named "spec/sample_spec.rb" with:
57
57
  """ruby
58
58
  RSpec.configure do |c|
59
59
  c.filter_run_excluding :broken => true
60
60
  end
61
-
61
+
62
62
  describe "group 1", :broken => true do
63
63
  before(:all) do
64
64
  raise "you should not see me"
65
65
  end
66
-
66
+
67
67
  it "group 1 example 1" do
68
68
  end
69
-
69
+
70
70
  it "group 1 example 2" do
71
71
  end
72
72
  end
73
-
73
+
74
74
  describe "group 2", :broken => true do
75
75
  before(:each) do
76
76
  raise "you should not see me"
77
77
  end
78
-
78
+
79
79
  it "group 2 example 1" do
80
80
  end
81
81
  end
@@ -3,7 +3,7 @@ Feature: custom formatters
3
3
  RSpec ships with general purpose output formatters. You can tell RSpec which
4
4
  one to use using the [`--format` command line
5
5
  option]('../command_line/format_option').
6
-
6
+
7
7
  When RSpec's built-in output formatters don't, however, give you everything
8
8
  you need, you can write your own custom formatter and tell RSpec to use that
9
9
  one instead. The simplest way is to subclass RSpec's `BaseTextFormatter`,
@@ -69,21 +69,21 @@ Feature: before and after hooks
69
69
  @widgets ||= []
70
70
  end
71
71
  end
72
-
72
+
73
73
  describe Thing do
74
74
  before(:all) do
75
75
  @thing = Thing.new
76
76
  end
77
-
77
+
78
78
  describe "initialized in before(:all)" do
79
79
  it "has 0 widgets" do
80
80
  @thing.should have(0).widgets
81
81
  end
82
-
82
+
83
83
  it "can get accept new widgets" do
84
84
  @thing.widgets << Object.new
85
85
  end
86
-
86
+
87
87
  it "shares state across examples" do
88
88
  @thing.should have(1).widgets
89
89
  end
@@ -187,7 +187,7 @@ Feature: before and after hooks
187
187
  @before_all = "before all"
188
188
  end
189
189
  end
190
-
190
+
191
191
  describe "stuff in before blocks" do
192
192
  describe "with :all" do
193
193
  it "should be available in the example" do
@@ -213,21 +213,21 @@ Feature: before and after hooks
213
213
  before(:all) do
214
214
  puts "before all"
215
215
  end
216
-
216
+
217
217
  before(:each) do
218
218
  puts "before each"
219
219
  end
220
-
220
+
221
221
  after(:each) do
222
222
  puts "after each"
223
223
  end
224
-
224
+
225
225
  after(:all) do
226
226
  puts "after all"
227
227
  end
228
-
228
+
229
229
  it "gets run in order" do
230
-
230
+
231
231
  end
232
232
  end
233
233
  """
@@ -239,7 +239,7 @@ Feature: before and after hooks
239
239
  after each
240
240
  .after all
241
241
  """
242
-
242
+
243
243
  Scenario: before/after blocks defined in config are run in order
244
244
  Given a file named "configuration_spec.rb" with:
245
245
  """ruby
@@ -249,28 +249,28 @@ Feature: before and after hooks
249
249
  config.before(:suite) do
250
250
  puts "before suite"
251
251
  end
252
-
252
+
253
253
  config.before(:all) do
254
254
  puts "before all"
255
255
  end
256
-
256
+
257
257
  config.before(:each) do
258
258
  puts "before each"
259
259
  end
260
-
260
+
261
261
  config.after(:each) do
262
262
  puts "after each"
263
263
  end
264
-
264
+
265
265
  config.after(:all) do
266
266
  puts "after all"
267
267
  end
268
-
268
+
269
269
  config.after(:suite) do
270
270
  puts "after suite"
271
271
  end
272
272
  end
273
-
273
+
274
274
  describe "ignore" do
275
275
  example "ignore" do
276
276
  end
@@ -294,7 +294,7 @@ Feature: before and after hooks
294
294
  before(:all) do
295
295
  puts "outer before all"
296
296
  end
297
-
297
+
298
298
  example "in outer group" do
299
299
  end
300
300
 
@@ -306,7 +306,7 @@ Feature: before and after hooks
306
306
  before(:all) do
307
307
  puts "inner before all"
308
308
  end
309
-
309
+
310
310
  example "in nested group" do
311
311
  end
312
312
 
@@ -5,14 +5,14 @@ Feature: mock with an alternative framework
5
5
  to provide an adapter that hooks RSpec's events into those of the framework.
6
6
 
7
7
  A mock framework adapter must expose three methods:
8
-
8
+
9
9
  * `setup_mocks_for_rspec`
10
10
  * called before each example is run
11
- * `verify_mocks_for_rspec`
11
+ * `verify_mocks_for_rspec`
12
12
  * called after each example is run
13
13
  * this is where message expectation failures should result in an error with
14
14
  the appropriate failure message
15
- * `teardown_mocks_for_rspec`
15
+ * `teardown_mocks_for_rspec`
16
16
  * called after `verify_mocks_for_rspec`
17
17
  * use this to clean up resources, restore objects to earlier state, etc
18
18
  * guaranteed to run even if there are failures
@@ -78,7 +78,7 @@ Feature: mock with an alternative framework
78
78
  end
79
79
  end
80
80
  """
81
-
81
+
82
82
  Given a file named "example_spec.rb" with:
83
83
  """ruby
84
84
  require File.expand_path("../expector", __FILE__)
@@ -102,5 +102,5 @@ Feature: mock with an alternative framework
102
102
  """
103
103
  When I run `rspec example_spec.rb --format doc`
104
104
  Then the exit status should be 1
105
- And the output should contain "2 examples, 1 failure"
106
- And the output should contain "fails when message is received (FAILED - 1)"
105
+ And the output should contain "2 examples, 1 failure"
106
+ And the output should contain "fails when message is received (FAILED - 1)"
@@ -18,7 +18,7 @@ Feature: mock with flexmock
18
18
  end
19
19
  """
20
20
  When I run `rspec example_spec.rb`
21
- Then the examples should all pass
21
+ Then the examples should all pass
22
22
 
23
23
  Scenario: failing message expecation
24
24
  Given a file named "example_spec.rb" with:
@@ -79,7 +79,7 @@ Feature: mock with flexmock
79
79
  Then the output should contain "1 example, 1 failure"
80
80
  And the exit status should be 1
81
81
 
82
- Scenario: accessing RSpec.configuration.mock_framework.framework_name
82
+ Scenario: accessing RSpec.configuration.mock_framework.framework_name
83
83
  Given a file named "example_spec.rb" with:
84
84
  """ruby
85
85
  RSpec.configure do |config|
@@ -93,4 +93,4 @@ Feature: mock with flexmock
93
93
  end
94
94
  """
95
95
  When I run `rspec example_spec.rb`
96
- Then the examples should all pass
96
+ Then the examples should all pass
@@ -18,7 +18,7 @@ Feature: mock with mocha
18
18
  end
19
19
  """
20
20
  When I run `rspec example_spec.rb`
21
- Then the examples should all pass
21
+ Then the examples should all pass
22
22
 
23
23
  Scenario: failing message expecation
24
24
  Given a file named "example_spec.rb" with:
@@ -79,7 +79,7 @@ Feature: mock with mocha
79
79
  Then the output should contain "1 example, 1 failure"
80
80
  And the exit status should be 1
81
81
 
82
- Scenario: accessing RSpec.configuration.mock_framework.framework_name
82
+ Scenario: accessing RSpec.configuration.mock_framework.framework_name
83
83
  Given a file named "example_spec.rb" with:
84
84
  """ruby
85
85
  RSpec.configure do |config|
@@ -93,5 +93,5 @@ Feature: mock with mocha
93
93
  end
94
94
  """
95
95
  When I run `rspec example_spec.rb`
96
- Then the examples should all pass
96
+ Then the examples should all pass
97
97
 
@@ -18,7 +18,7 @@ Feature: mock with rr
18
18
  end
19
19
  """
20
20
  When I run `rspec example_spec.rb`
21
- Then the examples should all pass
21
+ Then the examples should all pass
22
22
 
23
23
  Scenario: failing message expecation
24
24
  Given a file named "example_spec.rb" with:
@@ -79,7 +79,7 @@ Feature: mock with rr
79
79
  Then the output should contain "1 example, 1 failure"
80
80
  And the exit status should be 1
81
81
 
82
- Scenario: accessing RSpec.configuration.mock_framework.framework_name
82
+ Scenario: accessing RSpec.configuration.mock_framework.framework_name
83
83
  Given a file named "example_spec.rb" with:
84
84
  """ruby
85
85
  RSpec.configure do |config|
@@ -93,6 +93,6 @@ Feature: mock with rr
93
93
  end
94
94
  """
95
95
  When I run `rspec example_spec.rb`
96
- Then the examples should all pass
96
+ Then the examples should all pass
97
97
 
98
98