rspec-core 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/.gitignore +1 -0
  2. data/Gemfile +9 -4
  3. data/Guardfile +3 -3
  4. data/README.md +1 -1
  5. data/features/.nav +7 -2
  6. data/features/{README.markdown → Autotest.md} +17 -20
  7. data/features/Changelog.md +57 -2
  8. data/features/README.md +17 -0
  9. data/features/Upgrade.md +8 -66
  10. data/features/command_line/configure.feature +2 -2
  11. data/features/command_line/example_name_option.feature +10 -10
  12. data/features/command_line/exit_status.feature +4 -4
  13. data/features/command_line/line_number_appended_to_path.feature +11 -11
  14. data/features/command_line/line_number_option.feature +9 -9
  15. data/features/command_line/tag.feature +9 -9
  16. data/features/configuration/custom_settings.feature +3 -3
  17. data/features/configuration/fail_fast.feature +3 -3
  18. data/features/configuration/read_options_from_file.feature +4 -4
  19. data/features/example_groups/shared_example_group.feature +4 -4
  20. data/features/expectation_framework_integration/configure_expectation_framework.feature +8 -9
  21. data/features/filtering/exclusion_filters.feature +1 -1
  22. data/features/filtering/run_all_when_everything_filtered.feature +1 -1
  23. data/features/formatters/custom_formatter.feature +17 -13
  24. data/features/helper_methods/arbitrary_methods.feature +40 -0
  25. data/features/helper_methods/let.feature +50 -0
  26. data/features/hooks/before_and_after_hooks.feature +10 -10
  27. data/features/hooks/filtering.feature +37 -20
  28. data/features/metadata/described_class.feature +1 -1
  29. data/features/mock_framework_integration/use_flexmock.feature +1 -1
  30. data/features/mock_framework_integration/use_mocha.feature +1 -1
  31. data/features/mock_framework_integration/use_rr.feature +1 -1
  32. data/features/mock_framework_integration/use_rspec.feature +1 -1
  33. data/features/spec_files/arbitrary_file_suffix.feature +1 -1
  34. data/features/step_definitions/additional_cli_steps.rb +1 -1
  35. data/features/subject/attribute_of_subject.feature +2 -2
  36. data/features/subject/explicit_subject.feature +5 -5
  37. data/features/subject/implicit_receiver.feature +2 -2
  38. data/features/subject/implicit_subject.feature +2 -2
  39. data/lib/autotest/rspec2.rb +63 -13
  40. data/lib/rspec/core/configuration.rb +0 -1
  41. data/lib/rspec/core/configuration_options.rb +15 -12
  42. data/lib/rspec/core/example.rb +14 -6
  43. data/lib/rspec/core/example_group.rb +5 -4
  44. data/lib/rspec/core/formatters/base_formatter.rb +1 -1
  45. data/lib/rspec/core/formatters/documentation_formatter.rb +1 -1
  46. data/lib/rspec/core/formatters/html_formatter.rb +131 -32
  47. data/lib/rspec/core/formatters/snippet_extractor.rb +1 -1
  48. data/lib/rspec/core/hooks.rb +16 -1
  49. data/lib/rspec/core/option_parser.rb +6 -6
  50. data/lib/rspec/core/rake_task.rb +1 -1
  51. data/lib/rspec/core/subject.rb +7 -7
  52. data/lib/rspec/core/version.rb +1 -1
  53. data/rspec-core.gemspec +0 -12
  54. data/script/FullBuildRakeFile +63 -0
  55. data/script/cucumber +1 -0
  56. data/script/full_build +1 -0
  57. data/script/spec +1 -0
  58. data/spec/autotest/failed_results_re_spec.rb +22 -5
  59. data/spec/autotest/rspec_spec.rb +132 -16
  60. data/spec/rspec/core/configuration_options_spec.rb +38 -6
  61. data/spec/rspec/core/example_group_spec.rb +15 -64
  62. data/spec/rspec/core/formatters/base_formatter_spec.rb +23 -0
  63. data/spec/rspec/core/formatters/html_formatted-1.8.6.html +150 -48
  64. data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +151 -49
  65. data/spec/rspec/core/formatters/html_formatted-1.8.7.html +150 -48
  66. data/spec/rspec/core/formatters/html_formatted-1.9.1.html +150 -48
  67. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +150 -48
  68. data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +150 -48
  69. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +151 -49
  70. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +150 -48
  71. data/spec/rspec/core/formatters/text_mate_formatted-1.9.1.html +150 -48
  72. data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +150 -48
  73. data/spec/rspec/core/hooks_filtering_spec.rb +49 -0
  74. data/spec/rspec/core/rake_task_spec.rb +3 -3
  75. data/spec/rspec/core/subject_spec.rb +81 -0
  76. metadata +20 -22
  77. data/History.markdown +0 -186
  78. data/Upgrade.markdown +0 -345
@@ -1,345 +0,0 @@
1
- # rspec-core-2.3
2
-
3
- ## autotest integration
4
-
5
- Add a .rspec file to the project's root directory to tell RSpec to tell
6
- Autotest to use RSpec's specialized Autotest class.
7
-
8
- NOTE that rspec-core-2.0, 2.1, and 2.2 required an autotest/discover.rb file in
9
- the project's root directory. This worked with some, but not all versions of
10
- autotest and/or the autotest command that ships with ZenTest. This new approach
11
- will work regardless of which version of autotest/ZenTest you are using.
12
-
13
- ## config.expect_with
14
-
15
- Use this to configure RSpec to use rspec/expectations (default),
16
- test/unit/assertions, or both:
17
-
18
- RSpec.configure do |config|
19
- config.expect_with :rspec # => rspec/expectations
20
- config.expect_with :stdlib # => test/unit/assertions
21
- config.expect_with :rspec, :stdlib # => both
22
- end
23
-
24
- # rspec-core-2.2
25
-
26
- ## FASTER!
27
-
28
- Made several small optimizations that all add up to a considerable improvement
29
- in performance. Using a simple benchmark:
30
-
31
- generate 5000 example groups,
32
- each with one example,
33
- each with one passing expectation
34
-
35
- Run using ruby-1.9.2 on Mac OS X w/ 3.06 G
36
-
37
- * rspec-2.1
38
- * loaded in 0.85 on avg
39
- * ran in 2.61 on avg
40
- * rspec-2.2
41
- * loaded in 0.73 on avg (~15% improvement)
42
- * ran in 0.94 on avg (~64% improvement**)
43
-
44
- ** this does _not_ mean your suite will be 64% faster, but it does mean that
45
- the overhead incurred by RSpec in your suite should be roughly 64% less.
46
-
47
- ## Command line
48
-
49
- ### --debug/-d is now deprecated
50
-
51
- This command line option is now has no effect (other than a deprecation
52
- warning). To use the debugger, just add a `debugger` statement anywhere in your
53
- code. As long as you have ruby-debug installed, it will just work. If you
54
- don't, then you'll get a friendly warning telling you what's going on, but
55
- execution will continue.
56
-
57
- # rspec-core-2.1
58
-
59
- ## Command line
60
-
61
- ### `--tags`
62
-
63
- Now you can tag groups and examples using metadata and access those tags from
64
- the command line. So if you have a group with `:foo => true`:
65
-
66
- describe "something", :foo => true do
67
- it "does something" do
68
- # ...
69
- end
70
- end
71
-
72
- ... now you can run just that group like this:
73
-
74
- rspec spec --tags foo
75
-
76
- ### `--fail-fast`
77
-
78
- Add this flag to the command line to tell rspec to clean up and exit after the
79
- first failure:
80
-
81
- rspec spec --fail-fast
82
-
83
- ## Metata/filtering
84
-
85
- ### :if and :unless keys
86
-
87
- Use :if and :unless keys to conditionally run examples with simple boolean
88
- expressions:
89
-
90
- describe "something" do
91
- it "does something", :if => RUBY_VERSION == 1.8.6 do
92
- # ...
93
- end
94
- it "does something", :unless => RUBY_VERSION == 1.8.6 do
95
- # ...
96
- end
97
- end
98
-
99
- ## Conditionally 'pending' examples
100
-
101
- Make examples pending based on a condition. This is most useful when you
102
- have an example that runs in multiple contexts and fails in one of those due to
103
- a bug in a third-party dependency that you expect to be fixed in the future.
104
-
105
- describe "something" do
106
- it "does something that doesn't yet work right on JRuby" do
107
- pending("waiting for the JRuby team to fix issue XYZ", :if => RUBY_PLATFORM == 'java') do
108
- # the content of your spec
109
- end
110
- end
111
- end
112
-
113
- This example would run normally on all ruby interpretters except JRuby. On JRuby,
114
- it uses the block form of `pending`, which causes the example to still be run and
115
- will remain pending as long as it fails. In the future, if you upgraded your
116
- JRuby installation to a newer release that allows the example to pass, RSpec
117
- will report it as a failure (`Expected pending '...' to fail. No Error was raised.`),
118
- so that know that you can remove the call to `pending`.
119
-
120
- # New features in rspec-core-2.0
121
-
122
- ### Runner
123
-
124
- The new runner for rspec-2 comes from Micronaut.
125
-
126
- ### Metadata!
127
-
128
- In rspec-2, every example and example group comes with metadata information
129
- like the file and line number on which it was declared, the arguments passed to
130
- `describe` and `it`, etc. This metadata can be appended to through a hash
131
- argument passed to `describe` or `it`, allowing us to pre and post-process
132
- each example in a variety of ways.
133
-
134
- ### Filtering
135
-
136
- The most obvious use is for filtering the run. For example:
137
-
138
- # in spec/spec_helper.rb
139
- RSpec.configure do |c|
140
- c.filter_run :focus => true
141
- end
142
-
143
- # in any spec file
144
- describe "something" do
145
- it "does something", :focus => true do
146
- # ....
147
- end
148
- end
149
-
150
- When you run the `rspec` command, rspec will run only the examples that have
151
- `:focus => true` in the hash.
152
-
153
- You can also add `run_all_when_everything_filtered` to the config:
154
-
155
- RSpec.configure do |c|
156
- c.filter_run :focus => true
157
- c.run_all_when_everything_filtered = true
158
- end
159
-
160
- Now if there are no examples tagged with `:focus => true`, all examples
161
- will be run. This makes it really easy to focus on one example for a
162
- while, but then go back to running all of the examples by removing that
163
- argument from `it`. Works with `describe` too, in which case it runs
164
- all of the examples in that group.
165
-
166
- The configuration will accept a lambda, which provides a lot of flexibility
167
- in filtering examples. Say, for example, you have a spec for functionality that
168
- behaves slightly differently in Ruby 1.8 and Ruby 1.9. We have that in
169
- rspec-core, and here's how we're getting the right stuff to run under the
170
- right version:
171
-
172
- # in spec/spec_helper.rb
173
- RSpec.configure do |c|
174
- c.exclusion_filter = { :ruby => lambda {|version|
175
- !(RUBY_VERSION.to_s =~ /^#{version.to_s}/)
176
- }}
177
- end
178
-
179
- # in any spec file
180
- describe "something" do
181
- it "does something", :ruby => 1.8 do
182
- # ....
183
- end
184
-
185
- it "does something", :ruby => 1.9 do
186
- # ....
187
- end
188
- end
189
-
190
- In this case, we're using `exclusion_filter` instead of `filter_run` or
191
- `filter`, which indicate _inclusion_ filters. So each of those examples is
192
- excluded if we're _not_ running the version of Ruby they work with.
193
-
194
- ### Shared example groups
195
-
196
- Shared example groups are now run in a nested group within the including group
197
- (they used to be run in the same group). Nested groups inherit `before`, `after`,
198
- `around`, and `let` hooks, as well as any methods that are defined in the parent
199
- group.
200
-
201
- This new approach provides better encapsulation, better output, and an
202
- opportunity to add contextual information to the shared group via a block
203
- passed to `it_should_behave_like`.
204
-
205
- 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.
206
-
207
- NOTICE: The including example groups no longer have access to any of the
208
- methods, hooks, or state defined inside a shared group. This will break specs
209
- that were using shared example groups to extend the behavior of including
210
- groups in any way besides their intended purpose: to add examples to a group.
211
-
212
- # Upgrading from rspec-1.x
213
-
214
- ### rspec command
215
-
216
- The command to run specs is now `rspec` instead of `spec`.
217
-
218
- rspec ./spec
219
-
220
- #### Co-habitation of rspec-1 and rspec-2
221
-
222
- Early beta versions of RSpec-2 included a `spec` command, which conflicted with
223
- the RSpec-1 `spec` command because RSpec-1's was installed by the rspec gem,
224
- while RSpec-2's is installed by the rspec-core gem.
225
-
226
- If you installed one of these early versions, the safest bet is to uninstall
227
- rspec-1 and rspec-core-2, and then reinstall both. After you do this, you will
228
- be able to run rspec-2 like this:
229
-
230
- rspec ./spec
231
-
232
- ... and rspec-1 like this:
233
-
234
- spec _1.3.1_ ./spec
235
-
236
- Rubygems inspects the first argument to any gem executable to see if it's
237
- formatted like a version number surrounded by underscores. If so, it uses that
238
- version (e.g. `1.3.1`). If not, it uses the most recent version (e.g.
239
- `2.0.0`).
240
-
241
- ### rake task
242
-
243
- A few things changed in the Rake task used to run specs:
244
-
245
- 1. The file in which it is defined changed from `spec/rake/spectask` to
246
- `rspec/core/rake_task`
247
-
248
- 2. The `spec_opts` accessor has been deprecated in favor of `rspec_opts`. Also,
249
- the `rspec` command no longer supports the `--options` command line option
250
- so the options must be embedded directly in the Rakefile, or stored in the
251
- `.rspec` files mentioned above.
252
-
253
- 3. In RSpec-1, the rake task would read in rcov options from an `rcov.opts`
254
- file. This is ignored by RSpec-2. RCov options are now set directly on the Rake
255
- task:
256
-
257
- RSpec::Core::RakeTask.new(:rcov) do |t|
258
- t.rcov_opts = %q[--exclude "spec"]
259
- end
260
-
261
- 3. The `spec_files` accessor has been replaced by `pattern`.
262
-
263
- # rspec-1
264
- require 'spec/rake/spectask'
265
-
266
- Spec::Rake::SpecTask.new do |t|
267
- t.spec_opts = ['--options', "\"spec/spec.opts\""]
268
- t.spec_files = FileList['spec/**/*.rb']
269
- end
270
-
271
- # rspec-2
272
- require 'rspec/core/rake_task'
273
-
274
- RSpec::Core::RakeTask.new do |t|
275
- t.rspec_opts = ["-c", "-f progress", "-r ./spec/spec_helper.rb"]
276
- t.pattern = 'spec/**/*_spec.rb'
277
- end
278
-
279
- ### autotest
280
-
281
- RSpec-2 works with autotest as follows:
282
-
283
- rspec --configure autotest
284
-
285
- This adds `./autotest/discover.rb` with:
286
-
287
- Autotest.add_discovery { "rspec2" }
288
-
289
- Now, on the command line just type:
290
-
291
- autotest
292
-
293
- Or, if you're using bundler:
294
-
295
- bundle exec autotest
296
-
297
- The `autospec` command is a thing of the past.
298
-
299
- ### RSpec is the new Spec
300
-
301
- The root namespace (top level module) is now `RSpec` instead of `Spec`, and
302
- the root directory under `lib` within all of the `rspec` gems is `rspec` instead of `spec`.
303
-
304
- ### Configuration
305
-
306
- Typically in `spec/spec_helper.rb`, configuration is now done like this:
307
-
308
- RSpec.configure do |c|
309
- # ....
310
- end
311
-
312
- ### .rspec
313
-
314
- Command line options can be persisted in a `.rspec` file in a project. You
315
- can also store a `.rspec` file in your home directory (`~/.rspec`) with global
316
- options. Precedence is:
317
-
318
- command line
319
- ./.rspec
320
- ~/.rspec
321
-
322
- ### `context` is no longer a top-level method
323
-
324
- We removed `context` from the main object because it was creating conflicts with
325
- IRB and some users who had `Context` domain objects. `describe` is still there,
326
- so if you want to use `context` at the top level, just alias it:
327
-
328
- alias :context :describe
329
-
330
- Of course, you can still use `context` to declare a nested group:
331
-
332
- describe "something" do
333
- context "in some context" do
334
- it "does something" do
335
- # ...
336
- end
337
- end
338
- end
339
-
340
- ### `$KCODE` no longer set implicitly to `'u'`
341
-
342
- In RSpec-1, the runner set `$KCODE` to `'u'`, which impacts, among other
343
- things, the behaviour of Regular Expressions when applied to non-ascii
344
- characters. This is no longer the case in RSpec-2.
345
-