rspec-core 3.0.0.beta1 → 3.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/Changelog.md +137 -0
- data/README.md +2 -2
- data/exe/rspec +2 -23
- data/features/README.md +1 -5
- data/features/command_line/README.md +7 -10
- data/features/command_line/exit_status.feature +1 -1
- data/features/command_line/format_option.feature +1 -1
- data/features/command_line/init.feature +40 -1
- data/features/command_line/line_number_option.feature +2 -2
- data/features/command_line/ruby.feature +5 -4
- data/features/configuration/enable_global_dsl.feature +54 -0
- data/features/example_groups/aliasing.feature +48 -0
- data/features/example_groups/basic_structure.feature +1 -1
- data/features/expectation_framework_integration/configure_expectation_framework.feature +1 -1
- data/features/filtering/if_and_unless.feature +0 -30
- data/features/formatters/custom_formatter.feature +32 -0
- data/features/formatters/regression_tests.feature +95 -0
- data/features/hooks/around_hooks.feature +1 -0
- data/features/hooks/before_and_after_hooks.feature +2 -2
- data/features/mock_framework_integration/use_flexmock.feature +11 -13
- data/features/mock_framework_integration/use_mocha.feature +11 -13
- data/features/mock_framework_integration/use_rr.feature +11 -13
- data/features/mock_framework_integration/use_rspec.feature +11 -13
- data/features/pending_and_skipped_examples/README.md +3 -0
- data/features/pending_and_skipped_examples/pending_examples.feature +118 -0
- data/features/pending_and_skipped_examples/skipped_examples.feature +106 -0
- data/features/step_definitions/additional_cli_steps.rb +34 -0
- data/features/subject/explicit_subject.feature +1 -1
- data/features/subject/one_liner_syntax.feature +71 -0
- data/lib/rspec/core.rb +6 -14
- data/lib/rspec/core/backtrace_formatter.rb +16 -4
- data/lib/rspec/core/command_line.rb +2 -3
- data/lib/rspec/core/configuration.rb +114 -125
- data/lib/rspec/core/configuration_options.rb +32 -18
- data/lib/rspec/core/dsl.rb +80 -18
- data/lib/rspec/core/example.rb +84 -33
- data/lib/rspec/core/example_group.rb +95 -43
- data/lib/rspec/core/filter_manager.rb +31 -40
- data/lib/rspec/core/formatters.rb +137 -0
- data/lib/rspec/core/formatters/base_formatter.rb +28 -41
- data/lib/rspec/core/formatters/base_text_formatter.rb +26 -37
- data/lib/rspec/core/formatters/deprecation_formatter.rb +48 -27
- data/lib/rspec/core/formatters/documentation_formatter.rb +27 -22
- data/lib/rspec/core/formatters/html_formatter.rb +48 -56
- data/lib/rspec/core/formatters/html_printer.rb +11 -18
- data/lib/rspec/core/formatters/json_formatter.rb +18 -22
- data/lib/rspec/core/formatters/legacy_formatter.rb +227 -0
- data/lib/rspec/core/formatters/progress_formatter.rb +7 -10
- data/lib/rspec/core/hooks.rb +250 -217
- data/lib/rspec/core/memoized_helpers.rb +43 -9
- data/lib/rspec/core/mocking_adapters/flexmock.rb +29 -0
- data/lib/rspec/core/{mocking/with_mocha.rb → mocking_adapters/mocha.rb} +19 -16
- data/lib/rspec/core/mocking_adapters/null.rb +12 -0
- data/lib/rspec/core/mocking_adapters/rr.rb +28 -0
- data/lib/rspec/core/mocking_adapters/rspec.rb +30 -0
- data/lib/rspec/core/notifications.rb +100 -0
- data/lib/rspec/core/option_parser.rb +11 -18
- data/lib/rspec/core/pending.rb +78 -47
- data/lib/rspec/core/project_initializer.rb +2 -49
- data/lib/rspec/core/project_initializer/dot_rspec +3 -0
- data/lib/rspec/core/project_initializer/spec_helper.rb +82 -0
- data/lib/rspec/core/rake_task.rb +5 -14
- data/lib/rspec/core/reporter.rb +24 -32
- data/lib/rspec/core/ruby_project.rb +1 -1
- data/lib/rspec/core/runner.rb +14 -4
- data/lib/rspec/core/shared_example_group.rb +40 -13
- data/lib/rspec/core/version.rb +1 -1
- data/spec/command_line/order_spec.rb +15 -15
- data/spec/rspec/core/backtrace_formatter_spec.rb +15 -1
- data/spec/rspec/core/command_line_spec.rb +18 -17
- data/spec/rspec/core/configuration_options_spec.rb +57 -34
- data/spec/rspec/core/configuration_spec.rb +162 -184
- data/spec/rspec/core/drb_command_line_spec.rb +5 -7
- data/spec/rspec/core/drb_options_spec.rb +2 -2
- data/spec/rspec/core/dsl_spec.rb +79 -15
- data/spec/rspec/core/example_group_spec.rb +253 -39
- data/spec/rspec/core/example_spec.rb +149 -33
- data/spec/rspec/core/filter_manager_spec.rb +9 -26
- data/spec/rspec/core/formatters/base_formatter_spec.rb +2 -5
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +42 -145
- data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +64 -34
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +15 -28
- data/spec/rspec/core/formatters/helpers_spec.rb +2 -2
- data/spec/rspec/core/formatters/{html_formatted-1.8.7.html → html_formatted-2.1.0.html} +22 -44
- data/spec/rspec/core/formatters/{html_formatted-1.8.7-jruby.html → html_formatted.html} +30 -49
- data/spec/rspec/core/formatters/html_formatter_spec.rb +35 -19
- data/spec/rspec/core/formatters/json_formatter_spec.rb +42 -40
- data/spec/rspec/core/formatters/legacy_formatter_spec.rb +137 -0
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +38 -25
- data/spec/rspec/core/formatters/snippet_extractor_spec.rb +1 -1
- data/spec/rspec/core/formatters_spec.rb +120 -0
- data/spec/rspec/core/hooks_filtering_spec.rb +1 -1
- data/spec/rspec/core/hooks_spec.rb +13 -2
- data/spec/rspec/core/memoized_helpers_spec.rb +17 -8
- data/spec/rspec/core/metadata_spec.rb +3 -3
- data/spec/rspec/core/option_parser_spec.rb +53 -46
- data/spec/rspec/core/ordering_spec.rb +4 -4
- data/spec/rspec/core/pending_example_spec.rb +23 -126
- data/spec/rspec/core/pending_spec.rb +8 -0
- data/spec/rspec/core/project_initializer_spec.rb +8 -41
- data/spec/rspec/core/rake_task_spec.rb +15 -4
- data/spec/rspec/core/random_spec.rb +1 -1
- data/spec/rspec/core/reporter_spec.rb +50 -37
- data/spec/rspec/core/resources/formatter_specs.rb +9 -11
- data/spec/rspec/core/rspec_matchers_spec.rb +1 -1
- data/spec/rspec/core/ruby_project_spec.rb +3 -3
- data/spec/rspec/core/runner_spec.rb +65 -23
- data/spec/rspec/core/shared_context_spec.rb +4 -4
- data/spec/rspec/core/shared_example_group/collection_spec.rb +1 -1
- data/spec/rspec/core/shared_example_group_spec.rb +20 -11
- data/spec/rspec/core/warnings_spec.rb +1 -1
- data/spec/rspec/core/world_spec.rb +10 -10
- data/spec/rspec/core_spec.rb +2 -2
- data/spec/spec_helper.rb +12 -24
- data/spec/support/config_options_helper.rb +1 -3
- data/spec/support/formatter_support.rb +83 -0
- data/spec/support/isolate_load_path_mutation.rb +1 -2
- data/spec/support/isolated_directory.rb +1 -1
- data/spec/support/isolated_home_directory.rb +1 -1
- data/spec/support/legacy_formatter_using_sub_classing_example.rb +87 -0
- data/spec/support/matchers.rb +20 -0
- data/spec/support/mathn_integration_support.rb +2 -2
- data/spec/support/old_style_formatter_example.rb +69 -0
- data/spec/support/shared_example_groups.rb +1 -1
- data/spec/support/spec_files.rb +3 -3
- metadata +192 -69
- metadata.gz.sig +3 -1
- checksums.yaml +0 -15
- checksums.yaml.gz.sig +0 -2
- data/features/configuration/show_failures_in_pending_blocks.feature +0 -61
- data/features/pending/pending_examples.feature +0 -229
- data/features/subject/implicit_receiver.feature +0 -29
- data/lib/rspec/core/mocking/with_absolutely_nothing.rb +0 -11
- data/lib/rspec/core/mocking/with_flexmock.rb +0 -27
- data/lib/rspec/core/mocking/with_rr.rb +0 -27
- data/lib/rspec/core/mocking/with_rspec.rb +0 -27
- data/spec/rspec/core/formatters/html_formatted-1.8.7-rbx.html +0 -477
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +0 -425
- data/spec/rspec/core/formatters/html_formatted-1.9.3-jruby.html +0 -416
- data/spec/rspec/core/formatters/html_formatted-1.9.3-rbx.html +0 -477
- data/spec/rspec/core/formatters/html_formatted-1.9.3.html +0 -419
- data/spec/rspec/core/formatters/html_formatted-2.0.0.html +0 -425
- data/spec/support/in_sub_process.rb +0 -37
- data/spec/support/sandboxed_mock_space.rb +0 -100
data.tar.gz.sig
CHANGED
Binary file
|
data/Changelog.md
CHANGED
@@ -1,3 +1,100 @@
|
|
1
|
+
### 3.0.0.beta2 / 2014-02-17
|
2
|
+
[full changelog](http://github.com/rspec/rspec-core/compare/v3.0.0.beta1...v3.0.0.beta2)
|
3
|
+
|
4
|
+
Breaking Changes for 3.0.0:
|
5
|
+
|
6
|
+
* Make `mock_with` option more strict. Strings are no longer supported
|
7
|
+
(e.g. `mock_with "mocha"`) -- use a symbol instead. Also, unrecognized
|
8
|
+
values will now result in an error rather than falling back to the
|
9
|
+
null mocking adapter. If you want to use the null mocking adapter,
|
10
|
+
use `mock_with :nothing` (as has been documented for a long time).
|
11
|
+
(Myron Marston)
|
12
|
+
* Remove support for overriding RSpec's built-in `:if` and `:unless`
|
13
|
+
filters. (Ashish Dixit)
|
14
|
+
* Custom formatters are now required to call
|
15
|
+
`RSpec::Core::Formatters.register(formatter_class, *notifications)`
|
16
|
+
where `notifications` is the list of events the formatter wishes to
|
17
|
+
be notified about. Notifications are handled by methods matching the
|
18
|
+
names on formatters. This allows us to add or remove notifications
|
19
|
+
without breaking existing formatters. (Jon Rowe)
|
20
|
+
* Change arguments passed to formatters. Rather than passing multiple
|
21
|
+
arguments (which limits are ability to add additional arguments as
|
22
|
+
doing so would break existing formatters), we now pass a notification
|
23
|
+
value object that exposes the same data via attributes. This will
|
24
|
+
allow us to add new bits of data to a notification event without
|
25
|
+
breaking existing formattesr. (Jon Rowe)
|
26
|
+
* Remove support for deprecated `:alias` option for
|
27
|
+
`RSpec.configuration.add_setting`. (Myron Marston)
|
28
|
+
* Remove support for deprecated `RSpec.configuration.requires = [...]`.
|
29
|
+
(Myron Marston)
|
30
|
+
* Remove support for deprecated `--formatter` CLI option. (Myron Marston)
|
31
|
+
* Remove support for deprecated `--configure` CLI option. (Myron Marston)
|
32
|
+
* Remove support for deprecated `RSpec::Core::RakeTask#spec_opts=`.
|
33
|
+
(Myron Marston)
|
34
|
+
* An example group level `pending` block or `:pending` metadata now executes
|
35
|
+
the example and cause a failure if it passes, otherwise it will be pending if
|
36
|
+
it fails. The old "never run" behaviour is still used for `xexample`, `xit`,
|
37
|
+
and `xspecify`, or via a new `skip` method or `:skip` metadata option.
|
38
|
+
(Xavier Shay)
|
39
|
+
* After calling `pending` inside an example, the remainder of the example will
|
40
|
+
now be run. If it passes a failure is raised, otherwise the example is marked
|
41
|
+
pending. The old "never run" behaviour is provided a by a new `skip` method.
|
42
|
+
(Xavier Shay)
|
43
|
+
* Pending blocks inside an example have been removed as a feature with no
|
44
|
+
direct replacement. Use `skip` or `pending` without a block. (Xavier Shay)
|
45
|
+
* Pending statement is no longer allowed in `before(:all)` hooks. Use `skip`
|
46
|
+
instead. (Xavier Shay)
|
47
|
+
* Remove `show_failures_in_pending_blocks` configuration option. (Xavier Shay)
|
48
|
+
* Remove support for specifying the documentation formatter using
|
49
|
+
's', 'n', 'spec' or 'nested'. (Jon Rowe)
|
50
|
+
|
51
|
+
Enhancements:
|
52
|
+
|
53
|
+
* Add `is_expected` for one-liners that read well with the
|
54
|
+
`expect`-based syntax. `is_expected` is simply defined as
|
55
|
+
`expect(subject)` and can be used in an expression like:
|
56
|
+
`it { is_expected.to read_well }`. (Myron Marston)
|
57
|
+
* Add example run time to JSON formatter output. (Karthik Kastury)
|
58
|
+
* Add more suggested settings to the files generated by
|
59
|
+
`rspec --init`. (Myron Marston)
|
60
|
+
* Add `config.alias_example_group_to`, which can be used to define a
|
61
|
+
new method that defines an example group with the provided metadata.
|
62
|
+
(Michi Huber)
|
63
|
+
* Add `xdescribe` and `xcontext` as shortcuts to make an example group
|
64
|
+
pending. (Myron Marston)
|
65
|
+
* Add `fdescribe` and `fcontext` as shortcuts to focus an example group.
|
66
|
+
(Myron Marston)
|
67
|
+
* Don't autorun specs via `#at_exit` by default. `require 'rspec/autorun'`
|
68
|
+
is only needed when running specs via `ruby`, as it always has been.
|
69
|
+
Running specs via `rake` or `rspec` are both unaffected. (Ben Hoskings)
|
70
|
+
* Add `expose_dsl_globally` config option, defaulting to true. When disabled
|
71
|
+
it will remove the monkey patches rspec-core adds to `main` and `Module`
|
72
|
+
(e.g. `describe`, `shared_examples_for`, etc). (Jon Rowe)
|
73
|
+
* Expose RSpec DSL entry point methods (`describe`,
|
74
|
+
`shared_examples_for`, etc) on the `RSpec` constant. Intended for use
|
75
|
+
when `expose_dsl_globally` is set to `false`. (Jon Rowe)
|
76
|
+
* For consistency, expose all example group aliases (including
|
77
|
+
`context`) on the `RSpec` constant. If `expose_dsl_globally` is set to
|
78
|
+
`true`, also expose them on `main` and `Module`. Historically, only `describe`
|
79
|
+
was exposed. (Jon Rowe, Michi Huber)
|
80
|
+
|
81
|
+
Bug Fixes:
|
82
|
+
|
83
|
+
* Fix failure (undefined method `path`) in end-of-run summary
|
84
|
+
when `raise_errors_for_deprecations!` is configured. (Myron Marston)
|
85
|
+
* Issue error when attempting to use -i or --I on command line,
|
86
|
+
too close to -I to be considered short hand for --init. (Jon Rowe)
|
87
|
+
* Prevent adding formatters to an output target if the same
|
88
|
+
formatter has already been added to that output. (Alex Peattie)
|
89
|
+
* Allow a matcher-generated example description to be used when
|
90
|
+
the example is pending. (Myron Marston)
|
91
|
+
* Ensure the configured `failure_exit_code` is used by the rake
|
92
|
+
task when there is a failure. (Jon Rowe)
|
93
|
+
* Restore behaviour whereby system exclusion filters take priority over working
|
94
|
+
directory (was broken in beta1). (Jon Rowe)
|
95
|
+
* Prevent RSpec mangling file names that have substrings containing `line_number`
|
96
|
+
or `default_path`. (Matijs van Zuijlen)
|
97
|
+
|
1
98
|
### 3.0.0.beta1 / 2013-11-07
|
2
99
|
[full changelog](http://github.com/rspec/rspec-core/compare/v2.99.0.beta1...v3.0.0.beta1)
|
3
100
|
|
@@ -62,6 +159,46 @@ Deprecations
|
|
62
159
|
longer has an affect now that the behavior it enabled is always
|
63
160
|
enabled. (Myron Marston)
|
64
161
|
|
162
|
+
### 2.99.0.beta2 / 2014-02-17
|
163
|
+
[full changelog](http://github.com/rspec/rspec-core/compare/v2.99.0.beta1...v2.99.0.beta2)
|
164
|
+
|
165
|
+
Enhancements:
|
166
|
+
|
167
|
+
* Add `is_expected` for one-liners that read well with the
|
168
|
+
`expect`-based syntax. `is_expected` is simply defined as
|
169
|
+
`expect(subject)` and can be used in an expression like:
|
170
|
+
`it { is_expected.to read_well }`. (Myron Marston)
|
171
|
+
* Backport `skip` from RSpec 3, which acts like `pending` did in RSpec 2
|
172
|
+
when not given a block, since the behavior of `pending` is changing in
|
173
|
+
RSpec 3. (Xavier Shay)
|
174
|
+
|
175
|
+
Deprecations:
|
176
|
+
|
177
|
+
* Deprecate inexact `mock_with` config options. RSpec 3 will only support
|
178
|
+
the exact symbols `:rspec`, `:mocha`, `:flexmock`, `:rr` or `:nothing`
|
179
|
+
(or any module that implements the adapter interface). RSpec 2 did
|
180
|
+
fuzzy matching but this will not be supported going forward.
|
181
|
+
(Myron Marston)
|
182
|
+
* Deprecate `show_failures_in_pending_blocks` config option. To achieve
|
183
|
+
the same behavior as the option enabled, you can use a custom
|
184
|
+
formatter instead. (Xavier Shay)
|
185
|
+
* Add a deprecation warning for the fact that the behavior of `pending`
|
186
|
+
is changing in RSpec 3 -- rather than skipping the example (as it did
|
187
|
+
in 2.x when no block was provided), it will run the example and mark
|
188
|
+
it as failed if no exception is raised. Use `skip` instead to preserve
|
189
|
+
the old behavior. (Xavier Shay)
|
190
|
+
* Deprecate 's', 'n', 'spec' and 'nested' as aliases for documentation
|
191
|
+
formatter. (Jon Rowe)
|
192
|
+
* Deprecate `RSpec::Core::Reporter#abort` in favor of
|
193
|
+
`RSpec::Core::Reporter#finish`. (Jon Rowe)
|
194
|
+
|
195
|
+
Bug Fixes:
|
196
|
+
|
197
|
+
* Fix failure (undefined method `path`) in end-of-run summary
|
198
|
+
when `raise_errors_for_deprecations!` is configured. (Myron Marston)
|
199
|
+
* Fix issue were overridding spec ordering from the command line wasnt
|
200
|
+
fully recognised interally. (Jon Rowe)
|
201
|
+
|
65
202
|
### 2.99.0.beta1 / 2013-11-07
|
66
203
|
[full changelog](http://github.com/rspec/rspec-core/compare/v2.14.7...v2.99.0.beta1)
|
67
204
|
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# rspec-core [![Build Status](https://secure.travis-ci.org/rspec/rspec-core.png?branch=master)](http://travis-ci.org/rspec/rspec-core) [![Code Climate](https://codeclimate.com/github/rspec/rspec-core.png)](https://codeclimate.com/github/rspec/rspec-core)
|
1
|
+
# rspec-core [![Build Status](https://secure.travis-ci.org/rspec/rspec-core.png?branch=master)](http://travis-ci.org/rspec/rspec-core) [![Code Climate](https://codeclimate.com/github/rspec/rspec-core.png)](https://codeclimate.com/github/rspec/rspec-core)
|
2
2
|
|
3
3
|
rspec-core provides the structure for writing executable examples of how your
|
4
4
|
code should behave, and an `rspec` command with tools to constrain which
|
@@ -166,7 +166,7 @@ the command line.
|
|
166
166
|
## autotest integration
|
167
167
|
|
168
168
|
rspec-core no longer ships with an Autotest extension, if you require Autotest
|
169
|
-
integration, please use the `rspec-autotest` gem and see [rspec/
|
169
|
+
integration, please use the `rspec-autotest` gem and see [rspec/rspec-autotest](https://github.com/rspec/rspec-autotest)
|
170
170
|
for details
|
171
171
|
|
172
172
|
## get started
|
data/exe/rspec
CHANGED
@@ -1,25 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
rescue LoadError
|
6
|
-
$stderr.puts <<-EOS
|
7
|
-
#{'*'*50}
|
8
|
-
Could not find 'rspec/autorun'
|
9
|
-
|
10
|
-
This may happen if you're using rubygems as your package manager, but it is not
|
11
|
-
being required through some mechanism before executing the rspec command.
|
12
|
-
|
13
|
-
You may need to do one of the following in your shell:
|
14
|
-
|
15
|
-
# for bash/zsh
|
16
|
-
export RUBYOPT=rubygems
|
17
|
-
|
18
|
-
# for csh, etc.
|
19
|
-
set RUBYOPT=rubygems
|
20
|
-
|
21
|
-
For background, please see http://gist.github.com/54177.
|
22
|
-
#{'*'*50}
|
23
|
-
EOS
|
24
|
-
exit(1)
|
25
|
-
end
|
3
|
+
require 'rspec/core'
|
4
|
+
RSpec::Core::Runner.invoke
|
data/features/README.md
CHANGED
@@ -10,8 +10,4 @@ rspec-core provides the structure for RSpec code examples:
|
|
10
10
|
|
11
11
|
## Issues
|
12
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).
|
13
|
+
This documentation is [open source](https://github.com/rspec/rspec-core/tree/master/features), and a work in progress. If you find it incomplete or confusing, please [submit an issue](http://github.com/rspec/rspec-core/issues), or, better yet, [a pull request](http://github.com/rspec/rspec-core).
|
@@ -8,14 +8,9 @@ For a full list of options, run the `rspec` command with the `--help` flag:
|
|
8
8
|
### Run with `ruby`
|
9
9
|
|
10
10
|
Generally, life is simpler if you just use the `rspec` command. If you must use the `ruby`
|
11
|
-
command, however, you'll
|
12
|
-
|
13
|
-
|
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`
|
11
|
+
command, however, you'll need to require `"rspec/autorun"`. You can
|
12
|
+
either pass a `-rrspec/autorun` CLI option when invoking `ruby`, or add
|
13
|
+
a `require 'rspec/autorun'` to one or more of your spec files.
|
19
14
|
|
20
15
|
It is conventional to put configuration in and require assorted support files
|
21
16
|
from `spec/spec_helper.rb`. It is also conventional to require that file from
|
@@ -23,6 +18,8 @@ the spec files using `require 'spec_helper'`. This works because RSpec
|
|
23
18
|
implicitly adds the `spec` directory to the `LOAD_PATH`. It also adds `lib`, so
|
24
19
|
your implementation files will be on the `LOAD_PATH` as well.
|
25
20
|
|
26
|
-
If you're using the `ruby` command, you'll need to do this yourself
|
21
|
+
If you're using the `ruby` command, you'll need to do this yourself
|
22
|
+
(with the `-I` option). Putting these together, your command might be
|
23
|
+
something like this:
|
27
24
|
|
28
|
-
ruby -Ilib -Ispec path/to/spec.rb
|
25
|
+
$ ruby -Ilib -Ispec -rrspec/autorun path/to/spec.rb
|
@@ -1,7 +1,8 @@
|
|
1
1
|
Feature: --init option
|
2
2
|
|
3
3
|
Use the --init option on the command line to generate conventional
|
4
|
-
files for an rspec project.
|
4
|
+
files for an rspec project. It generates a `.rspec` and
|
5
|
+
`spec/spec_helper.rb` with some example settings to get you started.
|
5
6
|
|
6
7
|
Scenario: generate .rspec
|
7
8
|
When I run `rspec --init`
|
@@ -16,3 +17,41 @@ Feature: --init option
|
|
16
17
|
"""
|
17
18
|
When I run `rspec --init`
|
18
19
|
Then the output should contain "exist .rspec"
|
20
|
+
|
21
|
+
Scenario: Accept and use the recommended settings in spec_helper (which are initially commented out).
|
22
|
+
Given I have a brand new project with no files
|
23
|
+
And I have run `rspec --init`
|
24
|
+
When I accept the recommended settings by removing `=begin` and `=end` from `spec/spec_helper.rb`
|
25
|
+
And I create "spec/addition_spec.rb" with the following content:
|
26
|
+
"""ruby
|
27
|
+
RSpec.describe "Addition" do
|
28
|
+
it "works" do
|
29
|
+
expect(1 + 1).to eq(2)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
"""
|
33
|
+
And I create "spec/subtraction_spec.rb" with the following content:
|
34
|
+
"""ruby
|
35
|
+
RSpec.describe "Subtraction" do
|
36
|
+
it "works" do
|
37
|
+
expect(1 - 1).to eq(0)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
"""
|
41
|
+
|
42
|
+
When I run `rspec`
|
43
|
+
Then the examples should all pass
|
44
|
+
And the output should not contain:
|
45
|
+
"""
|
46
|
+
Addition
|
47
|
+
works
|
48
|
+
"""
|
49
|
+
|
50
|
+
When I run `rspec spec/addition_spec.rb`
|
51
|
+
Then the examples should all pass
|
52
|
+
And the output should contain:
|
53
|
+
"""
|
54
|
+
Addition
|
55
|
+
works
|
56
|
+
"""
|
57
|
+
|
@@ -4,15 +4,15 @@ Feature: run with ruby command
|
|
4
4
|
`rspec/autorun`.
|
5
5
|
|
6
6
|
Generally speaking, you're better off using the `rspec` command, which
|
7
|
-
|
8
|
-
command.
|
7
|
+
avoids the complexity of `rspec/autorun` (e.g. no `at_exit` hook needed!),
|
8
|
+
but some tools only work with the `ruby` command.
|
9
9
|
|
10
|
-
Scenario:
|
10
|
+
Scenario: Require `rspec/autorun` from a spec file
|
11
11
|
Given a file named "example_spec.rb" with:
|
12
12
|
"""ruby
|
13
13
|
require 'rspec/autorun'
|
14
14
|
|
15
|
-
describe 1 do
|
15
|
+
RSpec.describe 1 do
|
16
16
|
it "is < 2" do
|
17
17
|
expect(1).to be < 2
|
18
18
|
end
|
@@ -20,3 +20,4 @@ Feature: run with ruby command
|
|
20
20
|
"""
|
21
21
|
When I run `ruby example_spec.rb`
|
22
22
|
Then the output should contain "1 example, 0 failures"
|
23
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
Feature: Global namespace DSL
|
2
|
+
|
3
|
+
RSpec has a few top-level constructs that allow you to begin describing
|
4
|
+
behaviour:
|
5
|
+
|
6
|
+
* `RSpec.describe`: Define a named context for a group of examples.
|
7
|
+
* `RSpec.shared_examples_for`: Define a set of shared examples that can later be included in an example group.
|
8
|
+
* `RSpec.shared_context`: define some common context (using `before`, `let`, helper methods, etc) that can later be included in an example group.
|
9
|
+
|
10
|
+
Historically, these constructs have been available directly off of the main
|
11
|
+
object, so that you could use these at the start of a file without the
|
12
|
+
`RSpec.` prefix. They have also been available off of any class or module so
|
13
|
+
that you can scope your examples within a particular constant namespace.
|
14
|
+
|
15
|
+
RSpec 3 now provides an option to disable this global monkey patching:
|
16
|
+
|
17
|
+
`config.expose_dsl_globally = false`.
|
18
|
+
|
19
|
+
For backwards compatibility it defaults to true.
|
20
|
+
|
21
|
+
Scenario: by default RSpec allows the DSL to be used globally
|
22
|
+
Given a file named "spec/example_spec.rb" with:
|
23
|
+
"""ruby
|
24
|
+
describe "specs here" do
|
25
|
+
it "passes" do
|
26
|
+
end
|
27
|
+
end
|
28
|
+
"""
|
29
|
+
When I run `rspec`
|
30
|
+
Then the output should contain "1 example, 0 failures"
|
31
|
+
|
32
|
+
Scenario: when exposing globally is disabled the top level DSL no longer works
|
33
|
+
Given a file named "spec/example_spec.rb" with:
|
34
|
+
"""ruby
|
35
|
+
RSpec.configure { |c| c.expose_dsl_globally = false }
|
36
|
+
describe "specs here" do
|
37
|
+
it "passes" do
|
38
|
+
end
|
39
|
+
end
|
40
|
+
"""
|
41
|
+
When I run `rspec`
|
42
|
+
Then the output should contain "undefined method `describe'"
|
43
|
+
|
44
|
+
Scenario: regardless of setting
|
45
|
+
Given a file named "spec/example_spec.rb" with:
|
46
|
+
"""ruby
|
47
|
+
RSpec.configure { |c| c.expose_dsl_globally = true }
|
48
|
+
RSpec.describe "specs here" do
|
49
|
+
it "passes" do
|
50
|
+
end
|
51
|
+
end
|
52
|
+
"""
|
53
|
+
When I run `rspec`
|
54
|
+
Then the output should contain "1 example, 0 failures"
|
@@ -0,0 +1,48 @@
|
|
1
|
+
Feature: aliasing
|
2
|
+
|
3
|
+
`describe` and `context` are the default aliases for `example_group`.
|
4
|
+
You can define your own aliases for `example_group` and give those
|
5
|
+
custom aliases default metadata.
|
6
|
+
|
7
|
+
RSpec provides a few built-in aliases:
|
8
|
+
|
9
|
+
* `xdescribe` and `xcontext` add `:pending` metadata to the
|
10
|
+
example group in order to temporarily disable the examples.
|
11
|
+
* `fdescribe` and `fcontext` add `:focus` metadata to the
|
12
|
+
example group in order to make it easy to temporarily
|
13
|
+
focus the example group (when combined with `config.filter_run :focus`.)
|
14
|
+
|
15
|
+
Scenario: custom example group aliases with metadata
|
16
|
+
Given a file named "nested_example_group_aliases_spec.rb" with:
|
17
|
+
"""ruby
|
18
|
+
RSpec.configure do |c|
|
19
|
+
c.alias_example_group_to :detail, :detailed => true
|
20
|
+
end
|
21
|
+
|
22
|
+
RSpec.detail "a detail" do
|
23
|
+
it "can do some less important stuff" do
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
RSpec.describe "a thing" do
|
28
|
+
describe "in broad strokes" do
|
29
|
+
it "can do things" do
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
detail "something less important" do
|
34
|
+
it "can do an unimportant thing" do
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
"""
|
39
|
+
When I run `rspec nested_example_group_aliases_spec.rb --tag detailed -fdoc`
|
40
|
+
Then the output should contain:
|
41
|
+
"""
|
42
|
+
a detail
|
43
|
+
can do some less important stuff
|
44
|
+
|
45
|
+
a thing
|
46
|
+
something less important
|
47
|
+
"""
|
48
|
+
|