rspec-core 3.0.0.beta1 → 3.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. data.tar.gz.sig +0 -0
  2. data/Changelog.md +137 -0
  3. data/README.md +2 -2
  4. data/exe/rspec +2 -23
  5. data/features/README.md +1 -5
  6. data/features/command_line/README.md +7 -10
  7. data/features/command_line/exit_status.feature +1 -1
  8. data/features/command_line/format_option.feature +1 -1
  9. data/features/command_line/init.feature +40 -1
  10. data/features/command_line/line_number_option.feature +2 -2
  11. data/features/command_line/ruby.feature +5 -4
  12. data/features/configuration/enable_global_dsl.feature +54 -0
  13. data/features/example_groups/aliasing.feature +48 -0
  14. data/features/example_groups/basic_structure.feature +1 -1
  15. data/features/expectation_framework_integration/configure_expectation_framework.feature +1 -1
  16. data/features/filtering/if_and_unless.feature +0 -30
  17. data/features/formatters/custom_formatter.feature +32 -0
  18. data/features/formatters/regression_tests.feature +95 -0
  19. data/features/hooks/around_hooks.feature +1 -0
  20. data/features/hooks/before_and_after_hooks.feature +2 -2
  21. data/features/mock_framework_integration/use_flexmock.feature +11 -13
  22. data/features/mock_framework_integration/use_mocha.feature +11 -13
  23. data/features/mock_framework_integration/use_rr.feature +11 -13
  24. data/features/mock_framework_integration/use_rspec.feature +11 -13
  25. data/features/pending_and_skipped_examples/README.md +3 -0
  26. data/features/pending_and_skipped_examples/pending_examples.feature +118 -0
  27. data/features/pending_and_skipped_examples/skipped_examples.feature +106 -0
  28. data/features/step_definitions/additional_cli_steps.rb +34 -0
  29. data/features/subject/explicit_subject.feature +1 -1
  30. data/features/subject/one_liner_syntax.feature +71 -0
  31. data/lib/rspec/core.rb +6 -14
  32. data/lib/rspec/core/backtrace_formatter.rb +16 -4
  33. data/lib/rspec/core/command_line.rb +2 -3
  34. data/lib/rspec/core/configuration.rb +114 -125
  35. data/lib/rspec/core/configuration_options.rb +32 -18
  36. data/lib/rspec/core/dsl.rb +80 -18
  37. data/lib/rspec/core/example.rb +84 -33
  38. data/lib/rspec/core/example_group.rb +95 -43
  39. data/lib/rspec/core/filter_manager.rb +31 -40
  40. data/lib/rspec/core/formatters.rb +137 -0
  41. data/lib/rspec/core/formatters/base_formatter.rb +28 -41
  42. data/lib/rspec/core/formatters/base_text_formatter.rb +26 -37
  43. data/lib/rspec/core/formatters/deprecation_formatter.rb +48 -27
  44. data/lib/rspec/core/formatters/documentation_formatter.rb +27 -22
  45. data/lib/rspec/core/formatters/html_formatter.rb +48 -56
  46. data/lib/rspec/core/formatters/html_printer.rb +11 -18
  47. data/lib/rspec/core/formatters/json_formatter.rb +18 -22
  48. data/lib/rspec/core/formatters/legacy_formatter.rb +227 -0
  49. data/lib/rspec/core/formatters/progress_formatter.rb +7 -10
  50. data/lib/rspec/core/hooks.rb +250 -217
  51. data/lib/rspec/core/memoized_helpers.rb +43 -9
  52. data/lib/rspec/core/mocking_adapters/flexmock.rb +29 -0
  53. data/lib/rspec/core/{mocking/with_mocha.rb → mocking_adapters/mocha.rb} +19 -16
  54. data/lib/rspec/core/mocking_adapters/null.rb +12 -0
  55. data/lib/rspec/core/mocking_adapters/rr.rb +28 -0
  56. data/lib/rspec/core/mocking_adapters/rspec.rb +30 -0
  57. data/lib/rspec/core/notifications.rb +100 -0
  58. data/lib/rspec/core/option_parser.rb +11 -18
  59. data/lib/rspec/core/pending.rb +78 -47
  60. data/lib/rspec/core/project_initializer.rb +2 -49
  61. data/lib/rspec/core/project_initializer/dot_rspec +3 -0
  62. data/lib/rspec/core/project_initializer/spec_helper.rb +82 -0
  63. data/lib/rspec/core/rake_task.rb +5 -14
  64. data/lib/rspec/core/reporter.rb +24 -32
  65. data/lib/rspec/core/ruby_project.rb +1 -1
  66. data/lib/rspec/core/runner.rb +14 -4
  67. data/lib/rspec/core/shared_example_group.rb +40 -13
  68. data/lib/rspec/core/version.rb +1 -1
  69. data/spec/command_line/order_spec.rb +15 -15
  70. data/spec/rspec/core/backtrace_formatter_spec.rb +15 -1
  71. data/spec/rspec/core/command_line_spec.rb +18 -17
  72. data/spec/rspec/core/configuration_options_spec.rb +57 -34
  73. data/spec/rspec/core/configuration_spec.rb +162 -184
  74. data/spec/rspec/core/drb_command_line_spec.rb +5 -7
  75. data/spec/rspec/core/drb_options_spec.rb +2 -2
  76. data/spec/rspec/core/dsl_spec.rb +79 -15
  77. data/spec/rspec/core/example_group_spec.rb +253 -39
  78. data/spec/rspec/core/example_spec.rb +149 -33
  79. data/spec/rspec/core/filter_manager_spec.rb +9 -26
  80. data/spec/rspec/core/formatters/base_formatter_spec.rb +2 -5
  81. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +42 -145
  82. data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +64 -34
  83. data/spec/rspec/core/formatters/documentation_formatter_spec.rb +15 -28
  84. data/spec/rspec/core/formatters/helpers_spec.rb +2 -2
  85. data/spec/rspec/core/formatters/{html_formatted-1.8.7.html → html_formatted-2.1.0.html} +22 -44
  86. data/spec/rspec/core/formatters/{html_formatted-1.8.7-jruby.html → html_formatted.html} +30 -49
  87. data/spec/rspec/core/formatters/html_formatter_spec.rb +35 -19
  88. data/spec/rspec/core/formatters/json_formatter_spec.rb +42 -40
  89. data/spec/rspec/core/formatters/legacy_formatter_spec.rb +137 -0
  90. data/spec/rspec/core/formatters/progress_formatter_spec.rb +38 -25
  91. data/spec/rspec/core/formatters/snippet_extractor_spec.rb +1 -1
  92. data/spec/rspec/core/formatters_spec.rb +120 -0
  93. data/spec/rspec/core/hooks_filtering_spec.rb +1 -1
  94. data/spec/rspec/core/hooks_spec.rb +13 -2
  95. data/spec/rspec/core/memoized_helpers_spec.rb +17 -8
  96. data/spec/rspec/core/metadata_spec.rb +3 -3
  97. data/spec/rspec/core/option_parser_spec.rb +53 -46
  98. data/spec/rspec/core/ordering_spec.rb +4 -4
  99. data/spec/rspec/core/pending_example_spec.rb +23 -126
  100. data/spec/rspec/core/pending_spec.rb +8 -0
  101. data/spec/rspec/core/project_initializer_spec.rb +8 -41
  102. data/spec/rspec/core/rake_task_spec.rb +15 -4
  103. data/spec/rspec/core/random_spec.rb +1 -1
  104. data/spec/rspec/core/reporter_spec.rb +50 -37
  105. data/spec/rspec/core/resources/formatter_specs.rb +9 -11
  106. data/spec/rspec/core/rspec_matchers_spec.rb +1 -1
  107. data/spec/rspec/core/ruby_project_spec.rb +3 -3
  108. data/spec/rspec/core/runner_spec.rb +65 -23
  109. data/spec/rspec/core/shared_context_spec.rb +4 -4
  110. data/spec/rspec/core/shared_example_group/collection_spec.rb +1 -1
  111. data/spec/rspec/core/shared_example_group_spec.rb +20 -11
  112. data/spec/rspec/core/warnings_spec.rb +1 -1
  113. data/spec/rspec/core/world_spec.rb +10 -10
  114. data/spec/rspec/core_spec.rb +2 -2
  115. data/spec/spec_helper.rb +12 -24
  116. data/spec/support/config_options_helper.rb +1 -3
  117. data/spec/support/formatter_support.rb +83 -0
  118. data/spec/support/isolate_load_path_mutation.rb +1 -2
  119. data/spec/support/isolated_directory.rb +1 -1
  120. data/spec/support/isolated_home_directory.rb +1 -1
  121. data/spec/support/legacy_formatter_using_sub_classing_example.rb +87 -0
  122. data/spec/support/matchers.rb +20 -0
  123. data/spec/support/mathn_integration_support.rb +2 -2
  124. data/spec/support/old_style_formatter_example.rb +69 -0
  125. data/spec/support/shared_example_groups.rb +1 -1
  126. data/spec/support/spec_files.rb +3 -3
  127. metadata +192 -69
  128. metadata.gz.sig +3 -1
  129. checksums.yaml +0 -15
  130. checksums.yaml.gz.sig +0 -2
  131. data/features/configuration/show_failures_in_pending_blocks.feature +0 -61
  132. data/features/pending/pending_examples.feature +0 -229
  133. data/features/subject/implicit_receiver.feature +0 -29
  134. data/lib/rspec/core/mocking/with_absolutely_nothing.rb +0 -11
  135. data/lib/rspec/core/mocking/with_flexmock.rb +0 -27
  136. data/lib/rspec/core/mocking/with_rr.rb +0 -27
  137. data/lib/rspec/core/mocking/with_rspec.rb +0 -27
  138. data/spec/rspec/core/formatters/html_formatted-1.8.7-rbx.html +0 -477
  139. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +0 -425
  140. data/spec/rspec/core/formatters/html_formatted-1.9.3-jruby.html +0 -416
  141. data/spec/rspec/core/formatters/html_formatted-1.9.3-rbx.html +0 -477
  142. data/spec/rspec/core/formatters/html_formatted-1.9.3.html +0 -419
  143. data/spec/rspec/core/formatters/html_formatted-2.0.0.html +0 -425
  144. data/spec/support/in_sub_process.rb +0 -37
  145. data/spec/support/sandboxed_mock_space.rb +0 -100
@@ -23,7 +23,7 @@ Feature: configure expectation framework
23
23
  end
24
24
 
25
25
  describe 6 do
26
- it { should be_a_multiple_of(3) }
26
+ it { is_expected.to be_a_multiple_of 3 }
27
27
  end
28
28
  """
29
29
  When I run `rspec example_spec.rb`
@@ -136,33 +136,3 @@ Feature: :if and :unless
136
136
  | included :if => false example |
137
137
  | included :unless => true example |
138
138
  | excluded |
139
-
140
- Scenario: override implicit :if and :unless exclusion filters
141
- Given a file named "override_implicit_filters_spec.rb" with:
142
- """ruby
143
- RSpec.configure do |c|
144
- c.filter_run_excluding :if => :exclude_me, :unless => :exclude_me_for_unless
145
- end
146
-
147
- describe ":if filtering" do
148
- it(":if => true example", :if => true) { }
149
- it(":if => false example", :if => false) { }
150
- it(":if => :exclude_me example", :if => :exclude_me) { }
151
- end
152
-
153
- describe ":unless filtering" do
154
- it(":unless => true example", :unless => true) { }
155
- it(":unless => false example", :unless => false) { }
156
- it(":unless => :exclude_me_for_unless example", :unless => :exclude_me_for_unless) { }
157
- end
158
- """
159
- When I run `rspec override_implicit_filters_spec.rb --format doc`
160
- Then the output should contain all of these:
161
- | :if => true example |
162
- | :if => false example |
163
- | :unless => true example |
164
- | :unless => false example |
165
- And the output should not contain any of these:
166
- | :if => :exclude_me example |
167
- | :unless => :exclude_me_for_unless example |
168
-
@@ -10,6 +10,37 @@ Feature: custom formatters
10
10
  and then override just the methods that you want to modify.
11
11
 
12
12
  Scenario: custom formatter
13
+ Given a file named "custom_formatter.rb" with:
14
+ """ruby
15
+ require "rspec/core/formatters/base_text_formatter"
16
+
17
+ class CustomFormatter < RSpec::Core::Formatters::BaseTextFormatter
18
+
19
+ # This registers the notifications this formatter supports, and tells
20
+ # us that this was written against the RSpec 3.x formatter API.
21
+ RSpec::Core::Formatters.register self, :example_started
22
+
23
+ def initialize(output)
24
+ super(output)
25
+ end
26
+
27
+ def example_started(notification)
28
+ output << "example: " << notification.example.description
29
+ end
30
+ end
31
+ """
32
+ And a file named "example_spec.rb" with:
33
+ """ruby
34
+ describe "my group" do
35
+ specify "my example" do
36
+ end
37
+ end
38
+ """
39
+ When I run `rspec example_spec.rb --require ./custom_formatter.rb --format CustomFormatter`
40
+ Then the output should contain "example: my example"
41
+ And the exit status should be 0
42
+
43
+ Scenario: a legacy custom formatter
13
44
  Given a file named "custom_formatter.rb" with:
14
45
  """ruby
15
46
  require "rspec/core/formatters/base_text_formatter"
@@ -33,4 +64,5 @@ Feature: custom formatters
33
64
  """
34
65
  When I run `rspec example_spec.rb --require ./custom_formatter.rb --format CustomFormatter`
35
66
  Then the output should contain "example: my example"
67
+ And the output should contain "The CustomFormatter formatter uses the deprecated formatter interface."
36
68
  And the exit status should be 0
@@ -0,0 +1,95 @@
1
+ Feature: Regression tests for legacy custom formatters
2
+
3
+ Background:
4
+ Given a file named ".rspec" with:
5
+ """
6
+ --require spec_helper
7
+ """
8
+ And a file named "spec/spec_helper.rb" with:
9
+ """
10
+ RSpec.configure do |rspec|
11
+ rspec.after(:suite) do
12
+ puts rspec.formatters.map(&:class).inspect
13
+ end
14
+ end
15
+ """
16
+ And a file named "spec/passing_and_failing_spec.rb" with:
17
+ """ruby
18
+ RSpec.describe "Some examples" do
19
+ it "passes" do
20
+ expect(1).to eq(1)
21
+ end
22
+
23
+ it "fails" do
24
+ expect(1).to eq(2)
25
+ end
26
+
27
+ context "nested" do
28
+ it "passes" do
29
+ expect(1).to eq(1)
30
+ end
31
+
32
+ it "fails" do
33
+ expect(1).to eq(2)
34
+ end
35
+ end
36
+ end
37
+ """
38
+ And a file named "spec/pending_spec.rb" with:
39
+ """ruby
40
+ RSpec.describe "Some pending examples" do
41
+ context "pending" do
42
+ it "is reported as pending" do
43
+ pending; expect(1).to eq(2)
44
+ end
45
+
46
+ it "is reported as failing" do
47
+ pending; expect(1).to eq(1)
48
+ end
49
+ end
50
+ end
51
+ """
52
+
53
+ Scenario: Use fuubar formatter
54
+ When I run `rspec --format Fuubar`
55
+ Then the output should contain "Progress: |============"
56
+ And the output should contain "6 examples, 3 failures, 1 pending"
57
+ And the output should contain "The Fuubar formatter uses the deprecated formatter interface"
58
+ But the output should not contain any error backtraces
59
+ And the output should not contain "ProgressFormatter"
60
+
61
+ Scenario: Use rspec-instafail formatter
62
+ When I run `rspec --format RSpec::Instafail`
63
+ Then the output should contain "6 examples, 3 failures, 1 pending"
64
+ And the output should contain "The RSpec::Instafail formatter uses the deprecated formatter interface"
65
+ But the output should not contain any error backtraces
66
+ And the output should not contain "ProgressFormatter"
67
+
68
+ Scenario: Use rspec-extra-formatters JUnit formatter
69
+ When I run `rspec --require rspec-extra-formatters --format JUnitFormatter`
70
+ Then the output should contain:
71
+ """
72
+ <testsuite errors="0" failures="3" skipped="1" tests="6"
73
+ """
74
+ And the output should contain "The JUnitFormatter formatter uses the deprecated formatter interface"
75
+ But the output should not contain any error backtraces
76
+ And the output should not contain "ProgressFormatter"
77
+
78
+ @wip @announce
79
+ Scenario: Use rspec-extra-formatters Tap formatter
80
+ When I run `rspec --require rspec-extra-formatters --format TapFormatter`
81
+ Then the output should contain "TAP version 13"
82
+ And the output should contain "The TapFormatter formatter uses the deprecated formatter interface"
83
+ But the output should not contain any error backtraces
84
+ And the output should not contain "ProgressFormatter"
85
+
86
+ @wip @announce
87
+ Scenario: Use rspec-spinner formatter
88
+ When I run `rspec --require rspec_spinner --format RspecSpinner::Spinner`
89
+ Then the output should contain "TBD"
90
+
91
+ @wip @announce
92
+ Scenario: Use nyancat formatter
93
+ When I run `rspec --format NyanCatFormatter`
94
+ Then the output should contain "TBD"
95
+
@@ -230,6 +230,7 @@ Feature: around hooks
230
230
 
231
231
  it "should be detected as pending" do
232
232
  pending
233
+ fail
233
234
  end
234
235
  end
235
236
  """
@@ -46,7 +46,7 @@ Feature: before and after hooks
46
46
  expect(@thing.widgets.count).to eq(0)
47
47
  end
48
48
 
49
- it "can get accept new widgets" do
49
+ it "can accept new widgets" do
50
50
  @thing.widgets << Object.new
51
51
  end
52
52
 
@@ -80,7 +80,7 @@ Feature: before and after hooks
80
80
  expect(@thing.widgets.count).to eq(0)
81
81
  end
82
82
 
83
- it "can get accept new widgets" do
83
+ it "can accept new widgets" do
84
84
  @thing.widgets << Object.new
85
85
  end
86
86
 
@@ -37,19 +37,18 @@ Feature: mock with flexmock
37
37
  When I run `rspec example_spec.rb`
38
38
  Then the output should contain "1 example, 1 failure"
39
39
 
40
- Scenario: failing message expectation in pending block (remains pending)
40
+ Scenario: failing message expectation in pending example (remains pending)
41
41
  Given a file named "example_spec.rb" with:
42
42
  """ruby
43
43
  RSpec.configure do |config|
44
44
  config.mock_framework = :flexmock
45
45
  end
46
46
 
47
- describe "failed message expectation in a pending block" do
47
+ describe "failed message expectation in a pending example" do
48
48
  it "is listed as pending" do
49
- pending do
50
- receiver = flexmock('receiver')
51
- receiver.should_receive(:message).once
52
- end
49
+ pending
50
+ receiver = flexmock('receiver')
51
+ receiver.should_receive(:message).once
53
52
  end
54
53
  end
55
54
  """
@@ -57,20 +56,19 @@ Feature: mock with flexmock
57
56
  Then the output should contain "1 example, 0 failures, 1 pending"
58
57
  And the exit status should be 0
59
58
 
60
- Scenario: passing message expectation in pending block (fails)
59
+ Scenario: passing message expectation in pending example (fails)
61
60
  Given a file named "example_spec.rb" with:
62
61
  """ruby
63
62
  RSpec.configure do |config|
64
63
  config.mock_framework = :flexmock
65
64
  end
66
65
 
67
- describe "passing message expectation in a pending block" do
66
+ describe "passing message expectation in a pending example" do
68
67
  it "fails with FIXED" do
69
- pending do
70
- receiver = flexmock('receiver')
71
- receiver.should_receive(:message).once
72
- receiver.message
73
- end
68
+ pending
69
+ receiver = flexmock('receiver')
70
+ receiver.should_receive(:message).once
71
+ receiver.message
74
72
  end
75
73
  end
76
74
  """
@@ -37,19 +37,18 @@ Feature: mock with mocha
37
37
  When I run `rspec example_spec.rb`
38
38
  Then the output should contain "1 example, 1 failure"
39
39
 
40
- Scenario: failing message expectation in pending block (remains pending)
40
+ Scenario: failing message expectation in pending example (remains pending)
41
41
  Given a file named "example_spec.rb" with:
42
42
  """ruby
43
43
  RSpec.configure do |config|
44
44
  config.mock_framework = :mocha
45
45
  end
46
46
 
47
- describe "failed message expectation in a pending block" do
47
+ describe "failed message expectation in a pending example" do
48
48
  it "is listed as pending" do
49
- pending do
50
- receiver = mock('receiver')
51
- receiver.expects(:message).once
52
- end
49
+ pending
50
+ receiver = mock('receiver')
51
+ receiver.expects(:message).once
53
52
  end
54
53
  end
55
54
  """
@@ -57,20 +56,19 @@ Feature: mock with mocha
57
56
  Then the output should contain "1 example, 0 failures, 1 pending"
58
57
  And the exit status should be 0
59
58
 
60
- Scenario: passing message expectation in pending block (fails)
59
+ Scenario: passing message expectation in pending example (fails)
61
60
  Given a file named "example_spec.rb" with:
62
61
  """ruby
63
62
  RSpec.configure do |config|
64
63
  config.mock_framework = :mocha
65
64
  end
66
65
 
67
- describe "passing message expectation in a pending block" do
66
+ describe "passing message expectation in a pending example" do
68
67
  it "fails with FIXED" do
69
- pending do
70
- receiver = mock('receiver')
71
- receiver.expects(:message).once
72
- receiver.message
73
- end
68
+ pending
69
+ receiver = mock('receiver')
70
+ receiver.expects(:message).once
71
+ receiver.message
74
72
  end
75
73
  end
76
74
  """
@@ -37,19 +37,18 @@ Feature: mock with rr
37
37
  When I run `rspec example_spec.rb`
38
38
  Then the output should contain "1 example, 1 failure"
39
39
 
40
- Scenario: failing message expectation in pending block (remains pending)
40
+ Scenario: failing message expectation in pending example (remains pending)
41
41
  Given a file named "example_spec.rb" with:
42
42
  """ruby
43
43
  RSpec.configure do |config|
44
44
  config.mock_framework = :rr
45
45
  end
46
46
 
47
- describe "failed message expectation in a pending block" do
47
+ describe "failed message expectation in a pending example" do
48
48
  it "is listed as pending" do
49
- pending do
50
- receiver = Object.new
51
- mock(receiver).message
52
- end
49
+ pending
50
+ receiver = Object.new
51
+ mock(receiver).message
53
52
  end
54
53
  end
55
54
  """
@@ -57,20 +56,19 @@ Feature: mock with rr
57
56
  Then the output should contain "1 example, 0 failures, 1 pending"
58
57
  And the exit status should be 0
59
58
 
60
- Scenario: passing message expectation in pending block (fails)
59
+ Scenario: passing message expectation in pending example (fails)
61
60
  Given a file named "example_spec.rb" with:
62
61
  """ruby
63
62
  RSpec.configure do |config|
64
63
  config.mock_framework = :rr
65
64
  end
66
65
 
67
- describe "passing message expectation in a pending block" do
66
+ describe "passing message expectation in a pending example" do
68
67
  it "fails with FIXED" do
69
- pending do
70
- receiver = Object.new
71
- mock(receiver).message
72
- receiver.message
73
- end
68
+ pending
69
+ receiver = Object.new
70
+ mock(receiver).message
71
+ receiver.message
74
72
  end
75
73
  end
76
74
  """
@@ -38,19 +38,18 @@ Feature: mock with rspec
38
38
  When I run `rspec example_spec.rb`
39
39
  Then the output should contain "1 example, 1 failure"
40
40
 
41
- Scenario: failing message expectation in pending block (remains pending)
41
+ Scenario: failing message expectation in pending example (remains pending)
42
42
  Given a file named "example_spec.rb" with:
43
43
  """ruby
44
44
  RSpec.configure do |config|
45
45
  config.mock_framework = :rspec
46
46
  end
47
47
 
48
- describe "failed message expectation in a pending block" do
48
+ describe "failed message expectation in a pending example" do
49
49
  it "is listed as pending" do
50
- pending do
51
- receiver = double('receiver')
52
- expect(receiver).to receive(:message)
53
- end
50
+ pending
51
+ receiver = double('receiver')
52
+ expect(receiver).to receive(:message)
54
53
  end
55
54
  end
56
55
  """
@@ -58,20 +57,19 @@ Feature: mock with rspec
58
57
  Then the output should contain "1 example, 0 failures, 1 pending"
59
58
  And the exit status should be 0
60
59
 
61
- Scenario: passing message expectation in pending block (fails)
60
+ Scenario: passing message expectation in pending example (fails)
62
61
  Given a file named "example_spec.rb" with:
63
62
  """ruby
64
63
  RSpec.configure do |config|
65
64
  config.mock_framework = :rspec
66
65
  end
67
66
 
68
- describe "passing message expectation in a pending block" do
67
+ describe "passing message expectation in a pending example" do
69
68
  it "fails with FIXED" do
70
- pending do
71
- receiver = double('receiver')
72
- expect(receiver).to receive(:message)
73
- receiver.message
74
- end
69
+ pending
70
+ receiver = double('receiver')
71
+ expect(receiver).to receive(:message)
72
+ receiver.message
75
73
  end
76
74
  end
77
75
  """
@@ -0,0 +1,3 @@
1
+ Sometimes you will have a failing example that can not be fixed, but is useful to keep around. For instance, the fix could depend on an upstream patch being merged, or the example is not supported on JRuby. RSpec provides two features for dealing with this scenario.
2
+
3
+ An example can either be marked as _skipped_, in which is it not executed, or _pending_ in which it is executed but failure will not cause a failure of the entire suite. When a pending example passes (i.e. the underlying reasons for it being marked pending is no longer present) it will fail to communicate to you that it should no longer be marked as pending.
@@ -0,0 +1,118 @@
1
+ Feature: pending examples
2
+
3
+ RSpec offers a number of different ways to indicate that an example is
4
+ disabled pending some action.
5
+
6
+ Scenario: pending any arbitrary reason with a failing example
7
+ Given a file named "pending_without_block_spec.rb" with:
8
+ """ruby
9
+ describe "an example" do
10
+ it "is implemented but waiting" do
11
+ pending("something else getting finished")
12
+ fail
13
+ end
14
+ end
15
+ """
16
+ When I run `rspec pending_without_block_spec.rb`
17
+ Then the exit status should be 0
18
+ And the output should contain "1 example, 0 failures, 1 pending"
19
+ And the output should contain:
20
+ """
21
+ Pending:
22
+ an example is implemented but waiting
23
+ # something else getting finished
24
+ # ./pending_without_block_spec.rb:2
25
+ """
26
+ Scenario: pending any arbitrary reason with a passing example
27
+ Given a file named "pending_with_passing_example_spec.rb" with:
28
+ """ruby
29
+ describe "an example" do
30
+ it "is implemented but waiting" do
31
+ pending("something else getting finished")
32
+ expect(1).to be(1)
33
+ end
34
+ end
35
+ """
36
+ When I run `rspec pending_with_passing_example_spec.rb`
37
+ Then the exit status should not be 0
38
+ And the output should contain "1 example, 1 failure"
39
+ And the output should contain "FIXED"
40
+ And the output should contain "Expected pending 'something else getting finished' to fail. No Error was raised."
41
+ And the output should contain "pending_with_passing_example_spec.rb:2"
42
+
43
+ Scenario: pending for an example that is currently passing
44
+ Given a file named "pending_with_passing_block_spec.rb" with:
45
+ """ruby
46
+ describe "an example" do
47
+ pending("something else getting finished") do
48
+ expect(1).to eq(1)
49
+ end
50
+ end
51
+ """
52
+ When I run `rspec pending_with_passing_block_spec.rb`
53
+ Then the exit status should not be 0
54
+ And the output should contain "1 example, 1 failure"
55
+ And the output should contain "FIXED"
56
+ And the output should contain "Expected pending 'No reason given' to fail. No Error was raised."
57
+ And the output should contain "pending_with_passing_block_spec.rb:2"
58
+
59
+ Scenario: pending for an example that is currently passing with a reason
60
+ Given a file named "pending_with_passing_block_spec.rb" with:
61
+ """ruby
62
+ describe "an example" do
63
+ example("something else getting finished", :pending => 'unimplemented') do
64
+ expect(1).to eq(1)
65
+ end
66
+ end
67
+ """
68
+ When I run `rspec pending_with_passing_block_spec.rb`
69
+ Then the exit status should not be 0
70
+ And the output should contain "1 example, 1 failure"
71
+ And the output should contain "FIXED"
72
+ And the output should contain "Expected pending 'unimplemented' to fail. No Error was raised."
73
+ And the output should contain "pending_with_passing_block_spec.rb:2"
74
+
75
+ Scenario: example with no docstring and pending method using documentation formatter
76
+ Given a file named "pending_with_no_docstring_spec.rb" with:
77
+ """ruby
78
+ describe "an example" do
79
+ it "checks something" do
80
+ expect(1).to eq(1)
81
+ end
82
+ specify do
83
+ pending
84
+ fail
85
+ end
86
+ end
87
+ """
88
+ When I run `rspec pending_with_no_docstring_spec.rb --format documentation`
89
+ Then the exit status should be 0
90
+ And the output should contain "2 examples, 0 failures, 1 pending"
91
+ And the output should contain:
92
+ """
93
+ an example
94
+ checks something
95
+ example at ./pending_with_no_docstring_spec.rb:5 (PENDING: No reason given)
96
+ """
97
+
98
+ Scenario: pending with no docstring using documentation formatter
99
+ Given a file named "pending_with_no_docstring_spec.rb" with:
100
+ """ruby
101
+ describe "an example" do
102
+ it "checks something" do
103
+ expect(1).to eq(1)
104
+ end
105
+ pending do
106
+ fail
107
+ end
108
+ end
109
+ """
110
+ When I run `rspec pending_with_no_docstring_spec.rb --format documentation`
111
+ Then the exit status should be 0
112
+ And the output should contain "2 examples, 0 failures, 1 pending"
113
+ And the output should contain:
114
+ """
115
+ an example
116
+ checks something
117
+ example at ./pending_with_no_docstring_spec.rb:5 (PENDING: No reason given)
118
+ """