rspec-core 2.99.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.sig +0 -0
  3. data/.yardopts +1 -0
  4. data/Changelog.md +339 -1
  5. data/License.txt +1 -0
  6. data/README.md +19 -37
  7. data/exe/rspec +2 -23
  8. data/lib/rspec/core/backport_random.rb +336 -0
  9. data/lib/rspec/core/backtrace_formatter.rb +70 -0
  10. data/lib/rspec/core/configuration.rb +479 -577
  11. data/lib/rspec/core/configuration_options.rb +71 -54
  12. data/lib/rspec/core/drb.rb +111 -0
  13. data/lib/rspec/core/dsl.rb +86 -18
  14. data/lib/rspec/core/example.rb +267 -119
  15. data/lib/rspec/core/example_group.rb +381 -393
  16. data/lib/rspec/core/filter_manager.rb +133 -114
  17. data/lib/rspec/core/flat_map.rb +18 -0
  18. data/lib/rspec/core/formatters/base_formatter.rb +51 -125
  19. data/lib/rspec/core/formatters/base_text_formatter.rb +34 -286
  20. data/lib/rspec/core/formatters/console_codes.rb +24 -1
  21. data/lib/rspec/core/formatters/deprecation_formatter.rb +25 -26
  22. data/lib/rspec/core/formatters/documentation_formatter.rb +27 -25
  23. data/lib/rspec/core/formatters/helpers.rb +14 -36
  24. data/lib/rspec/core/formatters/html_formatter.rb +58 -65
  25. data/lib/rspec/core/formatters/html_printer.rb +12 -18
  26. data/lib/rspec/core/formatters/json_formatter.rb +54 -31
  27. data/lib/rspec/core/formatters/profile_formatter.rb +67 -0
  28. data/lib/rspec/core/formatters/progress_formatter.rb +11 -15
  29. data/lib/rspec/core/formatters/snippet_extractor.rb +22 -11
  30. data/lib/rspec/core/formatters.rb +90 -43
  31. data/lib/rspec/core/hooks.rb +325 -270
  32. data/lib/rspec/core/memoized_helpers.rb +45 -156
  33. data/lib/rspec/core/metadata.rb +284 -236
  34. data/lib/rspec/core/metadata_filter.rb +86 -0
  35. data/lib/rspec/core/mocking_adapters/flexmock.rb +29 -0
  36. data/lib/rspec/core/{mocking/with_mocha.rb → mocking_adapters/mocha.rb} +19 -16
  37. data/lib/rspec/core/mocking_adapters/null.rb +12 -0
  38. data/lib/rspec/core/mocking_adapters/rr.rb +29 -0
  39. data/lib/rspec/core/mocking_adapters/rspec.rb +30 -0
  40. data/lib/rspec/core/notifications.rb +511 -0
  41. data/lib/rspec/core/option_parser.rb +49 -74
  42. data/lib/rspec/core/ordering.rb +156 -0
  43. data/lib/rspec/core/pending.rb +94 -96
  44. data/lib/rspec/core/project_initializer/.rspec +3 -0
  45. data/lib/rspec/core/project_initializer/spec/spec_helper.rb +78 -0
  46. data/lib/rspec/core/project_initializer.rb +24 -64
  47. data/lib/rspec/core/rake_task.rb +44 -130
  48. data/lib/rspec/core/reporter.rb +76 -59
  49. data/lib/rspec/core/ruby_project.rb +2 -1
  50. data/lib/rspec/core/runner.rb +117 -52
  51. data/lib/rspec/core/shared_context.rb +10 -10
  52. data/lib/rspec/core/shared_example_group.rb +108 -121
  53. data/lib/rspec/core/version.rb +3 -1
  54. data/lib/rspec/core/warnings.rb +40 -0
  55. data/lib/rspec/core/world.rb +66 -10
  56. data/lib/rspec/core.rb +64 -104
  57. data.tar.gz.sig +3 -0
  58. metadata +75 -322
  59. metadata.gz.sig +1 -0
  60. data/exe/autospec +0 -13
  61. data/features/Autotest.md +0 -38
  62. data/features/README.md +0 -17
  63. data/features/Upgrade.md +0 -364
  64. data/features/command_line/README.md +0 -28
  65. data/features/command_line/example_name_option.feature +0 -97
  66. data/features/command_line/exit_status.feature +0 -82
  67. data/features/command_line/format_option.feature +0 -75
  68. data/features/command_line/init.feature +0 -18
  69. data/features/command_line/line_number_appended_to_path.feature +0 -140
  70. data/features/command_line/line_number_option.feature +0 -53
  71. data/features/command_line/order.feature +0 -26
  72. data/features/command_line/pattern_option.feature +0 -49
  73. data/features/command_line/rake_task.feature +0 -122
  74. data/features/command_line/require_option.feature +0 -43
  75. data/features/command_line/ruby.feature +0 -22
  76. data/features/command_line/tag.feature +0 -98
  77. data/features/command_line/warnings_option.feature +0 -29
  78. data/features/configuration/alias_example_to.feature +0 -48
  79. data/features/configuration/backtrace_clean_patterns.feature +0 -102
  80. data/features/configuration/custom_settings.feature +0 -84
  81. data/features/configuration/default_path.feature +0 -38
  82. data/features/configuration/deprecation_stream.feature +0 -58
  83. data/features/configuration/fail_fast.feature +0 -77
  84. data/features/configuration/failure_exit_code.feature +0 -36
  85. data/features/configuration/order_and_seed.feature +0 -3
  86. data/features/configuration/output_stream.feature +0 -24
  87. data/features/configuration/pattern.feature +0 -38
  88. data/features/configuration/profile.feature +0 -220
  89. data/features/configuration/read_options_from_file.feature +0 -90
  90. data/features/configuration/run_all_when_everything_filtered.feature +0 -76
  91. data/features/configuration/show_failures_in_pending_blocks.feature +0 -61
  92. data/features/configuration/treat_symbols_as_metadata_keys_with_true_values.feature +0 -52
  93. data/features/example_groups/basic_structure.feature +0 -55
  94. data/features/example_groups/shared_context.feature +0 -74
  95. data/features/example_groups/shared_examples.feature +0 -294
  96. data/features/expectation_framework_integration/configure_expectation_framework.feature +0 -197
  97. data/features/filtering/exclusion_filters.feature +0 -138
  98. data/features/filtering/if_and_unless.feature +0 -168
  99. data/features/filtering/inclusion_filters.feature +0 -105
  100. data/features/formatters/configurable_colors.feature +0 -31
  101. data/features/formatters/custom_formatter.feature +0 -36
  102. data/features/formatters/json_formatter.feature +0 -30
  103. data/features/formatters/text_formatter.feature +0 -46
  104. data/features/helper_methods/arbitrary_methods.feature +0 -40
  105. data/features/helper_methods/let.feature +0 -50
  106. data/features/helper_methods/modules.feature +0 -149
  107. data/features/hooks/around_hooks.feature +0 -343
  108. data/features/hooks/before_and_after_hooks.feature +0 -427
  109. data/features/hooks/filtering.feature +0 -234
  110. data/features/metadata/current_example.feature +0 -56
  111. data/features/metadata/described_class.feature +0 -17
  112. data/features/metadata/user_defined.feature +0 -113
  113. data/features/mock_framework_integration/use_any_framework.feature +0 -106
  114. data/features/mock_framework_integration/use_flexmock.feature +0 -96
  115. data/features/mock_framework_integration/use_mocha.feature +0 -97
  116. data/features/mock_framework_integration/use_rr.feature +0 -98
  117. data/features/mock_framework_integration/use_rspec.feature +0 -97
  118. data/features/pending/pending_examples.feature +0 -229
  119. data/features/spec_files/arbitrary_file_suffix.feature +0 -13
  120. data/features/step_definitions/additional_cli_steps.rb +0 -49
  121. data/features/subject/attribute_of_subject.feature +0 -124
  122. data/features/subject/explicit_subject.feature +0 -101
  123. data/features/subject/implicit_subject.feature +0 -63
  124. data/features/subject/one_liner_syntax.feature +0 -71
  125. data/features/support/env.rb +0 -14
  126. data/features/support/rubinius.rb +0 -6
  127. data/lib/autotest/discover.rb +0 -10
  128. data/lib/autotest/rspec2.rb +0 -77
  129. data/lib/rspec/core/backtrace_cleaner.rb +0 -46
  130. data/lib/rspec/core/backward_compatibility.rb +0 -55
  131. data/lib/rspec/core/caller_filter.rb +0 -60
  132. data/lib/rspec/core/command_line.rb +0 -47
  133. data/lib/rspec/core/deprecated_mutable_array_proxy.rb +0 -32
  134. data/lib/rspec/core/deprecation.rb +0 -26
  135. data/lib/rspec/core/drb_command_line.rb +0 -26
  136. data/lib/rspec/core/drb_options.rb +0 -87
  137. data/lib/rspec/core/extensions/instance_eval_with_args.rb +0 -44
  138. data/lib/rspec/core/extensions/kernel.rb +0 -9
  139. data/lib/rspec/core/extensions/module_eval_with_args.rb +0 -38
  140. data/lib/rspec/core/extensions/ordered.rb +0 -27
  141. data/lib/rspec/core/formatters/text_mate_formatter.rb +0 -34
  142. data/lib/rspec/core/metadata_hash_builder.rb +0 -97
  143. data/lib/rspec/core/mocking/with_absolutely_nothing.rb +0 -11
  144. data/lib/rspec/core/mocking/with_flexmock.rb +0 -27
  145. data/lib/rspec/core/mocking/with_rr.rb +0 -27
  146. data/lib/rspec/core/mocking/with_rspec.rb +0 -27
  147. data/lib/rspec/core/shared_example_group/collection.rb +0 -45
  148. data/spec/autotest/discover_spec.rb +0 -49
  149. data/spec/autotest/failed_results_re_spec.rb +0 -45
  150. data/spec/autotest/rspec_spec.rb +0 -133
  151. data/spec/command_line/order_spec.rb +0 -204
  152. data/spec/rspec/core/backtrace_cleaner_spec.rb +0 -68
  153. data/spec/rspec/core/caller_filter_spec.rb +0 -58
  154. data/spec/rspec/core/command_line_spec.rb +0 -127
  155. data/spec/rspec/core/command_line_spec_output.txt +0 -0
  156. data/spec/rspec/core/configuration_options_spec.rb +0 -417
  157. data/spec/rspec/core/configuration_spec.rb +0 -2072
  158. data/spec/rspec/core/deprecation_spec.rb +0 -27
  159. data/spec/rspec/core/deprecations_spec.rb +0 -59
  160. data/spec/rspec/core/drb_command_line_spec.rb +0 -102
  161. data/spec/rspec/core/drb_options_spec.rb +0 -193
  162. data/spec/rspec/core/dsl_spec.rb +0 -25
  163. data/spec/rspec/core/example_group_spec.rb +0 -1337
  164. data/spec/rspec/core/example_spec.rb +0 -502
  165. data/spec/rspec/core/filter_manager_spec.rb +0 -246
  166. data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -108
  167. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +0 -524
  168. data/spec/rspec/core/formatters/console_codes_spec.rb +0 -50
  169. data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +0 -263
  170. data/spec/rspec/core/formatters/documentation_formatter_spec.rb +0 -89
  171. data/spec/rspec/core/formatters/helpers_spec.rb +0 -104
  172. data/spec/rspec/core/formatters/html_formatted.html +0 -397
  173. data/spec/rspec/core/formatters/html_formatter_spec.rb +0 -131
  174. data/spec/rspec/core/formatters/json_formatter_spec.rb +0 -115
  175. data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -30
  176. data/spec/rspec/core/formatters/snippet_extractor_spec.rb +0 -26
  177. data/spec/rspec/core/formatters/text_mate_formatted.html +0 -397
  178. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +0 -107
  179. data/spec/rspec/core/hooks_filtering_spec.rb +0 -227
  180. data/spec/rspec/core/hooks_spec.rb +0 -269
  181. data/spec/rspec/core/kernel_extensions_spec.rb +0 -9
  182. data/spec/rspec/core/memoized_helpers_spec.rb +0 -776
  183. data/spec/rspec/core/metadata_spec.rb +0 -514
  184. data/spec/rspec/core/option_parser_spec.rb +0 -297
  185. data/spec/rspec/core/pending_example_spec.rb +0 -260
  186. data/spec/rspec/core/pending_spec.rb +0 -27
  187. data/spec/rspec/core/project_initializer_spec.rb +0 -130
  188. data/spec/rspec/core/rake_task_spec.rb +0 -202
  189. data/spec/rspec/core/reporter_spec.rb +0 -167
  190. data/spec/rspec/core/resources/a_bar.rb +0 -0
  191. data/spec/rspec/core/resources/a_foo.rb +0 -0
  192. data/spec/rspec/core/resources/a_spec.rb +0 -1
  193. data/spec/rspec/core/resources/custom_example_group_runner.rb +0 -14
  194. data/spec/rspec/core/resources/formatter_specs.rb +0 -60
  195. data/spec/rspec/core/resources/utf8_encoded.rb +0 -8
  196. data/spec/rspec/core/rspec_matchers_spec.rb +0 -45
  197. data/spec/rspec/core/ruby_project_spec.rb +0 -26
  198. data/spec/rspec/core/runner_spec.rb +0 -82
  199. data/spec/rspec/core/shared_context_spec.rb +0 -114
  200. data/spec/rspec/core/shared_example_group/collection_spec.rb +0 -70
  201. data/spec/rspec/core/shared_example_group_spec.rb +0 -138
  202. data/spec/rspec/core/world_spec.rb +0 -142
  203. data/spec/rspec/core_spec.rb +0 -108
  204. data/spec/spec_helper.rb +0 -135
  205. data/spec/support/config_options_helper.rb +0 -15
  206. data/spec/support/helper_methods.rb +0 -55
  207. data/spec/support/in_sub_process.rb +0 -37
  208. data/spec/support/isolate_load_path_mutation.rb +0 -6
  209. data/spec/support/isolated_directory.rb +0 -10
  210. data/spec/support/isolated_home_directory.rb +0 -16
  211. data/spec/support/matchers.rb +0 -65
  212. data/spec/support/mathn_integration_support.rb +0 -12
  213. data/spec/support/sandboxed_mock_space.rb +0 -116
  214. data/spec/support/shared_example_groups.rb +0 -42
  215. data/spec/support/silence_dsl_deprecations.rb +0 -32
  216. data/spec/support/spec_files.rb +0 -44
@@ -1,168 +0,0 @@
1
- Feature: :if and :unless
2
-
3
- The `:if` and `:unless` metadata keys can be used to filter examples without
4
- needing to configure an exclusion filter.
5
-
6
- Scenario: implicit :if filter
7
- Given a file named "implicit_if_filter_spec.rb" with:
8
- """ruby
9
- describe ":if => true group", :if => true do
10
- it(":if => true group :if => true example", :if => true) { }
11
- it(":if => true group :if => false example", :if => false) { }
12
- it(":if => true group no :if example") { }
13
- end
14
-
15
- describe ":if => false group", :if => false do
16
- it(":if => false group :if => true example", :if => true) { }
17
- it(":if => false group :if => false example", :if => false) { }
18
- it(":if => false group no :if example") { }
19
- end
20
-
21
- describe "no :if group" do
22
- it("no :if group :if => true example", :if => true) { }
23
- it("no :if group :if => false example", :if => false) { }
24
- it("no :if group no :if example") { }
25
- end
26
- """
27
- When I run `rspec implicit_if_filter_spec.rb --format doc`
28
- Then the output should contain all of these:
29
- | :if => true group :if => true example |
30
- | :if => true group no :if example |
31
- | :if => false group :if => true example |
32
- | no :if group :if => true example |
33
- | no :if group no :if example |
34
- And the output should not contain any of these:
35
- | :if => true group :if => false example |
36
- | :if => false group :if => false example |
37
- | :if => false group no :if example |
38
- | no :if group :if => false example |
39
-
40
- Scenario: implicit :unless filter
41
- Given a file named "implicit_unless_filter_spec.rb" with:
42
- """ruby
43
- describe ":unless => true group", :unless => true do
44
- it(":unless => true group :unless => true example", :unless => true) { }
45
- it(":unless => true group :unless => false example", :unless => false) { }
46
- it(":unless => true group no :unless example") { }
47
- end
48
-
49
- describe ":unless => false group", :unless => false do
50
- it(":unless => false group :unless => true example", :unless => true) { }
51
- it(":unless => false group :unless => false example", :unless => false) { }
52
- it(":unless => false group no :unless example") { }
53
- end
54
-
55
- describe "no :unless group" do
56
- it("no :unless group :unless => true example", :unless => true) { }
57
- it("no :unless group :unless => false example", :unless => false) { }
58
- it("no :unless group no :unless example") { }
59
- end
60
- """
61
- When I run `rspec implicit_unless_filter_spec.rb --format doc`
62
- Then the output should contain all of these:
63
- | :unless => true group :unless => false example |
64
- | :unless => false group :unless => false example |
65
- | :unless => false group no :unless example |
66
- | no :unless group :unless => false example |
67
- | no :unless group no :unless example |
68
- And the output should not contain any of these:
69
- | :unless => true group :unless => true example |
70
- | :unless => true group no :unless example |
71
- | :unless => false group :unless => true example |
72
- | no :unless group :unless => true example |
73
-
74
- Scenario: combining implicit filter with explicit inclusion filter
75
- Given a file named "explicit_inclusion_filter_spec.rb" with:
76
- """ruby
77
- RSpec.configure do |c|
78
- c.filter_run :focus => true
79
- end
80
-
81
- describe "group with :focus", :focus => true do
82
- it("focused example") { }
83
- it("focused :if => true example", :if => true) { }
84
- it("focused :if => false example", :if => false) { }
85
- it("focused :unless => true example", :unless => true) { }
86
- it("focused :unless => false example", :unless => false) { }
87
- end
88
-
89
- describe "group without :focus" do
90
- it("unfocused example") { }
91
- it("unfocused :if => true example", :if => true) { }
92
- it("unfocused :if => false example", :if => false) { }
93
- it("unfocused :unless => true example", :unless => true) { }
94
- it("unfocused :unless => false example", :unless => false) { }
95
- end
96
- """
97
- When I run `rspec explicit_inclusion_filter_spec.rb --format doc`
98
- Then the output should contain all of these:
99
- | focused example |
100
- | focused :if => true example |
101
- | focused :unless => false example |
102
- And the output should not contain any of these:
103
- | focused :if => false example |
104
- | focused :unless => true example |
105
- | unfocused |
106
-
107
- Scenario: combining implicit filter with explicit exclusion filter
108
- Given a file named "explicit_exclusion_filter_spec.rb" with:
109
- """ruby
110
- RSpec.configure do |c|
111
- c.filter_run_excluding :broken => true
112
- end
113
-
114
- describe "unbroken group" do
115
- it("included example") { }
116
- it("included :if => true example", :if => true) { }
117
- it("included :if => false example", :if => false) { }
118
- it("included :unless => true example", :unless => true) { }
119
- it("included :unless => false example", :unless => false) { }
120
- end
121
-
122
- describe "broken group", :broken => true do
123
- it("excluded example") { }
124
- it("excluded :if => true example", :if => true) { }
125
- it("excluded :if => false example", :if => false) { }
126
- it("excluded :unless => true example", :unless => true) { }
127
- it("excluded :unless => false example", :unless => false) { }
128
- end
129
- """
130
- When I run `rspec explicit_exclusion_filter_spec.rb --format doc`
131
- Then the output should contain all of these:
132
- | included example |
133
- | included :if => true example |
134
- | included :unless => false example |
135
- And the output should not contain any of these:
136
- | included :if => false example |
137
- | included :unless => true example |
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
-
@@ -1,105 +0,0 @@
1
- Feature: inclusion filters
2
-
3
- You can constrain which examples are run by declaring an inclusion filter. The
4
- most common use case is to focus on a subset of examples as you're focused on
5
- a particular problem.
6
-
7
- You can specify metadata using only symbols if you set the
8
- `treat_symbols_as_metadata_keys_with_true_values` config option to `true`.
9
-
10
- Background:
11
- Given a file named "spec/spec_helper.rb" with:
12
- """ruby
13
- RSpec.configure do |c|
14
- c.filter_run_including :focus => true
15
- end
16
- """
17
-
18
- Scenario: focus on an example
19
- Given a file named "spec/sample_spec.rb" with:
20
- """ruby
21
- require "spec_helper"
22
-
23
- describe "something" do
24
- it "does one thing" do
25
- end
26
-
27
- it "does another thing", :focus => true do
28
- end
29
- end
30
- """
31
- When I run `rspec spec/sample_spec.rb --format doc`
32
- Then the output should contain "does another thing"
33
- And the output should not contain "does one thing"
34
-
35
- Scenario: focus on a group
36
- Given a file named "spec/sample_spec.rb" with:
37
- """ruby
38
- require "spec_helper"
39
-
40
- describe "group 1", :focus => true do
41
- it "group 1 example 1" do
42
- end
43
-
44
- it "group 1 example 2" do
45
- end
46
- end
47
-
48
- describe "group 2" do
49
- it "group 2 example 1" do
50
- end
51
- end
52
- """
53
- When I run `rspec spec/sample_spec.rb --format doc`
54
- Then the output should contain "group 1 example 1"
55
- And the output should contain "group 1 example 2"
56
- And the output should not contain "group 2 example 1"
57
-
58
- Scenario: before/after(:all) hooks in unmatched example group are not run
59
- Given a file named "spec/before_after_all_inclusion_filter_spec.rb" with:
60
- """ruby
61
- require "spec_helper"
62
-
63
- describe "group 1", :focus => true do
64
- before(:all) { puts "before all in focused group" }
65
- after(:all) { puts "after all in focused group" }
66
-
67
- it "group 1 example" do
68
- end
69
- end
70
-
71
- describe "group 2" do
72
- before(:all) { puts "before all in unfocused group" }
73
- after(:all) { puts "after all in unfocused group" }
74
-
75
- context "context 1" do
76
- it "group 2 context 1 example 1" do
77
- end
78
- end
79
- end
80
- """
81
- When I run `rspec ./spec/before_after_all_inclusion_filter_spec.rb`
82
- Then the output should contain "before all in focused group"
83
- And the output should contain "after all in focused group"
84
- And the output should not contain "before all in unfocused group"
85
- And the output should not contain "after all in unfocused group"
86
-
87
- Scenario: Use symbols as metadata
88
- Given a file named "symbols_as_metadata_spec.rb" with:
89
- """ruby
90
- RSpec.configure do |c|
91
- c.treat_symbols_as_metadata_keys_with_true_values = true
92
- c.filter_run :current_example
93
- end
94
-
95
- describe "something" do
96
- it "does one thing" do
97
- end
98
-
99
- it "does another thing", :current_example do
100
- end
101
- end
102
- """
103
- When I run `rspec symbols_as_metadata_spec.rb --format doc`
104
- Then the output should contain "does another thing"
105
- And the output should not contain "does one thing"
@@ -1,31 +0,0 @@
1
- Feature: Configurable colors
2
-
3
- RSpec allows you to configure the terminal colors used in the text formatters.
4
-
5
- * `failure_color`: Color used when tests fail (default: `:red`)
6
- * `success_color`: Color used when tests pass (default: `:green`)
7
- * `pending_color`: Color used when tests are pending (default: `:yellow`)
8
- * `fixed_color`: Color used when a pending block inside an example passes, but was expected to fail (default: `:blue`)
9
- * `detail_color`: Color used for miscellaneous test details (default: `:cyan`)
10
-
11
- Colors are normally specified as symbols. Options are `:black`, `:red`,
12
- `:green`, `:yellow`, `:blue`, `:magenta`, `:cyan`, and `:white`.
13
-
14
- @ansi
15
- Scenario: Customizing the failure color
16
- Given a file named "custom_failure_color_spec.rb" with:
17
- """ruby
18
- RSpec.configure do |config|
19
- config.failure_color = :magenta
20
- config.tty = true
21
- config.color = true
22
- end
23
-
24
- describe "failure" do
25
- it "fails and uses the custom color" do
26
- expect(2).to eq(4)
27
- end
28
- end
29
- """
30
- When I run `rspec custom_failure_color_spec.rb --format progress`
31
- Then the failing example is printed in magenta
@@ -1,36 +0,0 @@
1
- Feature: custom formatters
2
-
3
- RSpec ships with general purpose output formatters. You can tell RSpec which
4
- one to use using the [`--format` command line
5
- option]('../command_line/format_option').
6
-
7
- When RSpec's built-in output formatters don't, however, give you everything
8
- you need, you can write your own custom formatter and tell RSpec to use that
9
- one instead. The simplest way is to subclass RSpec's `BaseTextFormatter`,
10
- and then override just the methods that you want to modify.
11
-
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
- def initialize(output)
19
- super(output)
20
- end
21
-
22
- def example_started(proxy)
23
- output << "example: " << proxy.description
24
- end
25
- end
26
- """
27
- And a file named "example_spec.rb" with:
28
- """ruby
29
- describe "my group" do
30
- specify "my example" do
31
- end
32
- end
33
- """
34
- When I run `rspec example_spec.rb --require ./custom_formatter.rb --format CustomFormatter`
35
- Then the output should contain "example: my example"
36
- And the exit status should be 0
@@ -1,30 +0,0 @@
1
- Feature: JSON formatter
2
-
3
- Scenario: Formatting example names for retry
4
- Given a file named "various_spec.rb" with:
5
- """ruby
6
- describe "Various" do
7
- it "fails" do
8
- "fail".should eq("succeed")
9
- end
10
-
11
- it "succeeds" do
12
- "succeed".should eq("succeed")
13
- end
14
-
15
- it "pends"
16
- end
17
- """
18
- When I run `rspec various_spec.rb --format j`
19
- Then the output should contain all of these:
20
- |"summary_line":"3 examples, 1 failure, 1 pending"|
21
- |"examples":[ |
22
- |"description":"fails" |
23
- |"full_description":"Various fails" |
24
- |"status":"failed" |
25
- |"file_path":"./various_spec.rb" |
26
- |"line_number":2 |
27
- |"exception":{ |
28
- |"class":"RSpec::Expectations::ExpectationNotMetError"|
29
-
30
- And the exit status should be 1
@@ -1,46 +0,0 @@
1
- Feature: text formatter
2
-
3
- In order to easily see the result of running my specs
4
- As an RSpec user
5
- I want clear, concise, well-formatted output
6
-
7
- Scenario: Backtrace formatting for failing specs in multiple files
8
- Given a file named "string_spec.rb" with:
9
- """ruby
10
- describe String do
11
- it "has a failing example" do
12
- "foo".reverse.should eq("ofo")
13
- end
14
- end
15
- """
16
- And a file named "integer_spec.rb" with:
17
- """ruby
18
- describe Integer do
19
- it "has a failing example" do
20
- (7 + 5).should eq(11)
21
- end
22
- end
23
- """
24
- When I run `rspec integer_spec.rb string_spec.rb`
25
- Then the backtrace-normalized output should contain:
26
- """
27
- 1) Integer has a failing example
28
- Failure/Error: (7 + 5).should eq(11)
29
-
30
- expected: 11
31
- got: 12
32
-
33
- (compared using ==)
34
- # ./integer_spec.rb:3
35
- """
36
- And the backtrace-normalized output should contain:
37
- """
38
- 2) String has a failing example
39
- Failure/Error: "foo".reverse.should eq("ofo")
40
-
41
- expected: "ofo"
42
- got: "oof"
43
-
44
- (compared using ==)
45
- # ./string_spec.rb:3
46
- """
@@ -1,40 +0,0 @@
1
- Feature: arbitrary helper methods
2
-
3
- You can define methods in any example group using Ruby's `def` keyword or
4
- `define_method` method. These _helper_ methods are exposed to examples in the
5
- group in which they are defined and groups nested within that group, but not
6
- parent or sibling groups.
7
-
8
- Scenario: use a method defined in the same group
9
- Given a file named "example_spec.rb" with:
10
- """ruby
11
- describe "an example" do
12
- def help
13
- :available
14
- end
15
-
16
- it "has access to methods defined in its group" do
17
- help.should be(:available)
18
- end
19
- end
20
- """
21
- When I run `rspec example_spec.rb`
22
- Then the examples should all pass
23
-
24
- Scenario: use a method defined in a parent group
25
- Given a file named "example_spec.rb" with:
26
- """ruby
27
- describe "an example" do
28
- def help
29
- :available
30
- end
31
-
32
- describe "in a nested group" do
33
- it "has access to methods defined in its parent group" do
34
- help.should be(:available)
35
- end
36
- end
37
- end
38
- """
39
- When I run `rspec example_spec.rb`
40
- Then the examples should all pass
@@ -1,50 +0,0 @@
1
- Feature: let and let!
2
-
3
- Use `let` to define a memoized helper method. The value will be cached
4
- across multiple calls in the same example but not across examples.
5
-
6
- Note that `let` is lazy-evaluated: it is not evaluated until the first time
7
- the method it defines is invoked. You can use `let!` to force the method's
8
- invocation before each example.
9
-
10
- Scenario: use let to define memoized helper method
11
- Given a file named "let_spec.rb" with:
12
- """ruby
13
- $count = 0
14
- describe "let" do
15
- let(:count) { $count += 1 }
16
-
17
- it "memoizes the value" do
18
- count.should eq(1)
19
- count.should eq(1)
20
- end
21
-
22
- it "is not cached across examples" do
23
- count.should eq(2)
24
- end
25
- end
26
- """
27
- When I run `rspec let_spec.rb`
28
- Then the examples should all pass
29
-
30
- Scenario: use let! to define a memoized helper method that is called in a before hook
31
- Given a file named "let_bang_spec.rb" with:
32
- """ruby
33
- $count = 0
34
- describe "let!" do
35
- invocation_order = []
36
-
37
- let!(:count) do
38
- invocation_order << :let!
39
- $count += 1
40
- end
41
-
42
- it "calls the helper method in a before hook" do
43
- invocation_order << :example
44
- invocation_order.should == [:let!, :example]
45
- count.should eq(1)
46
- end
47
- end
48
- """
49
- When I run `rspec let_bang_spec.rb`
50
- Then the examples should all pass
@@ -1,149 +0,0 @@
1
- Feature: Define helper methods in a module
2
-
3
- You can define helper methods in a module and include it in
4
- your example groups using the `config.include` configuration
5
- option. `config.extend` can be used to extend the module onto
6
- your example groups so that the methods in the module are available
7
- in the example groups themselves (but not in the actual examples).
8
-
9
- You can also include or extend the module onto only certain example
10
- groups by passing a metadata hash as the last argument. Only groups
11
- that match the given metadata will include or extend the module.
12
-
13
- If you set the `treat_symbols_as_metadata_keys_with_true_values` config option
14
- to `true`, you can specify metadata using only symbols.
15
-
16
- Background:
17
- Given a file named "helpers.rb" with:
18
- """ruby
19
- module Helpers
20
- def help
21
- :available
22
- end
23
- end
24
- """
25
-
26
- Scenario: include a module in all example groups
27
- Given a file named "include_module_spec.rb" with:
28
- """ruby
29
- require './helpers'
30
-
31
- RSpec.configure do |c|
32
- c.include Helpers
33
- end
34
-
35
- describe "an example group" do
36
- it "has access to the helper methods defined in the module" do
37
- help.should be(:available)
38
- end
39
- end
40
- """
41
- When I run `rspec include_module_spec.rb`
42
- Then the examples should all pass
43
-
44
- Scenario: extend a module in all example groups
45
- Given a file named "extend_module_spec.rb" with:
46
- """ruby
47
- require './helpers'
48
-
49
- RSpec.configure do |c|
50
- c.extend Helpers
51
- end
52
-
53
- describe "an example group" do
54
- puts "Help is #{help}"
55
-
56
- it "does not have access to the helper methods defined in the module" do
57
- expect { help }.to raise_error(NameError)
58
- end
59
- end
60
- """
61
- When I run `rspec extend_module_spec.rb`
62
- Then the examples should all pass
63
- And the output should contain "Help is available"
64
-
65
- Scenario: include a module in only some example groups
66
- Given a file named "include_module_in_some_groups_spec.rb" with:
67
- """ruby
68
- require './helpers'
69
-
70
- RSpec.configure do |c|
71
- c.include Helpers, :foo => :bar
72
- end
73
-
74
- describe "an example group with matching metadata", :foo => :bar do
75
- it "has access to the helper methods defined in the module" do
76
- help.should be(:available)
77
- end
78
- end
79
-
80
- describe "an example group without matching metadata" do
81
- it "does not have access to the helper methods defined in the module" do
82
- expect { help }.to raise_error(NameError)
83
- end
84
- end
85
- """
86
- When I run `rspec include_module_in_some_groups_spec.rb`
87
- Then the examples should all pass
88
-
89
- Scenario: extend a module in only some example groups
90
- Given a file named "extend_module_in_only_some_groups_spec.rb" with:
91
- """ruby
92
- require './helpers'
93
-
94
- RSpec.configure do |c|
95
- c.extend Helpers, :foo => :bar
96
- end
97
-
98
- describe "an example group with matching metadata", :foo => :bar do
99
- puts "In a matching group, help is #{help}"
100
-
101
- it "does not have access to the helper methods defined in the module" do
102
- expect { help }.to raise_error(NameError)
103
- end
104
- end
105
-
106
- describe "an example group without matching metadata" do
107
- puts "In a non-matching group, help is #{help rescue 'not available'}"
108
-
109
- it "does not have access to the helper methods defined in the module" do
110
- expect { help }.to raise_error(NameError)
111
- end
112
- end
113
- """
114
- When I run `rspec extend_module_in_only_some_groups_spec.rb`
115
- Then the examples should all pass
116
- And the output should contain "In a matching group, help is available"
117
- And the output should contain "In a non-matching group, help is not available"
118
-
119
- Scenario: use symbols as metadata
120
- Given a file named "symbols_as_metadata_spec.rb" with:
121
- """ruby
122
- require './helpers'
123
-
124
- RSpec.configure do |c|
125
- c.treat_symbols_as_metadata_keys_with_true_values = true
126
- c.include Helpers, :include_helpers
127
- c.extend Helpers, :extend_helpers
128
- end
129
-
130
- describe "an example group with matching include metadata", :include_helpers do
131
- puts "In a group not matching the extend filter, help is #{help rescue 'not available'}"
132
-
133
- it "has access to the helper methods defined in the module" do
134
- help.should be(:available)
135
- end
136
- end
137
-
138
- describe "an example group with matching extend metadata", :extend_helpers do
139
- puts "In a group matching the extend filter, help is #{help}"
140
-
141
- it "does not have access to the helper methods defined in the module" do
142
- expect { help }.to raise_error(NameError)
143
- end
144
- end
145
- """
146
- When I run `rspec symbols_as_metadata_spec.rb`
147
- Then the examples should all pass
148
- And the output should contain "In a group not matching the extend filter, help is not available"
149
- And the output should contain "In a group matching the extend filter, help is available"