rspec-core 3.0.0.beta2 → 3.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.yardopts +1 -0
- data/Changelog.md +297 -57
- data/README.md +16 -13
- data/lib/rspec/core.rb +55 -84
- data/lib/rspec/core/backport_random.rb +35 -3
- data/lib/rspec/core/backtrace_formatter.rb +4 -13
- data/lib/rspec/core/configuration.rb +330 -114
- data/lib/rspec/core/configuration_options.rb +38 -22
- data/lib/rspec/core/drb.rb +111 -0
- data/lib/rspec/core/dsl.rb +8 -2
- data/lib/rspec/core/example.rb +203 -94
- data/lib/rspec/core/example_group.rb +344 -316
- data/lib/rspec/core/filter_manager.rb +135 -90
- data/lib/rspec/core/flat_map.rb +1 -0
- data/lib/rspec/core/formatters.rb +50 -14
- data/lib/rspec/core/formatters/base_formatter.rb +32 -138
- data/lib/rspec/core/formatters/base_text_formatter.rb +32 -253
- data/lib/rspec/core/formatters/console_codes.rb +65 -0
- data/lib/rspec/core/formatters/deprecation_formatter.rb +24 -15
- data/lib/rspec/core/formatters/documentation_formatter.rb +7 -10
- data/lib/rspec/core/formatters/helpers.rb +15 -9
- data/lib/rspec/core/formatters/html_formatter.rb +17 -16
- data/lib/rspec/core/formatters/html_printer.rb +1 -0
- data/lib/rspec/core/formatters/json_formatter.rb +18 -20
- data/lib/rspec/core/formatters/profile_formatter.rb +67 -0
- data/lib/rspec/core/formatters/progress_formatter.rb +6 -7
- data/lib/rspec/core/formatters/snippet_extractor.rb +8 -6
- data/lib/rspec/core/hooks.rb +131 -125
- data/lib/rspec/core/memoized_helpers.rb +31 -26
- data/lib/rspec/core/metadata.rb +277 -184
- data/lib/rspec/core/metadata_filter.rb +86 -0
- data/lib/rspec/core/minitest_assertions_adapter.rb +28 -0
- data/lib/rspec/core/mocking_adapters/flexmock.rb +1 -1
- data/lib/rspec/core/mocking_adapters/mocha.rb +1 -1
- data/lib/rspec/core/mocking_adapters/null.rb +1 -1
- data/lib/rspec/core/mocking_adapters/rr.rb +2 -1
- data/lib/rspec/core/mocking_adapters/rspec.rb +1 -1
- data/lib/rspec/core/notifications.rb +435 -24
- data/lib/rspec/core/option_parser.rb +16 -25
- data/lib/rspec/core/ordering.rb +3 -1
- data/lib/rspec/core/pending.rb +57 -33
- data/lib/rspec/core/project_initializer.rb +2 -0
- data/lib/rspec/core/project_initializer/spec_helper.rb +5 -4
- data/lib/rspec/core/rake_task.rb +45 -20
- data/lib/rspec/core/reporter.rb +50 -22
- data/lib/rspec/core/ruby_project.rb +1 -0
- data/lib/rspec/core/runner.rb +93 -39
- data/lib/rspec/core/shared_context.rb +7 -5
- data/lib/rspec/core/shared_example_group.rb +85 -77
- data/lib/rspec/core/test_unit_assertions_adapter.rb +30 -0
- data/lib/rspec/core/version.rb +3 -1
- data/lib/rspec/core/warnings.rb +35 -17
- data/lib/rspec/core/world.rb +57 -5
- metadata +56 -369
- metadata.gz.sig +3 -3
- data/features/README.md +0 -13
- data/features/Upgrade.md +0 -352
- data/features/command_line/README.md +0 -25
- data/features/command_line/dry_run.feature +0 -29
- data/features/command_line/example_name_option.feature +0 -97
- data/features/command_line/exit_status.feature +0 -82
- data/features/command_line/fail_fast.feature +0 -26
- data/features/command_line/format_option.feature +0 -75
- data/features/command_line/init.feature +0 -57
- data/features/command_line/line_number_appended_to_path.feature +0 -140
- data/features/command_line/line_number_option.feature +0 -58
- data/features/command_line/order.feature +0 -25
- data/features/command_line/pattern_option.feature +0 -49
- data/features/command_line/rake_task.feature +0 -122
- data/features/command_line/randomization.feature +0 -63
- data/features/command_line/require_option.feature +0 -43
- data/features/command_line/ruby.feature +0 -23
- data/features/command_line/tag.feature +0 -98
- data/features/command_line/warnings_option.feature +0 -29
- data/features/configuration/alias_example_to.feature +0 -39
- data/features/configuration/backtrace_exclusion_patterns.feature +0 -105
- data/features/configuration/custom_settings.feature +0 -84
- data/features/configuration/default_path.feature +0 -38
- data/features/configuration/deprecation_stream.feature +0 -58
- data/features/configuration/enable_global_dsl.feature +0 -54
- data/features/configuration/fail_fast.feature +0 -77
- data/features/configuration/failure_exit_code.feature +0 -36
- data/features/configuration/order_and_seed.feature +0 -3
- data/features/configuration/output_stream.feature +0 -24
- data/features/configuration/overriding_global_ordering.feature +0 -93
- data/features/configuration/pattern.feature +0 -38
- data/features/configuration/profile.feature +0 -220
- data/features/configuration/read_options_from_file.feature +0 -90
- data/features/configuration/run_all_when_everything_filtered.feature +0 -76
- data/features/example_groups/aliasing.feature +0 -48
- data/features/example_groups/basic_structure.feature +0 -55
- data/features/example_groups/shared_context.feature +0 -74
- data/features/example_groups/shared_examples.feature +0 -286
- data/features/expectation_framework_integration/configure_expectation_framework.feature +0 -102
- data/features/filtering/exclusion_filters.feature +0 -135
- data/features/filtering/if_and_unless.feature +0 -138
- data/features/filtering/inclusion_filters.feature +0 -101
- data/features/formatters/configurable_colors.feature +0 -31
- data/features/formatters/custom_formatter.feature +0 -68
- data/features/formatters/json_formatter.feature +0 -30
- data/features/formatters/regression_tests.feature +0 -95
- data/features/formatters/text_formatter.feature +0 -46
- data/features/helper_methods/arbitrary_methods.feature +0 -40
- data/features/helper_methods/let.feature +0 -50
- data/features/helper_methods/modules.feature +0 -146
- data/features/hooks/around_hooks.feature +0 -344
- data/features/hooks/before_and_after_hooks.feature +0 -427
- data/features/hooks/filtering.feature +0 -232
- data/features/metadata/current_example.feature +0 -56
- data/features/metadata/described_class.feature +0 -17
- data/features/metadata/user_defined.feature +0 -100
- data/features/mock_framework_integration/use_any_framework.feature +0 -106
- data/features/mock_framework_integration/use_flexmock.feature +0 -94
- data/features/mock_framework_integration/use_mocha.feature +0 -95
- data/features/mock_framework_integration/use_rr.feature +0 -96
- data/features/mock_framework_integration/use_rspec.feature +0 -95
- data/features/pending_and_skipped_examples/README.md +0 -3
- data/features/pending_and_skipped_examples/pending_examples.feature +0 -118
- data/features/pending_and_skipped_examples/skipped_examples.feature +0 -106
- data/features/spec_files/arbitrary_file_suffix.feature +0 -13
- data/features/step_definitions/additional_cli_steps.rb +0 -83
- data/features/subject/explicit_subject.feature +0 -101
- data/features/subject/implicit_subject.feature +0 -63
- data/features/subject/one_liner_syntax.feature +0 -71
- data/features/support/env.rb +0 -21
- data/features/support/require_expect_syntax_in_aruba_specs.rb +0 -16
- data/features/support/rubinius.rb +0 -6
- data/lib/rspec/core/command_line.rb +0 -35
- data/lib/rspec/core/drb_command_line.rb +0 -26
- data/lib/rspec/core/drb_options.rb +0 -87
- data/lib/rspec/core/formatters/legacy_formatter.rb +0 -227
- data/lib/rspec/core/shared_example_group/collection.rb +0 -27
- data/spec/command_line/order_spec.rb +0 -211
- data/spec/rspec/core/backtrace_formatter_spec.rb +0 -230
- data/spec/rspec/core/command_line_spec.rb +0 -112
- data/spec/rspec/core/command_line_spec_output.txt +0 -0
- data/spec/rspec/core/configuration_options_spec.rb +0 -409
- data/spec/rspec/core/configuration_spec.rb +0 -1479
- data/spec/rspec/core/drb_command_line_spec.rb +0 -102
- data/spec/rspec/core/drb_options_spec.rb +0 -193
- data/spec/rspec/core/dsl_spec.rb +0 -88
- data/spec/rspec/core/example_group_spec.rb +0 -1533
- data/spec/rspec/core/example_spec.rb +0 -642
- data/spec/rspec/core/filter_manager_spec.rb +0 -229
- data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -64
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +0 -303
- data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +0 -208
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +0 -75
- data/spec/rspec/core/formatters/helpers_spec.rb +0 -104
- data/spec/rspec/core/formatters/html_formatted-2.1.0.html +0 -392
- data/spec/rspec/core/formatters/html_formatted.html +0 -397
- data/spec/rspec/core/formatters/html_formatter_spec.rb +0 -122
- data/spec/rspec/core/formatters/json_formatter_spec.rb +0 -206
- data/spec/rspec/core/formatters/legacy_formatter_spec.rb +0 -137
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -43
- data/spec/rspec/core/formatters/snippet_extractor_spec.rb +0 -26
- data/spec/rspec/core/formatters_spec.rb +0 -120
- data/spec/rspec/core/hooks_filtering_spec.rb +0 -227
- data/spec/rspec/core/hooks_spec.rb +0 -294
- data/spec/rspec/core/memoized_helpers_spec.rb +0 -495
- data/spec/rspec/core/metadata_spec.rb +0 -491
- data/spec/rspec/core/option_parser_spec.rb +0 -262
- data/spec/rspec/core/ordering_spec.rb +0 -102
- data/spec/rspec/core/pending_example_spec.rb +0 -117
- data/spec/rspec/core/pending_spec.rb +0 -8
- data/spec/rspec/core/project_initializer_spec.rb +0 -73
- data/spec/rspec/core/rake_task_spec.rb +0 -146
- data/spec/rspec/core/random_spec.rb +0 -47
- data/spec/rspec/core/reporter_spec.rb +0 -155
- data/spec/rspec/core/resources/a_bar.rb +0 -0
- data/spec/rspec/core/resources/a_foo.rb +0 -0
- data/spec/rspec/core/resources/a_spec.rb +0 -1
- data/spec/rspec/core/resources/custom_example_group_runner.rb +0 -14
- data/spec/rspec/core/resources/formatter_specs.rb +0 -58
- data/spec/rspec/core/resources/utf8_encoded.rb +0 -8
- data/spec/rspec/core/rspec_matchers_spec.rb +0 -45
- data/spec/rspec/core/ruby_project_spec.rb +0 -26
- data/spec/rspec/core/runner_spec.rb +0 -151
- data/spec/rspec/core/shared_context_spec.rb +0 -102
- data/spec/rspec/core/shared_example_group/collection_spec.rb +0 -57
- data/spec/rspec/core/shared_example_group_spec.rb +0 -114
- data/spec/rspec/core/warnings_spec.rb +0 -29
- data/spec/rspec/core/world_spec.rb +0 -142
- data/spec/rspec/core_spec.rb +0 -91
- data/spec/spec_helper.rb +0 -160
- data/spec/support/config_options_helper.rb +0 -13
- data/spec/support/formatter_support.rb +0 -83
- data/spec/support/helper_methods.rb +0 -26
- data/spec/support/isolate_load_path_mutation.rb +0 -5
- data/spec/support/isolated_directory.rb +0 -10
- data/spec/support/isolated_home_directory.rb +0 -16
- data/spec/support/legacy_formatter_using_sub_classing_example.rb +0 -87
- data/spec/support/matchers.rb +0 -85
- data/spec/support/mathn_integration_support.rb +0 -12
- data/spec/support/old_style_formatter_example.rb +0 -69
- data/spec/support/shared_example_groups.rb +0 -13
- data/spec/support/spec_files.rb +0 -44
- data/spec/support/stderr_splitter.rb +0 -36
metadata.gz.sig
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
}3����mq�@E��Iֆug�����K��-ޘ?Y���Ӿ��D���}���7�=K��o�u+pغ3�Q�w4*Tk�ƫ�P�:q�s��k>^���
|
2
|
+
�1J~��d��C�����(�zd�}F��4��G�l������ Gu�ꗘ
|
3
|
+
�+�I+ǩ�;)��I$]�8��ۙou����#�*���P
|
data/features/README.md
DELETED
@@ -1,13 +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 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).
|
data/features/Upgrade.md
DELETED
@@ -1,352 +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.7 do
|
127
|
-
# ...
|
128
|
-
end
|
129
|
-
it "does something", :unless => RUBY_VERSION == 1.8.7 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. The `spec_files` accessor has been replaced by `pattern`.
|
289
|
-
|
290
|
-
# rspec-1
|
291
|
-
require 'spec/rake/spectask'
|
292
|
-
|
293
|
-
Spec::Rake::SpecTask.new do |t|
|
294
|
-
t.spec_opts = ['--options', "\"spec/spec.opts\""]
|
295
|
-
t.spec_files = FileList['spec/**/*.rb']
|
296
|
-
end
|
297
|
-
|
298
|
-
# rspec-2
|
299
|
-
require 'rspec/core/rake_task'
|
300
|
-
|
301
|
-
RSpec::Core::RakeTask.new do |t|
|
302
|
-
t.rspec_opts = ["-c", "-f progress", "-r ./spec/spec_helper.rb"]
|
303
|
-
t.pattern = 'spec/**/*_spec.rb'
|
304
|
-
end
|
305
|
-
|
306
|
-
### RSpec is the new Spec
|
307
|
-
|
308
|
-
The root namespace (top level module) is now `RSpec` instead of `Spec`, and
|
309
|
-
the root directory under `lib` within all of the `rspec` gems is `rspec` instead of `spec`.
|
310
|
-
|
311
|
-
### Configuration
|
312
|
-
|
313
|
-
Typically in `spec/spec_helper.rb`, configuration is now done like this:
|
314
|
-
|
315
|
-
RSpec.configure do |c|
|
316
|
-
# ....
|
317
|
-
end
|
318
|
-
|
319
|
-
### .rspec
|
320
|
-
|
321
|
-
Command line options can be persisted in a `.rspec` file in a project. You
|
322
|
-
can also store a `.rspec` file in your home directory (`~/.rspec`) with global
|
323
|
-
options. Precedence is:
|
324
|
-
|
325
|
-
command line
|
326
|
-
./.rspec
|
327
|
-
~/.rspec
|
328
|
-
|
329
|
-
### `context` is no longer a top-level method
|
330
|
-
|
331
|
-
We removed `context` from the main object because it was creating conflicts with
|
332
|
-
IRB and some users who had `Context` domain objects. `describe` is still there,
|
333
|
-
so if you want to use `context` at the top level, just alias it:
|
334
|
-
|
335
|
-
alias :context :describe
|
336
|
-
|
337
|
-
Of course, you can still use `context` to declare a nested group:
|
338
|
-
|
339
|
-
describe "something" do
|
340
|
-
context "in some context" do
|
341
|
-
it "does something" do
|
342
|
-
# ...
|
343
|
-
end
|
344
|
-
end
|
345
|
-
end
|
346
|
-
|
347
|
-
### `$KCODE` no longer set implicitly to `'u'`
|
348
|
-
|
349
|
-
In RSpec-1, the runner set `$KCODE` to `'u'`, which impacts, among other
|
350
|
-
things, the behaviour of Regular Expressions when applied to non-ascii
|
351
|
-
characters. This is no longer the case in RSpec-2.
|
352
|
-
|
@@ -1,25 +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 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.
|
14
|
-
|
15
|
-
It is conventional to put configuration in and require assorted support files
|
16
|
-
from `spec/spec_helper.rb`. It is also conventional to require that file from
|
17
|
-
the spec files using `require 'spec_helper'`. This works because RSpec
|
18
|
-
implicitly adds the `spec` directory to the `LOAD_PATH`. It also adds `lib`, so
|
19
|
-
your implementation files will be on the `LOAD_PATH` as well.
|
20
|
-
|
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:
|
24
|
-
|
25
|
-
$ ruby -Ilib -Ispec -rrspec/autorun path/to/spec.rb
|
@@ -1,29 +0,0 @@
|
|
1
|
-
Feature: --dry-run
|
2
|
-
|
3
|
-
Use the `--dry-run` option to have RSpec print your suite's formatter
|
4
|
-
output without running any examples or hooks.
|
5
|
-
|
6
|
-
Scenario: Using --dry-run
|
7
|
-
Given a file named "spec/dry_run_spec.rb" with:
|
8
|
-
"""ruby
|
9
|
-
RSpec.configure do |c|
|
10
|
-
c.before(:suite) { puts "before suite" }
|
11
|
-
c.after(:suite) { puts "after suite" }
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "dry run" do
|
15
|
-
before(:all) { fail }
|
16
|
-
before(:each) { fail }
|
17
|
-
|
18
|
-
it "fails in example" do
|
19
|
-
fail
|
20
|
-
end
|
21
|
-
|
22
|
-
after(:each) { fail }
|
23
|
-
after(:all) { fail }
|
24
|
-
end
|
25
|
-
"""
|
26
|
-
When I run `rspec --dry-run`
|
27
|
-
Then the output should contain "1 example, 0 failures"
|
28
|
-
And the output should not contain "before suite"
|
29
|
-
And the output should not contain "after suite"
|
@@ -1,97 +0,0 @@
|
|
1
|
-
Feature: --example option
|
2
|
-
|
3
|
-
Use the --example (or -e) option to filter examples by name.
|
4
|
-
|
5
|
-
The argument is matched against the full description of the example,
|
6
|
-
which is the concatenation of descriptions of the group (including
|
7
|
-
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
|
-
"""ruby
|
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
|
-
"""ruby
|
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
|
-
"""ruby
|
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
|
-
"""ruby
|
41
|
-
describe Array do
|
42
|
-
describe "#length" do
|
43
|
-
it "is the number of items" do
|
44
|
-
expect(Array.new([1,2,3]).length).to 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 process should succeed even though no examples were run
|
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: all examples in one group
|
71
|
-
When I run `rspec . --example 'first group'`
|
72
|
-
Then the examples should all pass
|
73
|
-
|
74
|
-
Scenario: one match in one file with group name
|
75
|
-
When I run `rspec . --example 'second group first example'`
|
76
|
-
Then the examples should all pass
|
77
|
-
|
78
|
-
Scenario: all examples in one group including examples in nested groups
|
79
|
-
When I run `rspec . --example 'third group'`
|
80
|
-
Then the examples should all pass
|
81
|
-
|
82
|
-
Scenario: Object#method
|
83
|
-
When I run `rspec . --example 'Array#length'`
|
84
|
-
Then the examples should all pass
|
85
|
-
|
86
|
-
Scenario: Multiple applications of example name option
|
87
|
-
When I run `rspec . --example 'first group' --example 'second group' --format d`
|
88
|
-
Then the examples should all pass
|
89
|
-
And the output should contain all of these:
|
90
|
-
|first example in first group|
|
91
|
-
|second example in first group|
|
92
|
-
|first example in second group|
|
93
|
-
|second example in second group|
|
94
|
-
And the output should not contain any of these:
|
95
|
-
|first example in third group|
|
96
|
-
|nested group first example in nested group|
|
97
|
-
|nested group second example in nested group|
|