rspec-core 2.11.1 → 3.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (222) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data/.document +1 -1
  4. data/.yardopts +3 -1
  5. data/Changelog.md +1814 -29
  6. data/{License.txt → LICENSE.md} +6 -4
  7. data/README.md +197 -48
  8. data/exe/rspec +2 -23
  9. data/lib/rspec/autorun.rb +1 -0
  10. data/lib/rspec/core/backtrace_formatter.rb +65 -0
  11. data/lib/rspec/core/bisect/coordinator.rb +62 -0
  12. data/lib/rspec/core/bisect/example_minimizer.rb +173 -0
  13. data/lib/rspec/core/bisect/fork_runner.rb +138 -0
  14. data/lib/rspec/core/bisect/server.rb +61 -0
  15. data/lib/rspec/core/bisect/shell_command.rb +126 -0
  16. data/lib/rspec/core/bisect/shell_runner.rb +73 -0
  17. data/lib/rspec/core/bisect/utilities.rb +69 -0
  18. data/lib/rspec/core/configuration.rb +1846 -407
  19. data/lib/rspec/core/configuration_options.rb +154 -50
  20. data/lib/rspec/core/did_you_mean.rb +46 -0
  21. data/lib/rspec/core/drb.rb +120 -0
  22. data/lib/rspec/core/dsl.rb +90 -18
  23. data/lib/rspec/core/example.rb +488 -152
  24. data/lib/rspec/core/example_group.rb +733 -294
  25. data/lib/rspec/core/example_status_persister.rb +235 -0
  26. data/lib/rspec/core/filter_manager.rb +175 -147
  27. data/lib/rspec/core/flat_map.rb +20 -0
  28. data/lib/rspec/core/formatters/base_bisect_formatter.rb +45 -0
  29. data/lib/rspec/core/formatters/base_formatter.rb +32 -130
  30. data/lib/rspec/core/formatters/base_text_formatter.rb +62 -190
  31. data/lib/rspec/core/formatters/bisect_drb_formatter.rb +29 -0
  32. data/lib/rspec/core/formatters/bisect_progress_formatter.rb +157 -0
  33. data/lib/rspec/core/formatters/console_codes.rb +76 -0
  34. data/lib/rspec/core/formatters/deprecation_formatter.rb +223 -0
  35. data/lib/rspec/core/formatters/documentation_formatter.rb +62 -27
  36. data/lib/rspec/core/formatters/exception_presenter.rb +521 -0
  37. data/lib/rspec/core/formatters/failure_list_formatter.rb +23 -0
  38. data/lib/rspec/core/formatters/fallback_message_formatter.rb +28 -0
  39. data/lib/rspec/core/formatters/helpers.rb +93 -14
  40. data/lib/rspec/core/formatters/html_formatter.rb +104 -415
  41. data/lib/rspec/core/formatters/html_printer.rb +414 -0
  42. data/lib/rspec/core/formatters/html_snippet_extractor.rb +120 -0
  43. data/lib/rspec/core/formatters/json_formatter.rb +102 -0
  44. data/lib/rspec/core/formatters/profile_formatter.rb +68 -0
  45. data/lib/rspec/core/formatters/progress_formatter.rb +12 -15
  46. data/lib/rspec/core/formatters/protocol.rb +182 -0
  47. data/lib/rspec/core/formatters/snippet_extractor.rb +115 -39
  48. data/lib/rspec/core/formatters/syntax_highlighter.rb +91 -0
  49. data/lib/rspec/core/formatters.rb +279 -0
  50. data/lib/rspec/core/hooks.rb +451 -300
  51. data/lib/rspec/core/invocations.rb +87 -0
  52. data/lib/rspec/core/memoized_helpers.rb +580 -0
  53. data/lib/rspec/core/metadata.rb +395 -173
  54. data/lib/rspec/core/metadata_filter.rb +255 -0
  55. data/lib/rspec/core/minitest_assertions_adapter.rb +31 -0
  56. data/lib/rspec/core/mocking_adapters/flexmock.rb +31 -0
  57. data/lib/rspec/core/mocking_adapters/mocha.rb +57 -0
  58. data/lib/rspec/core/mocking_adapters/null.rb +14 -0
  59. data/lib/rspec/core/mocking_adapters/rr.rb +31 -0
  60. data/lib/rspec/core/mocking_adapters/rspec.rb +32 -0
  61. data/lib/rspec/core/notifications.rb +521 -0
  62. data/lib/rspec/core/option_parser.rb +208 -64
  63. data/lib/rspec/core/ordering.rb +169 -0
  64. data/lib/rspec/core/output_wrapper.rb +29 -0
  65. data/lib/rspec/core/pending.rb +115 -59
  66. data/lib/rspec/core/profiler.rb +34 -0
  67. data/lib/rspec/core/project_initializer/.rspec +1 -0
  68. data/lib/rspec/core/project_initializer/spec/spec_helper.rb +98 -0
  69. data/lib/rspec/core/project_initializer.rb +26 -65
  70. data/lib/rspec/core/rake_task.rb +140 -131
  71. data/lib/rspec/core/reporter.rb +207 -44
  72. data/lib/rspec/core/ruby_project.rb +15 -6
  73. data/lib/rspec/core/runner.rb +180 -44
  74. data/lib/rspec/core/sandbox.rb +37 -0
  75. data/lib/rspec/core/set.rb +54 -0
  76. data/lib/rspec/core/shared_context.rb +25 -19
  77. data/lib/rspec/core/shared_example_group.rb +229 -54
  78. data/lib/rspec/core/shell_escape.rb +49 -0
  79. data/lib/rspec/core/test_unit_assertions_adapter.rb +30 -0
  80. data/lib/rspec/core/version.rb +3 -1
  81. data/lib/rspec/core/warnings.rb +40 -0
  82. data/lib/rspec/core/world.rb +208 -49
  83. data/lib/rspec/core.rb +166 -80
  84. data.tar.gz.sig +0 -0
  85. metadata +230 -445
  86. metadata.gz.sig +0 -0
  87. data/exe/autospec +0 -13
  88. data/features/Autotest.md +0 -38
  89. data/features/README.md +0 -17
  90. data/features/Upgrade.md +0 -364
  91. data/features/command_line/README.md +0 -28
  92. data/features/command_line/example_name_option.feature +0 -101
  93. data/features/command_line/exit_status.feature +0 -83
  94. data/features/command_line/format_option.feature +0 -81
  95. data/features/command_line/init.feature +0 -18
  96. data/features/command_line/line_number_appended_to_path.feature +0 -140
  97. data/features/command_line/line_number_option.feature +0 -58
  98. data/features/command_line/order.feature +0 -29
  99. data/features/command_line/pattern_option.feature +0 -31
  100. data/features/command_line/rake_task.feature +0 -68
  101. data/features/command_line/ruby.feature +0 -22
  102. data/features/command_line/tag.feature +0 -91
  103. data/features/configuration/alias_example_to.feature +0 -48
  104. data/features/configuration/custom_settings.feature +0 -84
  105. data/features/configuration/default_path.feature +0 -38
  106. data/features/configuration/fail_fast.feature +0 -77
  107. data/features/configuration/read_options_from_file.feature +0 -87
  108. data/features/example_groups/basic_structure.feature +0 -55
  109. data/features/example_groups/shared_context.feature +0 -74
  110. data/features/example_groups/shared_examples.feature +0 -204
  111. data/features/expectation_framework_integration/configure_expectation_framework.feature +0 -102
  112. data/features/filtering/exclusion_filters.feature +0 -139
  113. data/features/filtering/if_and_unless.feature +0 -168
  114. data/features/filtering/inclusion_filters.feature +0 -105
  115. data/features/filtering/run_all_when_everything_filtered.feature +0 -46
  116. data/features/formatters/custom_formatter.feature +0 -36
  117. data/features/formatters/text_formatter.feature +0 -46
  118. data/features/helper_methods/arbitrary_methods.feature +0 -40
  119. data/features/helper_methods/let.feature +0 -50
  120. data/features/helper_methods/modules.feature +0 -149
  121. data/features/hooks/around_hooks.feature +0 -343
  122. data/features/hooks/before_and_after_hooks.feature +0 -423
  123. data/features/hooks/filtering.feature +0 -234
  124. data/features/metadata/current_example.feature +0 -17
  125. data/features/metadata/described_class.feature +0 -17
  126. data/features/metadata/user_defined.feature +0 -113
  127. data/features/mock_framework_integration/use_any_framework.feature +0 -106
  128. data/features/mock_framework_integration/use_flexmock.feature +0 -96
  129. data/features/mock_framework_integration/use_mocha.feature +0 -97
  130. data/features/mock_framework_integration/use_rr.feature +0 -98
  131. data/features/mock_framework_integration/use_rspec.feature +0 -97
  132. data/features/pending/pending_examples.feature +0 -229
  133. data/features/spec_files/arbitrary_file_suffix.feature +0 -13
  134. data/features/step_definitions/additional_cli_steps.rb +0 -30
  135. data/features/subject/attribute_of_subject.feature +0 -124
  136. data/features/subject/explicit_subject.feature +0 -82
  137. data/features/subject/implicit_receiver.feature +0 -29
  138. data/features/subject/implicit_subject.feature +0 -63
  139. data/features/support/env.rb +0 -12
  140. data/lib/autotest/discover.rb +0 -1
  141. data/lib/autotest/rspec2.rb +0 -73
  142. data/lib/rspec/core/backward_compatibility.rb +0 -65
  143. data/lib/rspec/core/command_line.rb +0 -36
  144. data/lib/rspec/core/deprecation.rb +0 -36
  145. data/lib/rspec/core/drb_command_line.rb +0 -26
  146. data/lib/rspec/core/drb_options.rb +0 -87
  147. data/lib/rspec/core/extensions/instance_eval_with_args.rb +0 -44
  148. data/lib/rspec/core/extensions/kernel.rb +0 -9
  149. data/lib/rspec/core/extensions/module_eval_with_args.rb +0 -38
  150. data/lib/rspec/core/extensions/ordered.rb +0 -21
  151. data/lib/rspec/core/extensions.rb +0 -4
  152. data/lib/rspec/core/formatters/text_mate_formatter.rb +0 -34
  153. data/lib/rspec/core/let.rb +0 -110
  154. data/lib/rspec/core/load_path.rb +0 -3
  155. data/lib/rspec/core/metadata_hash_builder.rb +0 -97
  156. data/lib/rspec/core/mocking/with_absolutely_nothing.rb +0 -11
  157. data/lib/rspec/core/mocking/with_flexmock.rb +0 -27
  158. data/lib/rspec/core/mocking/with_mocha.rb +0 -29
  159. data/lib/rspec/core/mocking/with_rr.rb +0 -27
  160. data/lib/rspec/core/mocking/with_rspec.rb +0 -23
  161. data/lib/rspec/core/subject.rb +0 -219
  162. data/spec/autotest/discover_spec.rb +0 -19
  163. data/spec/autotest/failed_results_re_spec.rb +0 -45
  164. data/spec/autotest/rspec_spec.rb +0 -123
  165. data/spec/command_line/order_spec.rb +0 -137
  166. data/spec/rspec/core/command_line_spec.rb +0 -108
  167. data/spec/rspec/core/command_line_spec_output.txt +0 -0
  168. data/spec/rspec/core/configuration_options_spec.rb +0 -377
  169. data/spec/rspec/core/configuration_spec.rb +0 -1196
  170. data/spec/rspec/core/deprecations_spec.rb +0 -66
  171. data/spec/rspec/core/drb_command_line_spec.rb +0 -108
  172. data/spec/rspec/core/drb_options_spec.rb +0 -180
  173. data/spec/rspec/core/dsl_spec.rb +0 -17
  174. data/spec/rspec/core/example_group_spec.rb +0 -1098
  175. data/spec/rspec/core/example_spec.rb +0 -370
  176. data/spec/rspec/core/filter_manager_spec.rb +0 -256
  177. data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -80
  178. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +0 -363
  179. data/spec/rspec/core/formatters/documentation_formatter_spec.rb +0 -88
  180. data/spec/rspec/core/formatters/helpers_spec.rb +0 -66
  181. data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +0 -410
  182. data/spec/rspec/core/formatters/html_formatted-1.8.7.html +0 -409
  183. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +0 -416
  184. data/spec/rspec/core/formatters/html_formatted-1.9.3.html +0 -416
  185. data/spec/rspec/core/formatters/html_formatter_spec.rb +0 -82
  186. data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -30
  187. data/spec/rspec/core/formatters/snippet_extractor_spec.rb +0 -18
  188. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +0 -410
  189. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +0 -409
  190. data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +0 -416
  191. data/spec/rspec/core/formatters/text_mate_formatted-1.9.3.html +0 -416
  192. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +0 -83
  193. data/spec/rspec/core/hooks_filtering_spec.rb +0 -227
  194. data/spec/rspec/core/hooks_spec.rb +0 -250
  195. data/spec/rspec/core/kernel_extensions_spec.rb +0 -9
  196. data/spec/rspec/core/let_spec.rb +0 -55
  197. data/spec/rspec/core/metadata_spec.rb +0 -447
  198. data/spec/rspec/core/option_parser_spec.rb +0 -166
  199. data/spec/rspec/core/pending_example_spec.rb +0 -220
  200. data/spec/rspec/core/project_initializer_spec.rb +0 -130
  201. data/spec/rspec/core/rake_task_spec.rb +0 -138
  202. data/spec/rspec/core/reporter_spec.rb +0 -103
  203. data/spec/rspec/core/resources/a_bar.rb +0 -0
  204. data/spec/rspec/core/resources/a_foo.rb +0 -0
  205. data/spec/rspec/core/resources/a_spec.rb +0 -1
  206. data/spec/rspec/core/resources/custom_example_group_runner.rb +0 -14
  207. data/spec/rspec/core/resources/formatter_specs.rb +0 -60
  208. data/spec/rspec/core/resources/utf8_encoded.rb +0 -8
  209. data/spec/rspec/core/rspec_matchers_spec.rb +0 -45
  210. data/spec/rspec/core/ruby_project_spec.rb +0 -24
  211. data/spec/rspec/core/runner_spec.rb +0 -81
  212. data/spec/rspec/core/shared_context_spec.rb +0 -67
  213. data/spec/rspec/core/shared_example_group_spec.rb +0 -84
  214. data/spec/rspec/core/subject_spec.rb +0 -244
  215. data/spec/rspec/core/world_spec.rb +0 -144
  216. data/spec/rspec/core_spec.rb +0 -35
  217. data/spec/spec_helper.rb +0 -98
  218. data/spec/support/config_options_helper.rb +0 -24
  219. data/spec/support/helper_methods.rb +0 -5
  220. data/spec/support/matchers.rb +0 -65
  221. data/spec/support/shared_example_groups.rb +0 -41
  222. data/spec/support/spec_files.rb +0 -44
metadata.gz.sig ADDED
Binary file
data/exe/autospec DELETED
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'rspec/core/deprecation'
3
- RSpec.warn_deprecation <<-WARNING
4
- ************************************************************
5
- REMOVAL NOTICE: you are using behaviour that has been
6
- removed from rspec-2.
7
-
8
- * The 'autospec' command is no longer supported.
9
- * Please use 'autotest' insted.
10
-
11
- This message will be removed from a future version of rspec.
12
- ************************************************************
13
- WARNING
data/features/Autotest.md DELETED
@@ -1,38 +0,0 @@
1
- RSpec ships with a specialized subclass of Autotest. To use it, just add a
2
- `.rspec` file to your project's root directory, and run the `autotest` command
3
- as normal:
4
-
5
- $ autotest
6
-
7
- ## Bundler
8
-
9
- The `autotest` command generates a shell command that runs your specs. If you
10
- are using Bundler, and you want the shell command to include `bundle exec`,
11
- require the Autotest bundler plugin in a `.autotest` file in the project's root
12
- directory or your home directory:
13
-
14
- # in .autotest
15
- require "autotest/bundler"
16
-
17
- ## Upgrading from previous versions of rspec
18
-
19
- Previous versions of RSpec used a different mechanism for telling autotest to
20
- invoke RSpec's Autotest extension: it generated an `autotest/discover.rb` file
21
- in the project's root directory. This is no longer necessary with the new
22
- approach of RSpec looking for a `.rspec` file, so feel free to delete the
23
- `autotest/discover.rb` file in the project root if you have one.
24
-
25
- ## Gotchas
26
-
27
- ### Invalid Option: --tty
28
-
29
- The `--tty` option was [added in rspec-core-2.2.1](changelog), and is used
30
- internally by RSpec. If you see an error citing it as an invalid option, you'll
31
- probably see there are two or more versions of rspec-core in the backtrace: one
32
- < 2.2.1 and one >= 2.2.1.
33
-
34
- This usually happens because you have a newer rspec-core installed, and an
35
- older rspec-core specified in a Bundler Gemfile. If this is the case, you can:
36
-
37
- 1. specify the newer version in the Gemfile (recommended)
38
- 2. prefix the `autotest` command with `bundle exec`
data/features/README.md DELETED
@@ -1,17 +0,0 @@
1
- rspec-core provides the structure for RSpec code examples:
2
-
3
- describe Account do
4
- it "has a balance of zero when first opened" do
5
- # example code goes here - for more on the
6
- # code inside the examples, see rspec-expectations
7
- # and rspec-mocks
8
- end
9
- end
10
-
11
- ## Issues
12
-
13
- This documentation is [open
14
- source](https://github.com/rspec/rspec-core/tree/master/features), and a work
15
- in progress. If you find it incomplete or confusing, please [submit an
16
- issue](http://github.com/rspec/rspec-core/issues), or, better yet, [a pull
17
- request](http://github.com/rspec/rspec-core).
data/features/Upgrade.md DELETED
@@ -1,364 +0,0 @@
1
- The [Changelog](changelog) has a complete list of everything that changed, but
2
- here are more detailed explanations for those items that warrant them.
3
-
4
- # rspec-core-2.7.0.rc1
5
-
6
- ## what's new
7
-
8
- ### `rspec` command with no arguments
9
-
10
- Now you can just type
11
-
12
- rspec
13
-
14
- to run all the specs in the `spec` directory. If you keep your specs in a
15
- different directory, you can override the default with the `--default_path`
16
- argument in a config file:
17
-
18
- # in .rspec
19
- --default_path specs
20
-
21
- ### `rspec` command supports multiple line numbers
22
-
23
- Use either of the following to run the examples declared on lines
24
- 37 and 42 of `a_spec.rb`:
25
-
26
- rspec path/to/a_spec.rb --line_number 37 --line_number 42
27
- rspec path/to/a_spec.rb:37:42
28
-
29
- ## what's changed
30
-
31
- ### `skip_bundler` and `gemfile` rake task options are deprecated and have no effect.
32
-
33
- RSpec's rake task invokes the `rspec` command in a subshell. If you invoke
34
- `bundle exec rake` or include `Bundler.setup` in your `Rakefile`, then
35
- Bundler will be activated in the subshell as well.
36
-
37
- Previously, the rake task managed this for you based on the presence of a
38
- `Gemfile`. In 2.7.0.rc1, this is done based on the presence of the
39
- `BUNDLE_GEMFILE` environment variable, which is set in the parent shell by Bundler.
40
-
41
- In 2.7.0.rc2 (not yet released), the rake task doesn't do anything at all.
42
- Turns out Bundler just does the right thing, so rspec doesn't need to do
43
- anything.
44
-
45
- # rspec-core-2.6
46
-
47
- ## new APIs for sharing content
48
-
49
- Use `shared_context` together with `include_context` to share before/after
50
- hooks, let declarations, and method definitions across example groups.
51
-
52
- Use `shared_examples` together with `include_examples` to share examples
53
- across different contexts.
54
-
55
- All of the old APIs are still supported, but these 4 are easy to remember, and
56
- serve most use cases.
57
-
58
- See `shared_context` and `shared_examples` under "Example Groups" for more
59
- information.
60
-
61
- ## `treat_symbols_as_metadata_keys_with_true_values`
62
-
63
- Yes it's a long name, but it's a great feature, and it's going to be the
64
- default behavior in rspec-3. This lets you add metadata to a group or example
65
- like this:
66
-
67
- describe "something", :awesome do
68
- ...
69
-
70
- And then you can run that group (or example) using the tags feature:
71
-
72
- rspec spec --tag awesome
73
-
74
- We're making this an opt-in for rspec-2.6 because `describe "string", :symbol`
75
- is a perfectly legal construct in pre-2.6 releases and we want to maintain
76
- compatibility in minor releases as much as is possible.
77
-
78
- # rspec-core-2.3
79
-
80
- ## `config.expect_with`
81
-
82
- Use this to configure RSpec to use rspec/expectations (default),
83
- stdlib assertions (Test::Unit with Ruby 1.8, MiniTest with Ruby 1.9),
84
- or both:
85
-
86
- RSpec.configure do |config|
87
- config.expect_with :rspec # => rspec/expectations
88
- config.expect_with :stdlib # => Test::Unit or MinitTest
89
- config.expect_with :rspec, :stdlib # => both
90
- end
91
-
92
- # rspec-core-2.1
93
-
94
- ## Command line
95
-
96
- ### `--tags`
97
-
98
- Now you can tag groups and examples using metadata and access those tags from
99
- the command line. So if you have a group with `:foo => true`:
100
-
101
- describe "something", :foo => true do
102
- it "does something" do
103
- # ...
104
- end
105
- end
106
-
107
- ... now you can run just that group like this:
108
-
109
- rspec spec --tags foo
110
-
111
- ### `--fail-fast`
112
-
113
- Add this flag to the command line to tell rspec to clean up and exit after the
114
- first failure:
115
-
116
- rspec spec --fail-fast
117
-
118
- ## Metata/filtering
119
-
120
- ### :if and :unless keys
121
-
122
- Use :if and :unless keys to conditionally run examples with simple boolean
123
- expressions:
124
-
125
- describe "something" do
126
- it "does something", :if => RUBY_VERSION == 1.8.6 do
127
- # ...
128
- end
129
- it "does something", :unless => RUBY_VERSION == 1.8.6 do
130
- # ...
131
- end
132
- end
133
-
134
- ## Conditionally 'pending' examples
135
-
136
- Make examples pending based on a condition. This is most useful when you
137
- have an example that runs in multiple contexts and fails in one of those due to
138
- a bug in a third-party dependency that you expect to be fixed in the future.
139
-
140
- describe "something" do
141
- it "does something that doesn't yet work right on JRuby" do
142
- pending("waiting for the JRuby team to fix issue XYZ", :if => RUBY_PLATFORM == 'java') do
143
- # the content of your spec
144
- end
145
- end
146
- end
147
-
148
- This example would run normally on all ruby interpretters except JRuby. On JRuby,
149
- it uses the block form of `pending`, which causes the example to still be run and
150
- will remain pending as long as it fails. In the future, if you upgraded your
151
- JRuby installation to a newer release that allows the example to pass, RSpec
152
- will report it as a failure (`Expected pending '...' to fail. No Error was raised.`),
153
- so that know that you can remove the call to `pending`.
154
-
155
- # New features in rspec-core-2.0
156
-
157
- ### Runner
158
-
159
- The new runner for rspec-2 comes from Micronaut.
160
-
161
- ### Metadata!
162
-
163
- In rspec-2, every example and example group comes with metadata information
164
- like the file and line number on which it was declared, the arguments passed to
165
- `describe` and `it`, etc. This metadata can be appended to through a hash
166
- argument passed to `describe` or `it`, allowing us to pre and post-process
167
- each example in a variety of ways.
168
-
169
- ### Filtering
170
-
171
- The most obvious use is for filtering the run. For example:
172
-
173
- # in spec/spec_helper.rb
174
- RSpec.configure do |c|
175
- c.filter_run :focus => true
176
- end
177
-
178
- # in any spec file
179
- describe "something" do
180
- it "does something", :focus => true do
181
- # ....
182
- end
183
- end
184
-
185
- When you run the `rspec` command, rspec will run only the examples that have
186
- `:focus => true` in the hash.
187
-
188
- You can also add `run_all_when_everything_filtered` to the config:
189
-
190
- RSpec.configure do |c|
191
- c.filter_run :focus => true
192
- c.run_all_when_everything_filtered = true
193
- end
194
-
195
- Now if there are no examples tagged with `:focus => true`, all examples
196
- will be run. This makes it really easy to focus on one example for a
197
- while, but then go back to running all of the examples by removing that
198
- argument from `it`. Works with `describe` too, in which case it runs
199
- all of the examples in that group.
200
-
201
- The configuration will accept a lambda, which provides a lot of flexibility
202
- in filtering examples. Say, for example, you have a spec for functionality that
203
- behaves slightly differently in Ruby 1.8 and Ruby 1.9. We have that in
204
- rspec-core, and here's how we're getting the right stuff to run under the
205
- right version:
206
-
207
- # in spec/spec_helper.rb
208
- RSpec.configure do |c|
209
- c.exclusion_filter = { :ruby => lambda {|version|
210
- !(RUBY_VERSION.to_s =~ /^#{version.to_s}/)
211
- }}
212
- end
213
-
214
- # in any spec file
215
- describe "something" do
216
- it "does something", :ruby => 1.8 do
217
- # ....
218
- end
219
-
220
- it "does something", :ruby => 1.9 do
221
- # ....
222
- end
223
- end
224
-
225
- In this case, we're using `exclusion_filter` instead of `filter_run` or
226
- `filter`, which indicate _inclusion_ filters. So each of those examples is
227
- excluded if we're _not_ running the version of Ruby they work with.
228
-
229
- ### Shared example groups
230
-
231
- Shared example groups are now run in a nested group within the including group
232
- (they used to be run in the same group). Nested groups inherit `before`, `after`,
233
- `around`, and `let` hooks, as well as any methods that are defined in the parent
234
- group.
235
-
236
- This new approach provides better encapsulation, better output, and an
237
- opportunity to add contextual information to the shared group via a block
238
- passed to `it_should_behave_like`.
239
-
240
- See [features/example\_groups/shared\_example\_group.feature](http://github.com/rspec/rspec-core/blob/master/features/example_groups/shared_example_group.feature) for more information.
241
-
242
- NOTICE: The including example groups no longer have access to any of the
243
- methods, hooks, or state defined inside a shared group. This will break rspec-1
244
- specs that were using shared example groups to extend the behavior of including
245
- groups.
246
-
247
- # Upgrading from rspec-1.x
248
-
249
- ### rspec command
250
-
251
- The command to run specs is now `rspec` instead of `spec`.
252
-
253
- rspec ./spec
254
-
255
- #### Co-habitation of rspec-1 and rspec-2
256
-
257
- Early beta versions of RSpec-2 included a `spec` command, which conflicted with
258
- the RSpec-1 `spec` command because RSpec-1's was installed by the rspec gem,
259
- while RSpec-2's is installed by the rspec-core gem.
260
-
261
- If you installed one of these early versions, the safest bet is to uninstall
262
- rspec-1 and rspec-core-2, and then reinstall both. After you do this, you will
263
- be able to run rspec-2 like this:
264
-
265
- rspec ./spec
266
-
267
- ... and rspec-1 like this:
268
-
269
- spec _1.3.1_ ./spec
270
-
271
- Rubygems inspects the first argument to any gem executable to see if it's
272
- formatted like a version number surrounded by underscores. If so, it uses that
273
- version (e.g. `1.3.1`). If not, it uses the most recent version (e.g.
274
- `2.0.0`).
275
-
276
- ### rake task
277
-
278
- A few things changed in the Rake task used to run specs:
279
-
280
- 1. The file in which it is defined changed from `spec/rake/spectask` to
281
- `rspec/core/rake_task`
282
-
283
- 2. The `spec_opts` accessor has been deprecated in favor of `rspec_opts`. Also,
284
- the `rspec` command no longer supports the `--options` command line option
285
- so the options must be embedded directly in the Rakefile, or stored in the
286
- `.rspec` files mentioned above.
287
-
288
- 3. In RSpec-1, the rake task would read in rcov options from an `rcov.opts`
289
- file. This is ignored by RSpec-2. RCov options are now set directly on the Rake
290
- task:
291
-
292
- RSpec::Core::RakeTask.new(:rcov) do |t|
293
- t.rcov_opts = %q[--exclude "spec"]
294
- end
295
-
296
- 3. The `spec_files` accessor has been replaced by `pattern`.
297
-
298
- # rspec-1
299
- require 'spec/rake/spectask'
300
-
301
- Spec::Rake::SpecTask.new do |t|
302
- t.spec_opts = ['--options', "\"spec/spec.opts\""]
303
- t.spec_files = FileList['spec/**/*.rb']
304
- end
305
-
306
- # rspec-2
307
- require 'rspec/core/rake_task'
308
-
309
- RSpec::Core::RakeTask.new do |t|
310
- t.rspec_opts = ["-c", "-f progress", "-r ./spec/spec_helper.rb"]
311
- t.pattern = 'spec/**/*_spec.rb'
312
- end
313
-
314
- ### autotest
315
-
316
- `autospec` is dead. Long live `autotest`.
317
-
318
- ### RSpec is the new Spec
319
-
320
- The root namespace (top level module) is now `RSpec` instead of `Spec`, and
321
- the root directory under `lib` within all of the `rspec` gems is `rspec` instead of `spec`.
322
-
323
- ### Configuration
324
-
325
- Typically in `spec/spec_helper.rb`, configuration is now done like this:
326
-
327
- RSpec.configure do |c|
328
- # ....
329
- end
330
-
331
- ### .rspec
332
-
333
- Command line options can be persisted in a `.rspec` file in a project. You
334
- can also store a `.rspec` file in your home directory (`~/.rspec`) with global
335
- options. Precedence is:
336
-
337
- command line
338
- ./.rspec
339
- ~/.rspec
340
-
341
- ### `context` is no longer a top-level method
342
-
343
- We removed `context` from the main object because it was creating conflicts with
344
- IRB and some users who had `Context` domain objects. `describe` is still there,
345
- so if you want to use `context` at the top level, just alias it:
346
-
347
- alias :context :describe
348
-
349
- Of course, you can still use `context` to declare a nested group:
350
-
351
- describe "something" do
352
- context "in some context" do
353
- it "does something" do
354
- # ...
355
- end
356
- end
357
- end
358
-
359
- ### `$KCODE` no longer set implicitly to `'u'`
360
-
361
- In RSpec-1, the runner set `$KCODE` to `'u'`, which impacts, among other
362
- things, the behaviour of Regular Expressions when applied to non-ascii
363
- characters. This is no longer the case in RSpec-2.
364
-
@@ -1,28 +0,0 @@
1
- The `rspec` command comes with several options you can use to customize RSpec's
2
- behavior, including output formats, filtering examples, etc.
3
-
4
- For a full list of options, run the `rspec` command with the `--help` flag:
5
-
6
- $ rspec --help
7
-
8
- ### Run with `ruby`
9
-
10
- Generally, life is simpler if you just use the `rspec` command. If you must use the `ruby`
11
- command, however, you'll want to do the following:
12
-
13
- * `require 'rspec/autorun'`
14
-
15
- This tells RSpec to run your examples. Do this in any file that you are
16
- passing to the `ruby` command.
17
-
18
- * Update the `LOAD_PATH`
19
-
20
- It is conventional to put configuration in and require assorted support files
21
- from `spec/spec_helper.rb`. It is also conventional to require that file from
22
- the spec files using `require 'spec_helper'`. This works because RSpec
23
- implicitly adds the `spec` directory to the `LOAD_PATH`. It also adds `lib`, so
24
- your implementation files will be on the `LOAD_PATH` as well.
25
-
26
- If you're using the `ruby` command, you'll need to do this yourself:
27
-
28
- ruby -Ilib -Ispec path/to/spec.rb
@@ -1,101 +0,0 @@
1
- Feature: --example option
2
-
3
- Use the --example (or -e) option to filter examples by name.
4
-
5
- The argument is compiled to a Ruby Regexp, and matched against the full
6
- description of the example, which is the concatenation of descriptions of the
7
- group (including any nested groups) and the example.
8
-
9
- This allows you to run a single uniquely named example, all examples with
10
- similar names, all the examples in a uniquely named group, etc, etc.
11
-
12
- You can also use the option more than once to specify multiple example matches.
13
-
14
- Background:
15
- Given a file named "first_spec.rb" with:
16
- """
17
- describe "first group" do
18
- it "first example in first group" do; end
19
- it "second example in first group" do; end
20
- end
21
- """
22
- And a file named "second_spec.rb" with:
23
- """
24
- describe "second group" do
25
- it "first example in second group" do; end
26
- it "second example in second group" do; end
27
- end
28
- """
29
- And a file named "third_spec.rb" with:
30
- """
31
- describe "third group" do
32
- it "first example in third group" do; end
33
- context "nested group" do
34
- it "first example in nested group" do; end
35
- it "second example in nested group" do; end
36
- end
37
- end
38
- """
39
- And a file named "fourth_spec.rb" with:
40
- """
41
- describe Array do
42
- describe "#length" do
43
- it "is the number of items" do
44
- Array.new([1,2,3]).length.should eq 3
45
- end
46
- end
47
- end
48
- """
49
-
50
- Scenario: no matches
51
- When I run `rspec . --example nothing_like_this`
52
- Then the examples should all pass
53
-
54
- Scenario: match on one word
55
- When I run `rspec . --example example`
56
- Then the examples should all pass
57
-
58
- Scenario: one match in each context
59
- When I run `rspec . --example 'first example'`
60
- Then the examples should all pass
61
-
62
- Scenario: one match in one file using just the example name
63
- When I run `rspec . --example 'first example in first group'`
64
- Then the examples should all pass
65
-
66
- Scenario: one match in one file using the example name and the group name
67
- When I run `rspec . --example 'first group first example in first group'`
68
- Then the examples should all pass
69
-
70
- Scenario: one match in one file using regexp
71
- When I run `rspec . --example 'first .* first example'`
72
- Then the examples should all pass
73
-
74
- Scenario: all examples in one group
75
- When I run `rspec . --example 'first group'`
76
- Then the examples should all pass
77
-
78
- Scenario: one match in one file with group name
79
- When I run `rspec . --example 'second group first example'`
80
- Then the examples should all pass
81
-
82
- Scenario: all examples in one group including examples in nested groups
83
- When I run `rspec . --example 'third group'`
84
- Then the examples should all pass
85
-
86
- Scenario: Object#method
87
- When I run `rspec . --example 'Array#length'`
88
- Then the examples should all pass
89
-
90
- Scenario: Multiple applications of example name option
91
- When I run `rspec . --example 'first group' --example 'second group' --format d`
92
- Then the examples should all pass
93
- And the output should contain all of these:
94
- |first example in first group|
95
- |second example in first group|
96
- |first example in second group|
97
- |second example in second group|
98
- And the output should not contain any of these:
99
- |first example in third group|
100
- |nested group first example in nested group|
101
- |nested group second example in nested group|
@@ -1,83 +0,0 @@
1
- Feature: exit status
2
-
3
- The rspec command exits with an exit status of 0 if all examples pass,
4
- and 1 if any examples fail. The failure exit code can be overridden
5
- using the --failure-exit-code option.
6
-
7
- Scenario: exit with 0 when all examples pass
8
- Given a file named "ok_spec.rb" with:
9
- """
10
- describe "ok" do
11
- it "passes" do
12
- end
13
- end
14
- """
15
- When I run `rspec ok_spec.rb`
16
- Then the exit status should be 0
17
- And the examples should all pass
18
-
19
- Scenario: exit with 1 when one example fails
20
- Given a file named "ko_spec.rb" with:
21
- """
22
- describe "KO" do
23
- it "fails" do
24
- raise "KO"
25
- end
26
- end
27
- """
28
- When I run `rspec ko_spec.rb`
29
- Then the exit status should be 1
30
- And the output should contain "1 example, 1 failure"
31
-
32
- Scenario: exit with 1 when a nested examples fails
33
- Given a file named "nested_ko_spec.rb" with:
34
- """
35
- describe "KO" do
36
- describe "nested" do
37
- it "fails" do
38
- raise "KO"
39
- end
40
- end
41
- end
42
- """
43
- When I run `rspec nested_ko_spec.rb`
44
- Then the exit status should be 1
45
- And the output should contain "1 example, 1 failure"
46
-
47
- Scenario: exit with 0 when no examples are run
48
- Given a file named "a_no_examples_spec.rb" with:
49
- """
50
- """
51
- When I run `rspec a_no_examples_spec.rb`
52
- Then the exit status should be 0
53
- And the output should contain "0 examples"
54
-
55
- Scenario: exit with 2 when one example fails and --failure-exit-code is 2
56
- Given a file named "ko_spec.rb" with:
57
- """
58
- describe "KO" do
59
- it "fails" do
60
- raise "KO"
61
- end
62
- end
63
- """
64
- When I run `rspec --failure-exit-code 2 ko_spec.rb`
65
- Then the exit status should be 2
66
- And the output should contain "1 example, 1 failure"
67
-
68
- @wip
69
- Scenario: exit with rspec's exit code when an at_exit hook is added upstream
70
- Given a file named "exit_at_spec.rb" with:
71
- """
72
- require 'rspec/autorun'
73
-
74
- describe "exit 0 at_exit" do
75
- it "does not interfere with rspec's exit code" do
76
- at_exit { exit 0 }
77
- fail
78
- end
79
- end
80
- """
81
- When I run `rspec exit_at_spec.rb`
82
- Then the exit status should be 1
83
- And the output should contain "1 example, 1 failure"