rspec-core 2.5.1 → 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.
- data/.travis.yml +7 -0
- data/Gemfile +12 -14
- data/README.md +4 -1
- data/Rakefile +29 -12
- data/cucumber.yml +1 -1
- data/features/.nav +15 -9
- data/features/Autotest.md +31 -7
- data/features/Changelog.md +46 -3
- data/features/Upgrade.md +35 -2
- data/features/command_line/README.md +22 -0
- data/features/command_line/configure.feature +2 -2
- data/features/command_line/example_name_option.feature +10 -10
- data/features/command_line/exit_status.feature +4 -4
- data/features/command_line/format_option.feature +4 -4
- data/features/command_line/line_number_appended_to_path.feature +11 -11
- data/features/command_line/line_number_option.feature +2 -2
- data/features/command_line/rake_task.feature +3 -3
- data/features/command_line/tag.feature +30 -14
- data/features/configuration/alias_example_to.feature +48 -0
- data/features/configuration/custom_settings.feature +3 -3
- data/features/configuration/fail_fast.feature +3 -3
- data/features/configuration/read_options_from_file.feature +4 -4
- data/features/example_groups/basic_structure.feature +11 -15
- data/features/example_groups/shared_context.feature +74 -0
- data/features/example_groups/shared_example_group.feature +21 -17
- data/features/expectation_framework_integration/configure_expectation_framework.feature +15 -4
- data/features/filtering/exclusion_filters.feature +28 -4
- data/features/filtering/{implicit_filters.feature → if_and_unless.feature} +9 -7
- data/features/filtering/inclusion_filters.feature +26 -3
- data/features/filtering/run_all_when_everything_filtered.feature +2 -2
- data/features/formatters/custom_formatter.feature +1 -1
- data/features/formatters/text_formatter.feature +43 -0
- data/features/helper_methods/arbitrary_methods.feature +2 -2
- data/features/helper_methods/let.feature +2 -2
- data/features/helper_methods/modules.feature +149 -0
- data/features/hooks/around_hooks.feature +18 -11
- data/features/hooks/before_and_after_hooks.feature +15 -19
- data/features/hooks/filtering.feature +160 -124
- data/features/metadata/current_example.feature +17 -0
- data/features/metadata/described_class.feature +2 -2
- data/features/metadata/user_defined.feature +111 -0
- data/features/mock_framework_integration/use_any_framework.feature +1 -1
- data/features/mock_framework_integration/use_flexmock.feature +83 -10
- data/features/mock_framework_integration/use_mocha.feature +84 -10
- data/features/mock_framework_integration/use_rr.feature +85 -10
- data/features/mock_framework_integration/use_rspec.feature +84 -10
- data/features/pending/pending_examples.feature +8 -8
- data/features/spec_files/arbitrary_file_suffix.feature +1 -1
- data/features/step_definitions/additional_cli_steps.rb +11 -1
- data/features/subject/attribute_of_subject.feature +24 -4
- data/features/subject/explicit_subject.feature +5 -5
- data/features/subject/implicit_receiver.feature +2 -2
- data/features/subject/implicit_subject.feature +2 -2
- data/features/support/env.rb +6 -1
- data/lib/rspec/core/backward_compatibility.rb +12 -2
- data/lib/rspec/core/command_line.rb +2 -5
- data/lib/rspec/core/configuration.rb +70 -38
- data/lib/rspec/core/configuration_options.rb +6 -23
- data/lib/rspec/core/drb_command_line.rb +5 -11
- data/lib/rspec/core/example.rb +29 -21
- data/lib/rspec/core/example_group.rb +40 -8
- data/lib/rspec/core/extensions/object.rb +0 -1
- data/lib/rspec/core/formatters/base_formatter.rb +6 -0
- data/lib/rspec/core/formatters/base_text_formatter.rb +1 -1
- data/lib/rspec/core/formatters/helpers.rb +0 -4
- data/lib/rspec/core/hooks.rb +14 -4
- data/lib/rspec/core/metadata.rb +1 -1
- data/lib/rspec/core/metadata_hash_builder.rb +93 -0
- data/lib/rspec/core/mocking/with_flexmock.rb +2 -0
- data/lib/rspec/core/mocking/with_mocha.rb +2 -0
- data/lib/rspec/core/mocking/with_rr.rb +2 -0
- data/lib/rspec/core/mocking/with_rspec.rb +3 -1
- data/lib/rspec/core/option_parser.rb +9 -2
- data/lib/rspec/core/pending.rb +10 -3
- data/lib/rspec/core/reporter.rb +2 -2
- data/lib/rspec/core/runner.rb +38 -13
- data/lib/rspec/core/shared_example_group.rb +18 -4
- data/lib/rspec/core/subject.rb +4 -6
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +70 -18
- data/lib/rspec/core.rb +29 -0
- data/lib/rspec/monkey/spork/test_framework/rspec.rb +1 -0
- data/rspec-core.gemspec +3 -5
- data/spec/autotest/failed_results_re_spec.rb +2 -2
- data/spec/rspec/core/command_line_spec.rb +36 -2
- data/spec/rspec/core/configuration_spec.rb +150 -70
- data/spec/rspec/core/deprecations_spec.rb +21 -0
- data/spec/rspec/core/drb_command_line_spec.rb +21 -56
- data/spec/rspec/core/example_group_spec.rb +213 -56
- data/spec/rspec/core/example_spec.rb +110 -0
- data/spec/rspec/core/formatters/base_formatter_spec.rb +23 -2
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +9 -0
- data/spec/rspec/core/formatters/helpers_spec.rb +1 -1
- data/spec/rspec/core/formatters/html_formatted-1.8.6.html +5 -5
- data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +8 -10
- data/spec/rspec/core/formatters/html_formatted-1.8.7.html +5 -5
- data/spec/rspec/core/formatters/html_formatted-1.9.1.html +5 -5
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +5 -5
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -1
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +5 -5
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +8 -10
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +5 -5
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.1.html +5 -5
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +5 -5
- data/spec/rspec/core/hooks_spec.rb +86 -0
- data/spec/rspec/core/metadata_spec.rb +7 -7
- data/spec/rspec/core/option_parser_spec.rb +26 -15
- data/spec/rspec/core/pending_example_spec.rb +12 -51
- data/spec/rspec/core/reporter_spec.rb +19 -3
- data/spec/rspec/core/resources/formatter_specs.rb +7 -1
- data/spec/rspec/core/rspec_matchers_spec.rb +45 -0
- data/spec/rspec/core/runner_spec.rb +42 -10
- data/spec/rspec/core/shared_example_group_spec.rb +57 -21
- data/spec/rspec/core/subject_spec.rb +32 -11
- data/spec/rspec/core/world_spec.rb +147 -15
- data/spec/rspec/core_spec.rb +28 -0
- data/spec/spec_helper.rb +22 -2
- data/spec/support/matchers.rb +44 -13
- data/spec/support/shared_example_groups.rb +41 -0
- data/spec/support/spec_files.rb +44 -0
- data/spec.txt +1126 -0
- metadata +35 -16
- data/spec/ruby_forker.rb +0 -13
data/.travis.yml
ADDED
data/Gemfile
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
source "http://rubygems.org"
|
|
2
2
|
|
|
3
3
|
### rspec libs
|
|
4
|
-
%w[rspec-core rspec-expectations rspec-mocks].each do |lib|
|
|
4
|
+
%w[rspec rspec-core rspec-expectations rspec-mocks].each do |lib|
|
|
5
5
|
library_path = File.expand_path("../../#{lib}", __FILE__)
|
|
6
6
|
if File.exist?(library_path)
|
|
7
7
|
gem lib, :path => library_path
|
|
8
8
|
else
|
|
9
|
-
gem lib
|
|
9
|
+
gem lib, :git => "git://github.com/rspec/#{lib}.git"
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
+
|
|
13
14
|
### dev dependencies
|
|
14
15
|
gem "rake", "0.8.7"
|
|
15
|
-
gem "cucumber", "0.
|
|
16
|
-
gem "aruba", "0.
|
|
16
|
+
gem "cucumber", "~> 0.10.2"
|
|
17
|
+
gem "aruba", "~> 0.3.6"
|
|
17
18
|
gem "rcov", "0.9.9", :platforms => :mri
|
|
18
19
|
gem "relish", "0.2.0"
|
|
19
20
|
gem "guard-rspec", "0.1.9"
|
|
@@ -21,17 +22,14 @@ gem "growl", "1.0.3"
|
|
|
21
22
|
gem "ZenTest", "~> 4.4.2"
|
|
22
23
|
gem "nokogiri", "1.4.4"
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
gem
|
|
26
|
-
gem "autotest-growl", "~> 0.2.9"
|
|
25
|
+
platforms :mri_18 do
|
|
26
|
+
gem 'ruby-debug'
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
gem
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
when '1.9.1'; gem 'ruby-debug-base19', '0.11.23'
|
|
34
|
-
when '1.9.2'; gem 'ruby-debug-base19', '0.11.24'
|
|
29
|
+
platforms :mri_19 do
|
|
30
|
+
gem 'linecache19', '0.5.11' # 0.5.12 cannot install on 1.9.1, and 0.5.11 appears to work with both 1.9.1 & 1.9.2
|
|
31
|
+
gem 'ruby-debug19'
|
|
32
|
+
gem 'ruby-debug-base19', RUBY_VERSION == '1.9.1' ? '0.11.23' : '~> 0.11.24'
|
|
35
33
|
end
|
|
36
34
|
|
|
37
35
|
platforms :mri_18, :mri_19 do
|
|
@@ -46,7 +44,7 @@ end
|
|
|
46
44
|
### rspec-core only
|
|
47
45
|
gem "mocha", "~> 0.9.10"
|
|
48
46
|
gem "rr", "~> 1.0.2"
|
|
49
|
-
gem "flexmock", "
|
|
47
|
+
gem "flexmock", "0.8.8"
|
|
50
48
|
|
|
51
49
|
### optional runtime deps
|
|
52
50
|
gem "syntax", "1.0.0"
|
data/README.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# RSpec Core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
RSpec Core provides the structure for writing executable examples of how your
|
|
4
|
+
code should behave.
|
|
5
|
+
|
|
6
|
+
[](http://travis-ci.org/rspec/rspec-core)
|
|
4
7
|
|
|
5
8
|
## Documentation
|
|
6
9
|
|
data/Rakefile
CHANGED
|
@@ -8,13 +8,25 @@ require "yaml"
|
|
|
8
8
|
require "rake/rdoctask"
|
|
9
9
|
require "rspec/core/rake_task"
|
|
10
10
|
require "rspec/core/version"
|
|
11
|
-
require "cucumber/rake/task"
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
cucumber_loaded = false
|
|
13
|
+
begin
|
|
14
|
+
require "cucumber/rake/task"
|
|
15
|
+
|
|
16
|
+
Cucumber::Rake::Task.new(:cucumber)
|
|
17
|
+
|
|
18
|
+
class Cucumber::Rake::Task::ForkedCucumberRunner
|
|
19
|
+
# When cucumber shells out, we still need it to run in the context of our
|
|
20
|
+
# bundle.
|
|
21
|
+
def run
|
|
22
|
+
sh "bundle exec #{RUBY} " + args.join(" ")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
cucumber_loaded = true
|
|
26
|
+
rescue LoadError => e
|
|
27
|
+
puts "unable to load cucumber, some tasks unavailable"
|
|
28
|
+
task :cucumber do
|
|
29
|
+
# no-op
|
|
18
30
|
end
|
|
19
31
|
end
|
|
20
32
|
|
|
@@ -25,7 +37,6 @@ RSpec::Core::RakeTask.new(:spec) do |t|
|
|
|
25
37
|
t.verbose = false
|
|
26
38
|
end
|
|
27
39
|
|
|
28
|
-
Cucumber::Rake::Task.new(:cucumber)
|
|
29
40
|
|
|
30
41
|
namespace :rcov do
|
|
31
42
|
task :cleanup do
|
|
@@ -38,11 +49,17 @@ namespace :rcov do
|
|
|
38
49
|
t.rcov_opts << %[--no-html --aggregate coverage.data]
|
|
39
50
|
end
|
|
40
51
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
52
|
+
if cucumber_loaded
|
|
53
|
+
Cucumber::Rake::Task.new :cucumber do |t|
|
|
54
|
+
t.cucumber_opts = %w{--format progress}
|
|
55
|
+
t.rcov = true
|
|
56
|
+
t.rcov_opts = %[-Ilib -Ispec --exclude "gems/*,features"]
|
|
57
|
+
t.rcov_opts << %[--text-report --sort coverage --aggregate coverage.data]
|
|
58
|
+
end
|
|
59
|
+
else
|
|
60
|
+
task :cucumber do
|
|
61
|
+
# no-op
|
|
62
|
+
end
|
|
46
63
|
end
|
|
47
64
|
|
|
48
65
|
end
|
data/cucumber.yml
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
default: --require features --strict --format progress --tags ~@wip features
|
|
1
|
+
default: --require features --strict --format progress --tags ~@wip<%= RUBY_PLATFORM == 'java' ? ' --tags ~@no-jruby' : '' %> features
|
|
2
2
|
wip: --require features --tags @wip:3 --wip features
|
data/features/.nav
CHANGED
|
@@ -4,6 +4,16 @@
|
|
|
4
4
|
- example_groups:
|
|
5
5
|
- basic_structure.feature
|
|
6
6
|
- shared_example_group.feature
|
|
7
|
+
- shared_context.feature
|
|
8
|
+
- command_line:
|
|
9
|
+
- configure.feature
|
|
10
|
+
- example_name_option.feature
|
|
11
|
+
- format_option.feature
|
|
12
|
+
- line_number_option.feature
|
|
13
|
+
- tag.feature
|
|
14
|
+
- line_number_appended_to_path.feature
|
|
15
|
+
- exit_status.feature
|
|
16
|
+
- rake_task.feature
|
|
7
17
|
- pending:
|
|
8
18
|
- pending_examples.feature
|
|
9
19
|
- hooks:
|
|
@@ -18,25 +28,21 @@
|
|
|
18
28
|
- helper_methods:
|
|
19
29
|
- let.feature
|
|
20
30
|
- arbitrary_methods.feature
|
|
31
|
+
- modules.feature
|
|
21
32
|
- metadata:
|
|
33
|
+
- current_example.feature
|
|
22
34
|
- described_class.feature
|
|
35
|
+
- user_defined.feature
|
|
23
36
|
- filtering:
|
|
24
37
|
- inclusion_filters.feature
|
|
25
38
|
- exclusion_filters.feature
|
|
26
|
-
-
|
|
39
|
+
- if_and_unless.feature
|
|
27
40
|
- run_all_when_everything_filtered.feature
|
|
28
|
-
- command_line:
|
|
29
|
-
- configure.feature
|
|
30
|
-
- example_name_option.feature
|
|
31
|
-
- exit_status.feature
|
|
32
|
-
- line_number_appended_to_path.feature
|
|
33
|
-
- line_number_option.feature
|
|
34
|
-
- rake_task.feature
|
|
35
|
-
- tag.feature
|
|
36
41
|
- configuration:
|
|
37
42
|
- read_options_from_file.feature
|
|
38
43
|
- fail_fast.feature
|
|
39
44
|
- custom_settings.feature
|
|
45
|
+
- alias_example_to.feature
|
|
40
46
|
- expectation_framework_integration:
|
|
41
47
|
- configure_expectation_framework.feature
|
|
42
48
|
- mock_framework_integration:
|
data/features/Autotest.md
CHANGED
|
@@ -1,14 +1,38 @@
|
|
|
1
|
-
RSpec ships with a specialized subclass of Autotest. To
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
RSpec ships with a specialized subclass of Autotest. To use it, just add a
|
|
2
|
+
`.rspec` file to your project's root directory, and run the `autotest` command
|
|
3
|
+
as normal:
|
|
4
4
|
|
|
5
5
|
$ autotest
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Bundler
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
The `autotest` command generates a shell command that runs your specs. If you
|
|
10
|
+
are using Bundler, and you want the shell command to include `bundle exec`,
|
|
11
|
+
require the Autotest bundler plugin in a `.autotest` file in the project's root
|
|
12
|
+
directory or your home directory:
|
|
12
13
|
|
|
13
14
|
# in .autotest
|
|
14
15
|
require "autotest/bundler"
|
|
16
|
+
|
|
17
|
+
## Upgrading from previous versions of rspec
|
|
18
|
+
|
|
19
|
+
Previous versions of RSpec used a different mechanism for telling autotest to
|
|
20
|
+
invoke RSpec's Autotest extension: it generated an `autotest/discover.rb` file
|
|
21
|
+
in the project's root directory. This is no longer necessary with the new
|
|
22
|
+
approach of RSpec looking for a `.rspec` file, so feel free to delete the
|
|
23
|
+
`autotest/discover.rb` file in the project root if you have one.
|
|
24
|
+
|
|
25
|
+
## Gotchas
|
|
26
|
+
|
|
27
|
+
### Invalid Option: --tty
|
|
28
|
+
|
|
29
|
+
The `--tty` option was [added in rspec-core-2.2.1](changelog), and is used
|
|
30
|
+
internally by RSpec. If you see an error citing it as an invalid option, you'll
|
|
31
|
+
probably see there are two or more versions of rspec-core in the backtrace: one
|
|
32
|
+
< 2.2.1 and one >= 2.2.1.
|
|
33
|
+
|
|
34
|
+
This usually happens because you have a newer rspec-core installed, and an
|
|
35
|
+
older rspec-core specified in a Bundler Gemfile. If this is the case, you can:
|
|
36
|
+
|
|
37
|
+
1. specify the newer version in the Gemfile (recommended)
|
|
38
|
+
2. prefix the `autotest` command with `bundle exec`
|
data/features/Changelog.md
CHANGED
|
@@ -1,4 +1,47 @@
|
|
|
1
|
-
### 2.
|
|
1
|
+
### 2.6.0 / 2011-05-12
|
|
2
|
+
|
|
3
|
+
[full changelog](http://github.com/rspec/rspec-core/compare/v2.5.1...v2.6.0)
|
|
4
|
+
|
|
5
|
+
* Enhancements
|
|
6
|
+
* `shared_context` (Damian Nurzynski)
|
|
7
|
+
* extend groups matching specific metadata with:
|
|
8
|
+
* method definitions
|
|
9
|
+
* subject declarations
|
|
10
|
+
* let/let! declarations
|
|
11
|
+
* etc (anything you can do in a group)
|
|
12
|
+
* `its([:key])` works for any subject with #[]. (Peter Jaros)
|
|
13
|
+
* `treat_symbols_as_metadata_keys_with_true_values` (Myron Marston)
|
|
14
|
+
* Print a deprecation warning when you configure RSpec after defining
|
|
15
|
+
an example. All configuration should happen before any examples are
|
|
16
|
+
defined. (Myron Marston)
|
|
17
|
+
* Pass the exit status of a DRb run to the invoking process. This causes
|
|
18
|
+
specs run via DRb to not just return true or false. (Ilkka Laukkanen)
|
|
19
|
+
* Refactoring of `ConfigurationOptions#parse_options` (Rodrigo Rosenfeld Rosas)
|
|
20
|
+
* Report excluded filters in runner output (tip from andyl)
|
|
21
|
+
* Clean up messages for filters/tags.
|
|
22
|
+
* Restore --pattern/-P command line option from rspec-1
|
|
23
|
+
* Support false as well as true in config.full_backtrace= (Andreas Tolf Tolfsen)
|
|
24
|
+
|
|
25
|
+
* Bug fixes
|
|
26
|
+
* Don't stumble over an exception without a message (Hans Hasselberg)
|
|
27
|
+
* Remove non-ascii characters from comments that were choking rcov (Geoffrey
|
|
28
|
+
Byers)
|
|
29
|
+
* Fixed backtrace so it doesn't include lines from before the autorun at_exit
|
|
30
|
+
hook (Myron Marston)
|
|
31
|
+
* Include RSpec::Matchers when first example group is defined, rather
|
|
32
|
+
than just before running the examples. This works around an obscure
|
|
33
|
+
bug in ruby 1.9 that can cause infinite recursion. (Myron Marston)
|
|
34
|
+
* Don't send `example_group_[started|finished]` to formatters for empty groups.
|
|
35
|
+
* Get specs passing on jruby (Sidu Ponnappa)
|
|
36
|
+
* Fix bug where mixing nested groups and outer-level examples gave
|
|
37
|
+
unpredictable :line_number behavior (Artur Małecki)
|
|
38
|
+
* Regexp.escape the argument to --example (tip from Elliot Winkler)
|
|
39
|
+
* Correctly pass/fail pending block with message expectations
|
|
40
|
+
* CommandLine returns exit status (0/1) instead of true/false
|
|
41
|
+
* Create path to formatter output file if it doesn't exist (marekj).
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### 2.5.1 / 2011-02-06
|
|
2
45
|
|
|
3
46
|
[full changelog](http://github.com/rspec/rspec-core/compare/v2.5.0...v2.5.1)
|
|
4
47
|
|
|
@@ -68,7 +111,7 @@ If you don't want 'bundle exec', there is nothing you have to do.
|
|
|
68
111
|
|
|
69
112
|
* Bug fixes
|
|
70
113
|
* send debugger warning message to $stdout if RSpec.configuration.error_stream
|
|
71
|
-
has not been defined yet.
|
|
114
|
+
has not been defined yet.
|
|
72
115
|
* HTML Formatter _finally_ properly displays nested groups (Jarmo Pertman)
|
|
73
116
|
* eliminate some warnings when running RSpec's own suite (Jarmo Pertman)
|
|
74
117
|
|
|
@@ -96,7 +139,7 @@ If you don't want 'bundle exec', there is nothing you have to do.
|
|
|
96
139
|
|
|
97
140
|
* Bug fixes
|
|
98
141
|
* alias_method instead of override Kernel#method_missing (John Wilger)
|
|
99
|
-
* changed --autotest to --tty in generated command (MIKAMI Yoshiyuki)
|
|
142
|
+
* changed --autotest to --tty in generated command (MIKAMI Yoshiyuki)
|
|
100
143
|
* revert change to debugger (had introduced conflict with Rails)
|
|
101
144
|
* also restored --debugger/-debug option
|
|
102
145
|
|
data/features/Upgrade.md
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
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
|
+
|
|
1
34
|
# rspec-core-2.3
|
|
2
35
|
|
|
3
36
|
## `config.expect_with`
|
|
@@ -106,7 +139,7 @@ The most obvious use is for filtering the run. For example:
|
|
|
106
139
|
end
|
|
107
140
|
|
|
108
141
|
When you run the `rspec` command, rspec will run only the examples that have
|
|
109
|
-
`:focus => true` in the hash.
|
|
142
|
+
`:focus => true` in the hash.
|
|
110
143
|
|
|
111
144
|
You can also add `run_all_when_everything_filtered` to the config:
|
|
112
145
|
|
|
@@ -207,7 +240,7 @@ A few things changed in the Rake task used to run specs:
|
|
|
207
240
|
the `rspec` command no longer supports the `--options` command line option
|
|
208
241
|
so the options must be embedded directly in the Rakefile, or stored in the
|
|
209
242
|
`.rspec` files mentioned above.
|
|
210
|
-
|
|
243
|
+
|
|
211
244
|
3. In RSpec-1, the rake task would read in rcov options from an `rcov.opts`
|
|
212
245
|
file. This is ignored by RSpec-2. RCov options are now set directly on the Rake
|
|
213
246
|
task:
|
|
@@ -4,3 +4,25 @@ behavior, including output formats, filtering examples, etc.
|
|
|
4
4
|
For a full list of options, run the `rspec` command with the `--help` flag:
|
|
5
5
|
|
|
6
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
|
|
@@ -8,7 +8,7 @@ Feature: --configure option
|
|
|
8
8
|
to load RSpec's Autotest subclass.
|
|
9
9
|
|
|
10
10
|
Scenario: generate .rspec file for autotest
|
|
11
|
-
When I run
|
|
11
|
+
When I run `rspec --configure autotest`
|
|
12
12
|
Then the following files should exist:
|
|
13
13
|
| .rspec |
|
|
14
14
|
And the output should contain ".rspec file did not exist, so it was created."
|
|
@@ -18,5 +18,5 @@ Feature: --configure option
|
|
|
18
18
|
"""
|
|
19
19
|
--color
|
|
20
20
|
"""
|
|
21
|
-
When I run
|
|
21
|
+
When I run `rspec --configure autotest`
|
|
22
22
|
Then the output should contain ".rspec file already exists, so nothing was changed."
|
|
@@ -46,41 +46,41 @@ Feature: --example option
|
|
|
46
46
|
"""
|
|
47
47
|
|
|
48
48
|
Scenario: no matches
|
|
49
|
-
When I run
|
|
49
|
+
When I run `rspec . --example nothing_like_this`
|
|
50
50
|
Then the examples should all pass
|
|
51
51
|
|
|
52
52
|
Scenario: match on one word
|
|
53
|
-
When I run
|
|
53
|
+
When I run `rspec . --example example`
|
|
54
54
|
Then the examples should all pass
|
|
55
55
|
|
|
56
56
|
Scenario: one match in each context
|
|
57
|
-
When I run
|
|
57
|
+
When I run `rspec . --example 'first example'`
|
|
58
58
|
Then the examples should all pass
|
|
59
59
|
|
|
60
60
|
Scenario: one match in one file using just the example name
|
|
61
|
-
When I run
|
|
61
|
+
When I run `rspec . --example 'first example in first group'`
|
|
62
62
|
Then the examples should all pass
|
|
63
63
|
|
|
64
64
|
Scenario: one match in one file using the example name and the group name
|
|
65
|
-
When I run
|
|
65
|
+
When I run `rspec . --example 'first group first example in first group'`
|
|
66
66
|
Then the examples should all pass
|
|
67
67
|
|
|
68
68
|
Scenario: one match in one file using regexp
|
|
69
|
-
When I run
|
|
69
|
+
When I run `rspec . --example 'first .* first example'`
|
|
70
70
|
Then the examples should all pass
|
|
71
71
|
|
|
72
72
|
Scenario: all examples in one group
|
|
73
|
-
When I run
|
|
73
|
+
When I run `rspec . --example 'first group'`
|
|
74
74
|
Then the examples should all pass
|
|
75
75
|
|
|
76
76
|
Scenario: one match in one file with group name
|
|
77
|
-
When I run
|
|
77
|
+
When I run `rspec . --example 'second group first example'`
|
|
78
78
|
Then the examples should all pass
|
|
79
79
|
|
|
80
80
|
Scenario: all examples in one group including examples in nested groups
|
|
81
|
-
When I run
|
|
81
|
+
When I run `rspec . --example 'third group'`
|
|
82
82
|
Then the examples should all pass
|
|
83
83
|
|
|
84
84
|
Scenario: Object#method
|
|
85
|
-
When I run
|
|
85
|
+
When I run `rspec . --example 'Array#length'`
|
|
86
86
|
Then the examples should all pass
|
|
@@ -11,7 +11,7 @@ Feature: exit status
|
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
"""
|
|
14
|
-
When I run
|
|
14
|
+
When I run `rspec ok_spec.rb`
|
|
15
15
|
Then the exit status should be 0
|
|
16
16
|
And the examples should all pass
|
|
17
17
|
|
|
@@ -24,7 +24,7 @@ Feature: exit status
|
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
"""
|
|
27
|
-
When I run
|
|
27
|
+
When I run `rspec ko_spec.rb`
|
|
28
28
|
Then the exit status should be 1
|
|
29
29
|
And the output should contain "1 example, 1 failure"
|
|
30
30
|
|
|
@@ -39,7 +39,7 @@ Feature: exit status
|
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
"""
|
|
42
|
-
When I run
|
|
42
|
+
When I run `rspec nested_ko_spec.rb`
|
|
43
43
|
Then the exit status should be 1
|
|
44
44
|
And the output should contain "1 example, 1 failure"
|
|
45
45
|
|
|
@@ -47,6 +47,6 @@ Feature: exit status
|
|
|
47
47
|
Given a file named "a_no_examples_spec.rb" with:
|
|
48
48
|
"""
|
|
49
49
|
"""
|
|
50
|
-
When I run
|
|
50
|
+
When I run `rspec a_no_examples_spec.rb`
|
|
51
51
|
Then the exit status should be 0
|
|
52
52
|
And the output should contain "0 examples"
|
|
@@ -38,11 +38,11 @@ Feature: --format option
|
|
|
38
38
|
"""
|
|
39
39
|
|
|
40
40
|
Scenario: progress bar format (default)
|
|
41
|
-
When I run
|
|
41
|
+
When I run `rspec example_spec.rb`
|
|
42
42
|
Then the output should contain ".F*"
|
|
43
43
|
|
|
44
44
|
Scenario: documentation format
|
|
45
|
-
When I run
|
|
45
|
+
When I run `rspec example_spec.rb --format documentation`
|
|
46
46
|
Then the output should contain:
|
|
47
47
|
"""
|
|
48
48
|
something
|
|
@@ -52,7 +52,7 @@ Feature: --format option
|
|
|
52
52
|
"""
|
|
53
53
|
|
|
54
54
|
Scenario: documentation format saved to a file
|
|
55
|
-
When I run
|
|
55
|
+
When I run `rspec example_spec.rb --format documentation --out rspec.txt`
|
|
56
56
|
Then the file "rspec.txt" should contain:
|
|
57
57
|
"""
|
|
58
58
|
something
|
|
@@ -62,7 +62,7 @@ Feature: --format option
|
|
|
62
62
|
"""
|
|
63
63
|
|
|
64
64
|
Scenario: multiple formats
|
|
65
|
-
When I run
|
|
65
|
+
When I run `rspec example_spec.rb --format progress --format documentation --out rspec.txt`
|
|
66
66
|
Then the output should contain ".F*"
|
|
67
67
|
And the file "rspec.txt" should contain:
|
|
68
68
|
"""
|
|
@@ -29,77 +29,77 @@ Feature: line number appended to file path
|
|
|
29
29
|
"""
|
|
30
30
|
|
|
31
31
|
Scenario: nested groups - outer group on declaration line
|
|
32
|
-
When I run
|
|
32
|
+
When I run `rspec example_spec.rb:1 --format doc`
|
|
33
33
|
Then the examples should all pass
|
|
34
34
|
And the output should contain "second example in outer group"
|
|
35
35
|
And the output should contain "first example in outer group"
|
|
36
36
|
And the output should contain "example in nested group"
|
|
37
37
|
|
|
38
38
|
Scenario: nested groups - outer group inside block before example
|
|
39
|
-
When I run
|
|
39
|
+
When I run `rspec example_spec.rb:2 --format doc`
|
|
40
40
|
Then the examples should all pass
|
|
41
41
|
And the output should contain "second example in outer group"
|
|
42
42
|
And the output should contain "first example in outer group"
|
|
43
43
|
And the output should contain "example in nested group"
|
|
44
44
|
|
|
45
45
|
Scenario: nested groups - inner group on declaration line
|
|
46
|
-
When I run
|
|
46
|
+
When I run `rspec example_spec.rb:11 --format doc`
|
|
47
47
|
Then the examples should all pass
|
|
48
48
|
And the output should contain "example in nested group"
|
|
49
49
|
And the output should not contain "second example in outer group"
|
|
50
50
|
And the output should not contain "first example in outer group"
|
|
51
51
|
|
|
52
52
|
Scenario: nested groups - inner group inside block before example
|
|
53
|
-
When I run
|
|
53
|
+
When I run `rspec example_spec.rb:12 --format doc`
|
|
54
54
|
Then the examples should all pass
|
|
55
55
|
And the output should contain "example in nested group"
|
|
56
56
|
And the output should not contain "second example in outer group"
|
|
57
57
|
And the output should not contain "first example in outer group"
|
|
58
58
|
|
|
59
59
|
Scenario: two examples - first example on declaration line
|
|
60
|
-
When I run
|
|
60
|
+
When I run `rspec example_spec.rb:3 --format doc`
|
|
61
61
|
Then the examples should all pass
|
|
62
62
|
And the output should contain "first example in outer group"
|
|
63
63
|
But the output should not contain "second example in outer group"
|
|
64
64
|
And the output should not contain "example in nested group"
|
|
65
65
|
|
|
66
66
|
Scenario: two examples - first example inside block
|
|
67
|
-
When I run
|
|
67
|
+
When I run `rspec example_spec.rb:4 --format doc`
|
|
68
68
|
Then the examples should all pass
|
|
69
69
|
And the output should contain "first example in outer group"
|
|
70
70
|
But the output should not contain "second example in outer group"
|
|
71
71
|
And the output should not contain "example in nested group"
|
|
72
72
|
|
|
73
73
|
Scenario: two examples - first example on end
|
|
74
|
-
When I run
|
|
74
|
+
When I run `rspec example_spec.rb:5 --format doc`
|
|
75
75
|
Then the examples should all pass
|
|
76
76
|
And the output should contain "first example in outer group"
|
|
77
77
|
But the output should not contain "second example in outer group"
|
|
78
78
|
And the output should not contain "example in nested group"
|
|
79
79
|
|
|
80
80
|
Scenario: two examples - first example after end but before next example
|
|
81
|
-
When I run
|
|
81
|
+
When I run `rspec example_spec.rb:6 --format doc`
|
|
82
82
|
Then the examples should all pass
|
|
83
83
|
And the output should contain "first example in outer group"
|
|
84
84
|
But the output should not contain "second example in outer group"
|
|
85
85
|
And the output should not contain "example in nested group"
|
|
86
86
|
|
|
87
87
|
Scenario: two examples - second example on declaration line
|
|
88
|
-
When I run
|
|
88
|
+
When I run `rspec example_spec.rb:7 --format doc`
|
|
89
89
|
Then the examples should all pass
|
|
90
90
|
And the output should contain "second example in outer group"
|
|
91
91
|
But the output should not contain "first example in outer group"
|
|
92
92
|
And the output should not contain "example in nested group"
|
|
93
93
|
|
|
94
94
|
Scenario: two examples - second example inside block
|
|
95
|
-
When I run
|
|
95
|
+
When I run `rspec example_spec.rb:7 --format doc`
|
|
96
96
|
Then the examples should all pass
|
|
97
97
|
And the output should contain "second example in outer group"
|
|
98
98
|
But the output should not contain "first example in outer group"
|
|
99
99
|
And the output should not contain "example in nested group"
|
|
100
100
|
|
|
101
101
|
Scenario: two examples - second example on end
|
|
102
|
-
When I run
|
|
102
|
+
When I run `rspec example_spec.rb:7 --format doc`
|
|
103
103
|
Then the examples should all pass
|
|
104
104
|
And the output should contain "second example in outer group"
|
|
105
105
|
But the output should not contain "first example in outer group"
|
|
@@ -21,7 +21,7 @@ Feature: --line_number option
|
|
|
21
21
|
|
|
22
22
|
end
|
|
23
23
|
"""
|
|
24
|
-
When I run
|
|
24
|
+
When I run `rspec example_spec.rb --line_number 5 --format doc`
|
|
25
25
|
Then the examples should all pass
|
|
26
26
|
Then the output should contain "should be > 8"
|
|
27
27
|
But the output should not contain "should be < 10"
|
|
@@ -39,7 +39,7 @@ Feature: --line_number option
|
|
|
39
39
|
|
|
40
40
|
end
|
|
41
41
|
"""
|
|
42
|
-
When I run
|
|
42
|
+
When I run `rspec example_spec.rb --line_number 5 --format doc`
|
|
43
43
|
Then the examples should all pass
|
|
44
44
|
Then the output should contain "should be > 8"
|
|
45
45
|
But the output should not contain "should be < 10"
|
|
@@ -19,7 +19,7 @@ Feature: rake task
|
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
"""
|
|
22
|
-
When I run
|
|
22
|
+
When I run `rake`
|
|
23
23
|
Then the stderr should contain "ruby -S rspec"
|
|
24
24
|
Then the exit status should be 0
|
|
25
25
|
|
|
@@ -40,7 +40,7 @@ Feature: rake task
|
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
"""
|
|
43
|
-
When I run
|
|
43
|
+
When I run `rake`
|
|
44
44
|
Then the exit status should be 1
|
|
45
45
|
|
|
46
46
|
Scenario: fail_on_error = false with failing spec (exit status is 0)
|
|
@@ -62,7 +62,7 @@ Feature: rake task
|
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
64
|
"""
|
|
65
|
-
When I run
|
|
65
|
+
When I run `rake`
|
|
66
66
|
Then the exit status should be 0
|
|
67
67
|
|
|
68
68
|
|