rspec-core 2.0.0.beta.22 → 2.6.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 (171) hide show
  1. data/.gitignore +1 -0
  2. data/.rspec +0 -1
  3. data/.travis.yml +7 -0
  4. data/Gemfile +46 -20
  5. data/Guardfile +5 -0
  6. data/License.txt +2 -1
  7. data/{README.markdown → README.md} +23 -5
  8. data/Rakefile +58 -31
  9. data/bin/autospec +13 -0
  10. data/bin/rspec +24 -2
  11. data/cucumber.yml +1 -1
  12. data/features/.nav +57 -0
  13. data/features/Autotest.md +38 -0
  14. data/features/Changelog.md +269 -0
  15. data/features/README.md +17 -0
  16. data/features/Upgrade.md +320 -0
  17. data/features/command_line/README.md +28 -0
  18. data/features/command_line/configure.feature +18 -15
  19. data/features/command_line/example_name_option.feature +37 -23
  20. data/features/command_line/exit_status.feature +16 -31
  21. data/features/command_line/format_option.feature +73 -0
  22. data/features/command_line/line_number_appended_to_path.feature +25 -27
  23. data/features/command_line/line_number_option.feature +11 -10
  24. data/features/command_line/rake_task.feature +68 -0
  25. data/features/command_line/tag.feature +90 -0
  26. data/features/configuration/alias_example_to.feature +48 -0
  27. data/features/configuration/custom_settings.feature +8 -10
  28. data/features/configuration/fail_fast.feature +77 -0
  29. data/features/configuration/read_options_from_file.feature +42 -26
  30. data/features/example_groups/basic_structure.feature +55 -0
  31. data/features/example_groups/shared_context.feature +74 -0
  32. data/features/example_groups/shared_example_group.feature +56 -41
  33. data/features/expectation_framework_integration/configure_expectation_framework.feature +73 -0
  34. data/features/filtering/exclusion_filters.feature +69 -9
  35. data/features/filtering/if_and_unless.feature +168 -0
  36. data/features/filtering/inclusion_filters.feature +58 -26
  37. data/features/filtering/run_all_when_everything_filtered.feature +46 -0
  38. data/features/formatters/custom_formatter.feature +17 -13
  39. data/features/formatters/text_formatter.feature +43 -0
  40. data/features/helper_methods/arbitrary_methods.feature +40 -0
  41. data/features/helper_methods/let.feature +50 -0
  42. data/features/helper_methods/modules.feature +149 -0
  43. data/features/hooks/around_hooks.feature +99 -69
  44. data/features/hooks/before_and_after_hooks.feature +74 -40
  45. data/features/hooks/filtering.feature +227 -0
  46. data/features/metadata/current_example.feature +17 -0
  47. data/features/metadata/described_class.feature +17 -0
  48. data/features/metadata/user_defined.feature +111 -0
  49. data/features/mock_framework_integration/use_any_framework.feature +106 -0
  50. data/features/mock_framework_integration/use_flexmock.feature +84 -11
  51. data/features/mock_framework_integration/use_mocha.feature +85 -11
  52. data/features/mock_framework_integration/use_rr.feature +86 -11
  53. data/features/mock_framework_integration/use_rspec.feature +85 -11
  54. data/features/pending/pending_examples.feature +143 -5
  55. data/features/spec_files/arbitrary_file_suffix.feature +2 -2
  56. data/features/step_definitions/additional_cli_steps.rb +30 -0
  57. data/features/subject/attribute_of_subject.feature +93 -15
  58. data/features/subject/explicit_subject.feature +28 -17
  59. data/features/subject/implicit_receiver.feature +29 -0
  60. data/features/subject/implicit_subject.feature +9 -10
  61. data/features/support/env.rb +6 -1
  62. data/lib/autotest/discover.rb +1 -0
  63. data/lib/autotest/rspec2.rb +15 -11
  64. data/lib/rspec/autorun.rb +2 -0
  65. data/lib/rspec/core/backward_compatibility.rb +33 -4
  66. data/lib/rspec/core/command_line.rb +4 -28
  67. data/lib/rspec/core/command_line_configuration.rb +16 -16
  68. data/lib/rspec/core/configuration.rb +279 -89
  69. data/lib/rspec/core/configuration_options.rb +46 -35
  70. data/lib/rspec/core/deprecation.rb +1 -1
  71. data/lib/rspec/core/drb_command_line.rb +5 -11
  72. data/lib/rspec/core/example.rb +63 -39
  73. data/lib/rspec/core/example_group.rb +109 -59
  74. data/lib/rspec/core/expecting/with_rspec.rb +11 -0
  75. data/lib/rspec/core/expecting/with_stdlib.rb +9 -0
  76. data/lib/rspec/core/extensions/kernel.rb +1 -1
  77. data/lib/rspec/core/extensions/object.rb +1 -3
  78. data/lib/rspec/core/formatters/base_formatter.rb +22 -11
  79. data/lib/rspec/core/formatters/base_text_formatter.rb +46 -30
  80. data/lib/rspec/core/formatters/documentation_formatter.rb +4 -2
  81. data/lib/rspec/core/formatters/helpers.rb +0 -4
  82. data/lib/rspec/core/formatters/html_formatter.rb +146 -41
  83. data/lib/rspec/core/formatters/progress_formatter.rb +1 -0
  84. data/lib/rspec/core/formatters/snippet_extractor.rb +1 -1
  85. data/lib/rspec/core/formatters/text_mate_formatter.rb +3 -1
  86. data/lib/rspec/core/hooks.rb +55 -17
  87. data/lib/rspec/core/metadata.rb +75 -64
  88. data/lib/rspec/core/metadata_hash_builder.rb +93 -0
  89. data/lib/rspec/core/mocking/with_flexmock.rb +2 -0
  90. data/lib/rspec/core/mocking/with_mocha.rb +2 -0
  91. data/lib/rspec/core/mocking/with_rr.rb +2 -0
  92. data/lib/rspec/core/mocking/with_rspec.rb +3 -1
  93. data/lib/rspec/core/option_parser.rb +48 -5
  94. data/lib/rspec/core/pending.rb +22 -4
  95. data/lib/rspec/core/rake_task.rb +64 -28
  96. data/lib/rspec/core/reporter.rb +3 -2
  97. data/lib/rspec/core/ruby_project.rb +2 -2
  98. data/lib/rspec/core/runner.rb +50 -6
  99. data/lib/rspec/core/shared_context.rb +16 -0
  100. data/lib/rspec/core/shared_example_group.rb +19 -4
  101. data/lib/rspec/core/subject.rb +92 -65
  102. data/lib/rspec/core/version.rb +1 -1
  103. data/lib/rspec/core/world.rb +83 -25
  104. data/lib/rspec/core.rb +40 -24
  105. data/lib/rspec/monkey/spork/test_framework/rspec.rb +1 -0
  106. data/rspec-core.gemspec +4 -25
  107. data/script/FullBuildRakeFile +63 -0
  108. data/script/cucumber +1 -0
  109. data/script/full_build +1 -0
  110. data/script/spec +1 -0
  111. data/spec/autotest/discover_spec.rb +19 -0
  112. data/spec/autotest/failed_results_re_spec.rb +25 -9
  113. data/spec/autotest/rspec_spec.rb +32 -41
  114. data/spec/rspec/core/command_line_spec.rb +62 -7
  115. data/spec/rspec/core/configuration_options_spec.rb +184 -148
  116. data/spec/rspec/core/configuration_spec.rb +406 -108
  117. data/spec/rspec/core/deprecations_spec.rb +38 -1
  118. data/spec/rspec/core/drb_command_line_spec.rb +21 -56
  119. data/spec/rspec/core/example_group_spec.rb +366 -127
  120. data/spec/rspec/core/example_spec.rb +125 -45
  121. data/spec/rspec/core/formatters/base_formatter_spec.rb +61 -1
  122. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +39 -5
  123. data/spec/rspec/core/formatters/documentation_formatter_spec.rb +7 -6
  124. data/spec/rspec/core/formatters/helpers_spec.rb +1 -1
  125. data/spec/rspec/core/formatters/html_formatted-1.8.6.html +199 -81
  126. data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +199 -83
  127. data/spec/rspec/core/formatters/html_formatted-1.8.7.html +199 -81
  128. data/spec/rspec/core/formatters/html_formatted-1.9.1.html +206 -81
  129. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +206 -61
  130. data/spec/rspec/core/formatters/html_formatter_spec.rb +17 -9
  131. data/spec/rspec/core/formatters/progress_formatter_spec.rb +1 -1
  132. data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +199 -81
  133. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +199 -81
  134. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +199 -81
  135. data/spec/rspec/core/formatters/text_mate_formatted-1.9.1.html +206 -81
  136. data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +206 -81
  137. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +22 -7
  138. data/spec/rspec/core/hooks_filtering_spec.rb +128 -5
  139. data/spec/rspec/core/hooks_spec.rb +90 -4
  140. data/spec/rspec/core/metadata_spec.rb +176 -163
  141. data/spec/rspec/core/option_parser_spec.rb +73 -6
  142. data/spec/rspec/core/pending_example_spec.rb +137 -35
  143. data/spec/rspec/core/rake_task_spec.rb +62 -29
  144. data/spec/rspec/core/reporter_spec.rb +20 -4
  145. data/spec/rspec/core/resources/formatter_specs.rb +25 -1
  146. data/spec/rspec/core/rspec_matchers_spec.rb +45 -0
  147. data/spec/rspec/core/runner_spec.rb +60 -10
  148. data/spec/rspec/core/shared_context_spec.rb +30 -0
  149. data/spec/rspec/core/shared_example_group_spec.rb +59 -23
  150. data/spec/rspec/core/subject_spec.rb +136 -0
  151. data/spec/rspec/core/world_spec.rb +211 -68
  152. data/spec/rspec/core_spec.rb +28 -0
  153. data/spec/spec_helper.rb +41 -23
  154. data/spec/support/matchers.rb +44 -13
  155. data/spec/support/shared_example_groups.rb +41 -0
  156. data/spec/support/spec_files.rb +44 -0
  157. data/spec.txt +1126 -0
  158. metadata +99 -168
  159. data/.treasure_map.rb +0 -23
  160. data/History.md +0 -30
  161. data/Upgrade.markdown +0 -150
  162. data/autotest/discover.rb +0 -2
  163. data/features/README.markdown +0 -12
  164. data/features/example_groups/describe_aliases.feature +0 -25
  165. data/features/example_groups/nested_groups.feature +0 -44
  166. data/features/hooks/described_class.feature +0 -14
  167. data/features/hooks/halt.feature +0 -26
  168. data/lib/rspec/core/around_proxy.rb +0 -14
  169. data/lib/rspec/core/formatters.rb +0 -8
  170. data/spec/ruby_forker.rb +0 -13
  171. data/specs.watchr +0 -59
@@ -0,0 +1,17 @@
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).
@@ -0,0 +1,320 @@
1
+ # rspec-core-2.6
2
+
3
+ ## new APIs for sharing content
4
+
5
+ Use `shared_context` together with `include_context` to share before/after
6
+ hooks, let declarations, and method definitions across example groups.
7
+
8
+ Use `shared_examples` together with `include_examples` to share examples
9
+ across different contexts.
10
+
11
+ All of the old APIs are still supported, but these 4 are easy to remember, and
12
+ serve most use cases.
13
+
14
+ See `shared_context` and `shared_examples` under "Example Groups" for more
15
+ information.
16
+
17
+ ## `treat_symbols_as_metadata_keys_with_true_values`
18
+
19
+ Yes it's a long name, but it's a great feature, and it's going to be the
20
+ default behavior in rspec-3. This lets you add metadata to a group or example
21
+ like this:
22
+
23
+ describe "something", :awesome do
24
+ ...
25
+
26
+ And then you can run that group (or example) using the tags feature:
27
+
28
+ rspec spec --tag awesome
29
+
30
+ We're making this an opt-in for rspec-2.6 because `describe "string", :symbol`
31
+ is a perfectly legal construct in pre-2.6 releases and we want to maintain
32
+ compatibility in minor releases as much as is possible.
33
+
34
+ # rspec-core-2.3
35
+
36
+ ## `config.expect_with`
37
+
38
+ Use this to configure RSpec to use rspec/expectations (default),
39
+ stdlib assertions (Test::Unit with Ruby 1.8, MiniTest with Ruby 1.9),
40
+ or both:
41
+
42
+ RSpec.configure do |config|
43
+ config.expect_with :rspec # => rspec/expectations
44
+ config.expect_with :stdlib # => Test::Unit or MinitTest
45
+ config.expect_with :rspec, :stdlib # => both
46
+ end
47
+
48
+ # rspec-core-2.1
49
+
50
+ ## Command line
51
+
52
+ ### `--tags`
53
+
54
+ Now you can tag groups and examples using metadata and access those tags from
55
+ the command line. So if you have a group with `:foo => true`:
56
+
57
+ describe "something", :foo => true do
58
+ it "does something" do
59
+ # ...
60
+ end
61
+ end
62
+
63
+ ... now you can run just that group like this:
64
+
65
+ rspec spec --tags foo
66
+
67
+ ### `--fail-fast`
68
+
69
+ Add this flag to the command line to tell rspec to clean up and exit after the
70
+ first failure:
71
+
72
+ rspec spec --fail-fast
73
+
74
+ ## Metata/filtering
75
+
76
+ ### :if and :unless keys
77
+
78
+ Use :if and :unless keys to conditionally run examples with simple boolean
79
+ expressions:
80
+
81
+ describe "something" do
82
+ it "does something", :if => RUBY_VERSION == 1.8.6 do
83
+ # ...
84
+ end
85
+ it "does something", :unless => RUBY_VERSION == 1.8.6 do
86
+ # ...
87
+ end
88
+ end
89
+
90
+ ## Conditionally 'pending' examples
91
+
92
+ Make examples pending based on a condition. This is most useful when you
93
+ have an example that runs in multiple contexts and fails in one of those due to
94
+ a bug in a third-party dependency that you expect to be fixed in the future.
95
+
96
+ describe "something" do
97
+ it "does something that doesn't yet work right on JRuby" do
98
+ pending("waiting for the JRuby team to fix issue XYZ", :if => RUBY_PLATFORM == 'java') do
99
+ # the content of your spec
100
+ end
101
+ end
102
+ end
103
+
104
+ This example would run normally on all ruby interpretters except JRuby. On JRuby,
105
+ it uses the block form of `pending`, which causes the example to still be run and
106
+ will remain pending as long as it fails. In the future, if you upgraded your
107
+ JRuby installation to a newer release that allows the example to pass, RSpec
108
+ will report it as a failure (`Expected pending '...' to fail. No Error was raised.`),
109
+ so that know that you can remove the call to `pending`.
110
+
111
+ # New features in rspec-core-2.0
112
+
113
+ ### Runner
114
+
115
+ The new runner for rspec-2 comes from Micronaut.
116
+
117
+ ### Metadata!
118
+
119
+ In rspec-2, every example and example group comes with metadata information
120
+ like the file and line number on which it was declared, the arguments passed to
121
+ `describe` and `it`, etc. This metadata can be appended to through a hash
122
+ argument passed to `describe` or `it`, allowing us to pre and post-process
123
+ each example in a variety of ways.
124
+
125
+ ### Filtering
126
+
127
+ The most obvious use is for filtering the run. For example:
128
+
129
+ # in spec/spec_helper.rb
130
+ RSpec.configure do |c|
131
+ c.filter_run :focus => true
132
+ end
133
+
134
+ # in any spec file
135
+ describe "something" do
136
+ it "does something", :focus => true do
137
+ # ....
138
+ end
139
+ end
140
+
141
+ When you run the `rspec` command, rspec will run only the examples that have
142
+ `:focus => true` in the hash.
143
+
144
+ You can also add `run_all_when_everything_filtered` to the config:
145
+
146
+ RSpec.configure do |c|
147
+ c.filter_run :focus => true
148
+ c.run_all_when_everything_filtered = true
149
+ end
150
+
151
+ Now if there are no examples tagged with `:focus => true`, all examples
152
+ will be run. This makes it really easy to focus on one example for a
153
+ while, but then go back to running all of the examples by removing that
154
+ argument from `it`. Works with `describe` too, in which case it runs
155
+ all of the examples in that group.
156
+
157
+ The configuration will accept a lambda, which provides a lot of flexibility
158
+ in filtering examples. Say, for example, you have a spec for functionality that
159
+ behaves slightly differently in Ruby 1.8 and Ruby 1.9. We have that in
160
+ rspec-core, and here's how we're getting the right stuff to run under the
161
+ right version:
162
+
163
+ # in spec/spec_helper.rb
164
+ RSpec.configure do |c|
165
+ c.exclusion_filter = { :ruby => lambda {|version|
166
+ !(RUBY_VERSION.to_s =~ /^#{version.to_s}/)
167
+ }}
168
+ end
169
+
170
+ # in any spec file
171
+ describe "something" do
172
+ it "does something", :ruby => 1.8 do
173
+ # ....
174
+ end
175
+
176
+ it "does something", :ruby => 1.9 do
177
+ # ....
178
+ end
179
+ end
180
+
181
+ In this case, we're using `exclusion_filter` instead of `filter_run` or
182
+ `filter`, which indicate _inclusion_ filters. So each of those examples is
183
+ excluded if we're _not_ running the version of Ruby they work with.
184
+
185
+ ### Shared example groups
186
+
187
+ Shared example groups are now run in a nested group within the including group
188
+ (they used to be run in the same group). Nested groups inherit `before`, `after`,
189
+ `around`, and `let` hooks, as well as any methods that are defined in the parent
190
+ group.
191
+
192
+ This new approach provides better encapsulation, better output, and an
193
+ opportunity to add contextual information to the shared group via a block
194
+ passed to `it_should_behave_like`.
195
+
196
+ 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.
197
+
198
+ NOTICE: The including example groups no longer have access to any of the
199
+ methods, hooks, or state defined inside a shared group. This will break rspec-1
200
+ specs that were using shared example groups to extend the behavior of including
201
+ groups.
202
+
203
+ # Upgrading from rspec-1.x
204
+
205
+ ### rspec command
206
+
207
+ The command to run specs is now `rspec` instead of `spec`.
208
+
209
+ rspec ./spec
210
+
211
+ #### Co-habitation of rspec-1 and rspec-2
212
+
213
+ Early beta versions of RSpec-2 included a `spec` command, which conflicted with
214
+ the RSpec-1 `spec` command because RSpec-1's was installed by the rspec gem,
215
+ while RSpec-2's is installed by the rspec-core gem.
216
+
217
+ If you installed one of these early versions, the safest bet is to uninstall
218
+ rspec-1 and rspec-core-2, and then reinstall both. After you do this, you will
219
+ be able to run rspec-2 like this:
220
+
221
+ rspec ./spec
222
+
223
+ ... and rspec-1 like this:
224
+
225
+ spec _1.3.1_ ./spec
226
+
227
+ Rubygems inspects the first argument to any gem executable to see if it's
228
+ formatted like a version number surrounded by underscores. If so, it uses that
229
+ version (e.g. `1.3.1`). If not, it uses the most recent version (e.g.
230
+ `2.0.0`).
231
+
232
+ ### rake task
233
+
234
+ A few things changed in the Rake task used to run specs:
235
+
236
+ 1. The file in which it is defined changed from `spec/rake/spectask` to
237
+ `rspec/core/rake_task`
238
+
239
+ 2. The `spec_opts` accessor has been deprecated in favor of `rspec_opts`. Also,
240
+ the `rspec` command no longer supports the `--options` command line option
241
+ so the options must be embedded directly in the Rakefile, or stored in the
242
+ `.rspec` files mentioned above.
243
+
244
+ 3. In RSpec-1, the rake task would read in rcov options from an `rcov.opts`
245
+ file. This is ignored by RSpec-2. RCov options are now set directly on the Rake
246
+ task:
247
+
248
+ RSpec::Core::RakeTask.new(:rcov) do |t|
249
+ t.rcov_opts = %q[--exclude "spec"]
250
+ end
251
+
252
+ 3. The `spec_files` accessor has been replaced by `pattern`.
253
+
254
+ # rspec-1
255
+ require 'spec/rake/spectask'
256
+
257
+ Spec::Rake::SpecTask.new do |t|
258
+ t.spec_opts = ['--options', "\"spec/spec.opts\""]
259
+ t.spec_files = FileList['spec/**/*.rb']
260
+ end
261
+
262
+ # rspec-2
263
+ require 'rspec/core/rake_task'
264
+
265
+ RSpec::Core::RakeTask.new do |t|
266
+ t.rspec_opts = ["-c", "-f progress", "-r ./spec/spec_helper.rb"]
267
+ t.pattern = 'spec/**/*_spec.rb'
268
+ end
269
+
270
+ ### autotest
271
+
272
+ `autospec` is dead. Long live `autotest`.
273
+
274
+ ### RSpec is the new Spec
275
+
276
+ The root namespace (top level module) is now `RSpec` instead of `Spec`, and
277
+ the root directory under `lib` within all of the `rspec` gems is `rspec` instead of `spec`.
278
+
279
+ ### Configuration
280
+
281
+ Typically in `spec/spec_helper.rb`, configuration is now done like this:
282
+
283
+ RSpec.configure do |c|
284
+ # ....
285
+ end
286
+
287
+ ### .rspec
288
+
289
+ Command line options can be persisted in a `.rspec` file in a project. You
290
+ can also store a `.rspec` file in your home directory (`~/.rspec`) with global
291
+ options. Precedence is:
292
+
293
+ command line
294
+ ./.rspec
295
+ ~/.rspec
296
+
297
+ ### `context` is no longer a top-level method
298
+
299
+ We removed `context` from the main object because it was creating conflicts with
300
+ IRB and some users who had `Context` domain objects. `describe` is still there,
301
+ so if you want to use `context` at the top level, just alias it:
302
+
303
+ alias :context :describe
304
+
305
+ Of course, you can still use `context` to declare a nested group:
306
+
307
+ describe "something" do
308
+ context "in some context" do
309
+ it "does something" do
310
+ # ...
311
+ end
312
+ end
313
+ end
314
+
315
+ ### `$KCODE` no longer set implicitly to `'u'`
316
+
317
+ In RSpec-1, the runner set `$KCODE` to `'u'`, which impacts, among other
318
+ things, the behaviour of Regular Expressions when applied to non-ascii
319
+ characters. This is no longer the case in RSpec-2.
320
+
@@ -0,0 +1,28 @@
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,19 +1,22 @@
1
- Feature: configure
1
+ Feature: --configure option
2
2
 
3
- Use --configure to generate configuration files.
3
+ Use the --configure option on the command line to generate configuration
4
+ files.
4
5
 
5
- Currently, the only supported argument is "autotest", which creates
6
- a autotest/discover.rb file in your project root directory.
6
+ The only supported argument, so far, is "autotest", which creates a .rspec
7
+ file in your project root directory. When autotest sees this file, it knows
8
+ to load RSpec's Autotest subclass.
7
9
 
8
- Background:
9
- Given a directory named "rspec_project"
10
- And I cd to "rspec_project"
10
+ Scenario: generate .rspec file for autotest
11
+ When I run `rspec --configure autotest`
12
+ Then the following files should exist:
13
+ | .rspec |
14
+ And the output should contain ".rspec file did not exist, so it was created."
11
15
 
12
- Scenario: generate autotest directory and discover file
13
- When I run "rspec --configure autotest"
14
- Then the following directories should exist:
15
- | autotest |
16
- And the following files should exist:
17
- | autotest/discover.rb |
18
- And the file "autotest/discover.rb" should contain "Autotest.add_discovery"
19
- And the stdout should contain "autotest/discover.rb has been added"
16
+ Scenario: .rspec file already exists
17
+ Given a file named ".rspec" with:
18
+ """
19
+ --color
20
+ """
21
+ When I run `rspec --configure autotest`
22
+ Then the output should contain ".rspec file already exists, so nothing was changed."
@@ -1,13 +1,13 @@
1
- Feature: example name option
1
+ Feature: --example option
2
2
 
3
- Use the --example (or -e) option to filter the examples to be run by name.
3
+ Use the --example (or -e) option to filter examples by name.
4
4
 
5
5
  The argument is compiled to a Ruby Regexp, and matched against the full
6
6
  description of the example, which is the concatenation of descriptions of the
7
7
  group (including any nested groups) and the example.
8
8
 
9
9
  This allows you to run a single uniquely named example, all examples with
10
- similar names, all the example in a uniquely named group, etc, etc.
10
+ similar names, all the examples in a uniquely named group, etc, etc.
11
11
 
12
12
  Background:
13
13
  Given a file named "first_spec.rb" with:
@@ -17,14 +17,14 @@ Feature: example name option
17
17
  it "second example in first group" do; end
18
18
  end
19
19
  """
20
- Given a file named "second_spec.rb" with:
20
+ And a file named "second_spec.rb" with:
21
21
  """
22
22
  describe "second group" do
23
23
  it "first example in second group" do; end
24
24
  it "second example in second group" do; end
25
25
  end
26
26
  """
27
- Given a file named "third_spec.rb" with:
27
+ And a file named "third_spec.rb" with:
28
28
  """
29
29
  describe "third group" do
30
30
  it "first example in third group" do; end
@@ -34,39 +34,53 @@ Feature: example name option
34
34
  end
35
35
  end
36
36
  """
37
+ And a file named "fourth_spec.rb" with:
38
+ """
39
+ describe Array do
40
+ describe "#length" do
41
+ it "is the number of items" do
42
+ Array.new([1,2,3]).length.should eq 3
43
+ end
44
+ end
45
+ end
46
+ """
37
47
 
38
48
  Scenario: no matches
39
- When I run "rspec . --example nothing_like_this"
40
- Then the output should contain "0 examples, 0 failures"
49
+ When I run `rspec . --example nothing_like_this`
50
+ Then the examples should all pass
41
51
 
42
52
  Scenario: match on one word
43
- When I run "rspec . --example example"
44
- Then the output should contain "7 examples, 0 failures"
53
+ When I run `rspec . --example example`
54
+ Then the examples should all pass
45
55
 
46
56
  Scenario: one match in each context
47
- When I run "rspec . --example 'first example'"
48
- Then the output should contain "4 examples, 0 failures"
57
+ When I run `rspec . --example 'first example'`
58
+ Then the examples should all pass
49
59
 
50
60
  Scenario: one match in one file using just the example name
51
- When I run "rspec . --example 'first example in first group'"
52
- Then the output should contain "1 example, 0 failures"
61
+ When I run `rspec . --example 'first example in first group'`
62
+ Then the examples should all pass
53
63
 
54
64
  Scenario: one match in one file using the example name and the group name
55
- When I run "rspec . --example 'first group first example in first group'"
56
- Then the output should contain "1 example, 0 failures"
65
+ When I run `rspec . --example 'first group first example in first group'`
66
+ Then the examples should all pass
57
67
 
58
68
  Scenario: one match in one file using regexp
59
- When I run "rspec . --example 'first .* first example'"
60
- Then the output should contain "1 example, 0 failures"
69
+ When I run `rspec . --example 'first .* first example'`
70
+ Then the examples should all pass
61
71
 
62
72
  Scenario: all examples in one group
63
- When I run "rspec . --example 'first group'"
64
- Then the output should contain "2 examples, 0 failures"
73
+ When I run `rspec . --example 'first group'`
74
+ Then the examples should all pass
65
75
 
66
76
  Scenario: one match in one file with group name
67
- When I run "rspec . --example 'second group first example'"
68
- Then the output should contain "1 example, 0 failures"
77
+ When I run `rspec . --example 'second group first example'`
78
+ Then the examples should all pass
69
79
 
70
80
  Scenario: all examples in one group including examples in nested groups
71
- When I run "rspec . --example 'third group'"
72
- Then the output should contain "3 examples, 0 failures"
81
+ When I run `rspec . --example 'third group'`
82
+ Then the examples should all pass
83
+
84
+ Scenario: Object#method
85
+ When I run `rspec . --example 'Array#length'`
86
+ Then the examples should all pass
@@ -1,6 +1,7 @@
1
1
  Feature: exit status
2
- In order to fail the build when it should,
3
- the spec CLI exits with an appropriate exit status
2
+
3
+ In order to fail the build when it should, the spec CLI exits with an
4
+ appropriate exit status
4
5
 
5
6
  Scenario: exit with 0 when all examples pass
6
7
  Given a file named "ok_spec.rb" with:
@@ -10,11 +11,9 @@ Feature: exit status
10
11
  end
11
12
  end
12
13
  """
13
- When I run "rspec ok_spec.rb"
14
- Then it should pass with:
15
- """
16
- 1 example, 0 failures
17
- """
14
+ When I run `rspec ok_spec.rb`
15
+ Then the exit status should be 0
16
+ And the examples should all pass
18
17
 
19
18
  Scenario: exit with 1 when one example fails
20
19
  Given a file named "ko_spec.rb" with:
@@ -25,11 +24,9 @@ Feature: exit status
25
24
  end
26
25
  end
27
26
  """
28
- When I run "rspec ko_spec.rb"
29
- Then it should fail with:
30
- """
31
- 1 example, 1 failure
32
- """
27
+ When I run `rspec ko_spec.rb`
28
+ Then the exit status should be 1
29
+ And the output should contain "1 example, 1 failure"
33
30
 
34
31
  Scenario: exit with 1 when a nested examples fails
35
32
  Given a file named "nested_ko_spec.rb" with:
@@ -42,26 +39,14 @@ Feature: exit status
42
39
  end
43
40
  end
44
41
  """
45
- When I run "rspec nested_ko_spec.rb"
46
- Then it should fail with:
47
- """
48
- 1 example, 1 failure
49
- """
42
+ When I run `rspec nested_ko_spec.rb`
43
+ Then the exit status should be 1
44
+ And the output should contain "1 example, 1 failure"
50
45
 
51
46
  Scenario: exit with 0 when no examples are run
52
- Given a file named "spec/a_no_examples_spec.rb" with:
53
- """
54
- """
55
- And a file named "spec/b_one_example_spec.rb" with:
56
- """
57
- describe "something" do
58
- it "does something" do
59
- end
60
- end
61
- """
62
-
63
- When I run "rspec spec"
64
- Then it should pass with:
47
+ Given a file named "a_no_examples_spec.rb" with:
65
48
  """
66
- 1 example, 0 failures
67
49
  """
50
+ When I run `rspec a_no_examples_spec.rb`
51
+ Then the exit status should be 0
52
+ And the output should contain "0 examples"
@@ -0,0 +1,73 @@
1
+ Feature: --format option
2
+
3
+ Use the --format option to tell RSpec how to format the output.
4
+
5
+ RSpec ships with a few formatters built in. By default, it uses the progress
6
+ formatter, which generates output like this:
7
+
8
+ ....F.....*.....
9
+
10
+ A '.' represents a passing example, 'F' is failing, and '*' is pending.
11
+
12
+ To see the documentation strings passed to each describe(), context(), and it()
13
+ method, use the documentation formatter:
14
+
15
+ $ rspec spec --format documentation
16
+
17
+ You can also specify an output target (STDOUT by default) by appending a
18
+ filename to the argument:
19
+
20
+ $ rspec spec --format documentation:rspec.output.txt
21
+
22
+ Background:
23
+ Given a file named "example_spec.rb" with:
24
+ """
25
+ describe "something" do
26
+ it "does something that passes" do
27
+ 5.should eq(5)
28
+ end
29
+
30
+ it "does something that fails" do
31
+ 5.should eq(4)
32
+ end
33
+
34
+ it "does something that is pending", :pending => true do
35
+ 5.should be > 3
36
+ end
37
+ end
38
+ """
39
+
40
+ Scenario: progress bar format (default)
41
+ When I run `rspec example_spec.rb`
42
+ Then the output should contain ".F*"
43
+
44
+ Scenario: documentation format
45
+ When I run `rspec example_spec.rb --format documentation`
46
+ Then the output should contain:
47
+ """
48
+ something
49
+ does something that passes
50
+ does something that fails (FAILED - 1)
51
+ does something that is pending (PENDING: Not Yet Implemented)
52
+ """
53
+
54
+ Scenario: documentation format saved to a file
55
+ When I run `rspec example_spec.rb --format documentation --out rspec.txt`
56
+ Then the file "rspec.txt" should contain:
57
+ """
58
+ something
59
+ does something that passes
60
+ does something that fails (FAILED - 1)
61
+ does something that is pending (PENDING: Not Yet Implemented)
62
+ """
63
+
64
+ Scenario: multiple formats
65
+ When I run `rspec example_spec.rb --format progress --format documentation --out rspec.txt`
66
+ Then the output should contain ".F*"
67
+ And the file "rspec.txt" should contain:
68
+ """
69
+ something
70
+ does something that passes
71
+ does something that fails (FAILED - 1)
72
+ does something that is pending (PENDING: Not Yet Implemented)
73
+ """