rspec-core 2.11.1 → 3.11.0
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/.document +1 -1
- data/.yardopts +3 -1
- data/Changelog.md +1814 -29
- data/{License.txt → LICENSE.md} +6 -4
- data/README.md +197 -48
- data/exe/rspec +2 -23
- data/lib/rspec/autorun.rb +1 -0
- data/lib/rspec/core/backtrace_formatter.rb +65 -0
- data/lib/rspec/core/bisect/coordinator.rb +62 -0
- data/lib/rspec/core/bisect/example_minimizer.rb +173 -0
- data/lib/rspec/core/bisect/fork_runner.rb +138 -0
- data/lib/rspec/core/bisect/server.rb +61 -0
- data/lib/rspec/core/bisect/shell_command.rb +126 -0
- data/lib/rspec/core/bisect/shell_runner.rb +73 -0
- data/lib/rspec/core/bisect/utilities.rb +69 -0
- data/lib/rspec/core/configuration.rb +1846 -407
- data/lib/rspec/core/configuration_options.rb +154 -50
- data/lib/rspec/core/did_you_mean.rb +46 -0
- data/lib/rspec/core/drb.rb +120 -0
- data/lib/rspec/core/dsl.rb +90 -18
- data/lib/rspec/core/example.rb +488 -152
- data/lib/rspec/core/example_group.rb +733 -294
- data/lib/rspec/core/example_status_persister.rb +235 -0
- data/lib/rspec/core/filter_manager.rb +175 -147
- data/lib/rspec/core/flat_map.rb +20 -0
- data/lib/rspec/core/formatters/base_bisect_formatter.rb +45 -0
- data/lib/rspec/core/formatters/base_formatter.rb +32 -130
- data/lib/rspec/core/formatters/base_text_formatter.rb +62 -190
- data/lib/rspec/core/formatters/bisect_drb_formatter.rb +29 -0
- data/lib/rspec/core/formatters/bisect_progress_formatter.rb +157 -0
- data/lib/rspec/core/formatters/console_codes.rb +76 -0
- data/lib/rspec/core/formatters/deprecation_formatter.rb +223 -0
- data/lib/rspec/core/formatters/documentation_formatter.rb +62 -27
- data/lib/rspec/core/formatters/exception_presenter.rb +521 -0
- data/lib/rspec/core/formatters/failure_list_formatter.rb +23 -0
- data/lib/rspec/core/formatters/fallback_message_formatter.rb +28 -0
- data/lib/rspec/core/formatters/helpers.rb +93 -14
- data/lib/rspec/core/formatters/html_formatter.rb +104 -415
- data/lib/rspec/core/formatters/html_printer.rb +414 -0
- data/lib/rspec/core/formatters/html_snippet_extractor.rb +120 -0
- data/lib/rspec/core/formatters/json_formatter.rb +102 -0
- data/lib/rspec/core/formatters/profile_formatter.rb +68 -0
- data/lib/rspec/core/formatters/progress_formatter.rb +12 -15
- data/lib/rspec/core/formatters/protocol.rb +182 -0
- data/lib/rspec/core/formatters/snippet_extractor.rb +115 -39
- data/lib/rspec/core/formatters/syntax_highlighter.rb +91 -0
- data/lib/rspec/core/formatters.rb +279 -0
- data/lib/rspec/core/hooks.rb +451 -300
- data/lib/rspec/core/invocations.rb +87 -0
- data/lib/rspec/core/memoized_helpers.rb +580 -0
- data/lib/rspec/core/metadata.rb +395 -173
- data/lib/rspec/core/metadata_filter.rb +255 -0
- data/lib/rspec/core/minitest_assertions_adapter.rb +31 -0
- data/lib/rspec/core/mocking_adapters/flexmock.rb +31 -0
- data/lib/rspec/core/mocking_adapters/mocha.rb +57 -0
- data/lib/rspec/core/mocking_adapters/null.rb +14 -0
- data/lib/rspec/core/mocking_adapters/rr.rb +31 -0
- data/lib/rspec/core/mocking_adapters/rspec.rb +32 -0
- data/lib/rspec/core/notifications.rb +521 -0
- data/lib/rspec/core/option_parser.rb +208 -64
- data/lib/rspec/core/ordering.rb +169 -0
- data/lib/rspec/core/output_wrapper.rb +29 -0
- data/lib/rspec/core/pending.rb +115 -59
- data/lib/rspec/core/profiler.rb +34 -0
- data/lib/rspec/core/project_initializer/.rspec +1 -0
- data/lib/rspec/core/project_initializer/spec/spec_helper.rb +98 -0
- data/lib/rspec/core/project_initializer.rb +26 -65
- data/lib/rspec/core/rake_task.rb +140 -131
- data/lib/rspec/core/reporter.rb +207 -44
- data/lib/rspec/core/ruby_project.rb +15 -6
- data/lib/rspec/core/runner.rb +180 -44
- data/lib/rspec/core/sandbox.rb +37 -0
- data/lib/rspec/core/set.rb +54 -0
- data/lib/rspec/core/shared_context.rb +25 -19
- data/lib/rspec/core/shared_example_group.rb +229 -54
- data/lib/rspec/core/shell_escape.rb +49 -0
- 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 +40 -0
- data/lib/rspec/core/world.rb +208 -49
- data/lib/rspec/core.rb +166 -80
- data.tar.gz.sig +0 -0
- metadata +230 -445
- metadata.gz.sig +0 -0
- data/exe/autospec +0 -13
- data/features/Autotest.md +0 -38
- data/features/README.md +0 -17
- data/features/Upgrade.md +0 -364
- data/features/command_line/README.md +0 -28
- data/features/command_line/example_name_option.feature +0 -101
- data/features/command_line/exit_status.feature +0 -83
- data/features/command_line/format_option.feature +0 -81
- data/features/command_line/init.feature +0 -18
- 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 -29
- data/features/command_line/pattern_option.feature +0 -31
- data/features/command_line/rake_task.feature +0 -68
- data/features/command_line/ruby.feature +0 -22
- data/features/command_line/tag.feature +0 -91
- data/features/configuration/alias_example_to.feature +0 -48
- data/features/configuration/custom_settings.feature +0 -84
- data/features/configuration/default_path.feature +0 -38
- data/features/configuration/fail_fast.feature +0 -77
- data/features/configuration/read_options_from_file.feature +0 -87
- 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 -204
- data/features/expectation_framework_integration/configure_expectation_framework.feature +0 -102
- data/features/filtering/exclusion_filters.feature +0 -139
- data/features/filtering/if_and_unless.feature +0 -168
- data/features/filtering/inclusion_filters.feature +0 -105
- data/features/filtering/run_all_when_everything_filtered.feature +0 -46
- data/features/formatters/custom_formatter.feature +0 -36
- 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 -149
- data/features/hooks/around_hooks.feature +0 -343
- data/features/hooks/before_and_after_hooks.feature +0 -423
- data/features/hooks/filtering.feature +0 -234
- data/features/metadata/current_example.feature +0 -17
- data/features/metadata/described_class.feature +0 -17
- data/features/metadata/user_defined.feature +0 -113
- data/features/mock_framework_integration/use_any_framework.feature +0 -106
- data/features/mock_framework_integration/use_flexmock.feature +0 -96
- data/features/mock_framework_integration/use_mocha.feature +0 -97
- data/features/mock_framework_integration/use_rr.feature +0 -98
- data/features/mock_framework_integration/use_rspec.feature +0 -97
- data/features/pending/pending_examples.feature +0 -229
- data/features/spec_files/arbitrary_file_suffix.feature +0 -13
- data/features/step_definitions/additional_cli_steps.rb +0 -30
- data/features/subject/attribute_of_subject.feature +0 -124
- data/features/subject/explicit_subject.feature +0 -82
- data/features/subject/implicit_receiver.feature +0 -29
- data/features/subject/implicit_subject.feature +0 -63
- data/features/support/env.rb +0 -12
- data/lib/autotest/discover.rb +0 -1
- data/lib/autotest/rspec2.rb +0 -73
- data/lib/rspec/core/backward_compatibility.rb +0 -65
- data/lib/rspec/core/command_line.rb +0 -36
- data/lib/rspec/core/deprecation.rb +0 -36
- data/lib/rspec/core/drb_command_line.rb +0 -26
- data/lib/rspec/core/drb_options.rb +0 -87
- data/lib/rspec/core/extensions/instance_eval_with_args.rb +0 -44
- data/lib/rspec/core/extensions/kernel.rb +0 -9
- data/lib/rspec/core/extensions/module_eval_with_args.rb +0 -38
- data/lib/rspec/core/extensions/ordered.rb +0 -21
- data/lib/rspec/core/extensions.rb +0 -4
- data/lib/rspec/core/formatters/text_mate_formatter.rb +0 -34
- data/lib/rspec/core/let.rb +0 -110
- data/lib/rspec/core/load_path.rb +0 -3
- data/lib/rspec/core/metadata_hash_builder.rb +0 -97
- 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_mocha.rb +0 -29
- data/lib/rspec/core/mocking/with_rr.rb +0 -27
- data/lib/rspec/core/mocking/with_rspec.rb +0 -23
- data/lib/rspec/core/subject.rb +0 -219
- data/spec/autotest/discover_spec.rb +0 -19
- data/spec/autotest/failed_results_re_spec.rb +0 -45
- data/spec/autotest/rspec_spec.rb +0 -123
- data/spec/command_line/order_spec.rb +0 -137
- data/spec/rspec/core/command_line_spec.rb +0 -108
- data/spec/rspec/core/command_line_spec_output.txt +0 -0
- data/spec/rspec/core/configuration_options_spec.rb +0 -377
- data/spec/rspec/core/configuration_spec.rb +0 -1196
- data/spec/rspec/core/deprecations_spec.rb +0 -66
- data/spec/rspec/core/drb_command_line_spec.rb +0 -108
- data/spec/rspec/core/drb_options_spec.rb +0 -180
- data/spec/rspec/core/dsl_spec.rb +0 -17
- data/spec/rspec/core/example_group_spec.rb +0 -1098
- data/spec/rspec/core/example_spec.rb +0 -370
- data/spec/rspec/core/filter_manager_spec.rb +0 -256
- data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -80
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +0 -363
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +0 -88
- data/spec/rspec/core/formatters/helpers_spec.rb +0 -66
- data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +0 -410
- data/spec/rspec/core/formatters/html_formatted-1.8.7.html +0 -409
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +0 -416
- data/spec/rspec/core/formatters/html_formatted-1.9.3.html +0 -416
- data/spec/rspec/core/formatters/html_formatter_spec.rb +0 -82
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -30
- data/spec/rspec/core/formatters/snippet_extractor_spec.rb +0 -18
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +0 -410
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +0 -409
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +0 -416
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.3.html +0 -416
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +0 -83
- data/spec/rspec/core/hooks_filtering_spec.rb +0 -227
- data/spec/rspec/core/hooks_spec.rb +0 -250
- data/spec/rspec/core/kernel_extensions_spec.rb +0 -9
- data/spec/rspec/core/let_spec.rb +0 -55
- data/spec/rspec/core/metadata_spec.rb +0 -447
- data/spec/rspec/core/option_parser_spec.rb +0 -166
- data/spec/rspec/core/pending_example_spec.rb +0 -220
- data/spec/rspec/core/project_initializer_spec.rb +0 -130
- data/spec/rspec/core/rake_task_spec.rb +0 -138
- data/spec/rspec/core/reporter_spec.rb +0 -103
- 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 -60
- 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 -24
- data/spec/rspec/core/runner_spec.rb +0 -81
- data/spec/rspec/core/shared_context_spec.rb +0 -67
- data/spec/rspec/core/shared_example_group_spec.rb +0 -84
- data/spec/rspec/core/subject_spec.rb +0 -244
- data/spec/rspec/core/world_spec.rb +0 -144
- data/spec/rspec/core_spec.rb +0 -35
- data/spec/spec_helper.rb +0 -98
- data/spec/support/config_options_helper.rb +0 -24
- data/spec/support/helper_methods.rb +0 -5
- data/spec/support/matchers.rb +0 -65
- data/spec/support/shared_example_groups.rb +0 -41
- data/spec/support/spec_files.rb +0 -44
@@ -1,81 +0,0 @@
|
|
1
|
-
Feature: --format option
|
2
|
-
|
3
|
-
Use the --format option to tell RSpec how to format the output.
|
4
|
-
|
5
|
-
RSpec ships with a few formatters built in. By default, it uses the progress
|
6
|
-
formatter, which generates output like this:
|
7
|
-
|
8
|
-
....F.....*.....
|
9
|
-
|
10
|
-
A '.' represents a passing example, 'F' is failing, and '*' is pending.
|
11
|
-
|
12
|
-
To see the documentation strings passed to each describe(), context(), and it()
|
13
|
-
method, use the documentation formatter:
|
14
|
-
|
15
|
-
$ rspec spec --format documentation
|
16
|
-
|
17
|
-
You can also specify an output target (STDOUT by default) by appending a
|
18
|
-
filename to the argument:
|
19
|
-
|
20
|
-
$ rspec spec --format documentation:rspec.output.txt
|
21
|
-
|
22
|
-
`rspec --help` lists available formatters:
|
23
|
-
|
24
|
-
[p]rogress (default - dots)
|
25
|
-
[d]ocumentation (group and example names)
|
26
|
-
[h]tml
|
27
|
-
[t]extmate
|
28
|
-
custom formatter class name
|
29
|
-
|
30
|
-
Background:
|
31
|
-
Given a file named "example_spec.rb" with:
|
32
|
-
"""
|
33
|
-
describe "something" do
|
34
|
-
it "does something that passes" do
|
35
|
-
5.should eq(5)
|
36
|
-
end
|
37
|
-
|
38
|
-
it "does something that fails" do
|
39
|
-
5.should eq(4)
|
40
|
-
end
|
41
|
-
|
42
|
-
it "does something that is pending", :pending => true do
|
43
|
-
5.should be > 3
|
44
|
-
end
|
45
|
-
end
|
46
|
-
"""
|
47
|
-
|
48
|
-
Scenario: progress bar format (default)
|
49
|
-
When I run `rspec --format progress example_spec.rb`
|
50
|
-
Then the output should contain ".F*"
|
51
|
-
|
52
|
-
Scenario: documentation format
|
53
|
-
When I run `rspec example_spec.rb --format documentation`
|
54
|
-
Then the output should contain:
|
55
|
-
"""
|
56
|
-
something
|
57
|
-
does something that passes
|
58
|
-
does something that fails (FAILED - 1)
|
59
|
-
does something that is pending (PENDING: No reason given)
|
60
|
-
"""
|
61
|
-
|
62
|
-
Scenario: documentation format saved to a file
|
63
|
-
When I run `rspec example_spec.rb --format documentation --out rspec.txt`
|
64
|
-
Then the file "rspec.txt" should contain:
|
65
|
-
"""
|
66
|
-
something
|
67
|
-
does something that passes
|
68
|
-
does something that fails (FAILED - 1)
|
69
|
-
does something that is pending (PENDING: No reason given)
|
70
|
-
"""
|
71
|
-
|
72
|
-
Scenario: multiple formats
|
73
|
-
When I run `rspec example_spec.rb --format progress --format documentation --out rspec.txt`
|
74
|
-
Then the output should contain ".F*"
|
75
|
-
And the file "rspec.txt" should contain:
|
76
|
-
"""
|
77
|
-
something
|
78
|
-
does something that passes
|
79
|
-
does something that fails (FAILED - 1)
|
80
|
-
does something that is pending (PENDING: No reason given)
|
81
|
-
"""
|
@@ -1,18 +0,0 @@
|
|
1
|
-
Feature: --init option
|
2
|
-
|
3
|
-
Use the --init option on the command line to generate conventional
|
4
|
-
files for an rspec project.
|
5
|
-
|
6
|
-
Scenario: generate .rspec
|
7
|
-
When I run `rspec --init`
|
8
|
-
Then the following files should exist:
|
9
|
-
| .rspec |
|
10
|
-
And the output should contain "create .rspec"
|
11
|
-
|
12
|
-
Scenario: .rspec file already exists
|
13
|
-
Given a file named ".rspec" with:
|
14
|
-
"""
|
15
|
-
--color
|
16
|
-
"""
|
17
|
-
When I run `rspec --init`
|
18
|
-
Then the output should contain "exist .rspec"
|
@@ -1,140 +0,0 @@
|
|
1
|
-
Feature: line number appended to file path
|
2
|
-
|
3
|
-
To run one or more examples or groups, you can append the line number to the path, e.g.
|
4
|
-
|
5
|
-
rspec path/to/example_spec.rb:37
|
6
|
-
|
7
|
-
Background:
|
8
|
-
Given a file named "example_spec.rb" with:
|
9
|
-
"""
|
10
|
-
describe "outer group" do
|
11
|
-
|
12
|
-
it "first example in outer group" do
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
it "second example in outer group" do
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "nested group" do
|
21
|
-
|
22
|
-
it "example in nested group" do
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
"""
|
30
|
-
And a file named "example2_spec.rb" with:
|
31
|
-
"""
|
32
|
-
describe "yet another group" do
|
33
|
-
it "first example in second file" do
|
34
|
-
end
|
35
|
-
it "second example in second file" do
|
36
|
-
end
|
37
|
-
end
|
38
|
-
"""
|
39
|
-
|
40
|
-
Scenario: nested groups - outer group on declaration line
|
41
|
-
When I run `rspec example_spec.rb:1 --format doc`
|
42
|
-
Then the examples should all pass
|
43
|
-
And the output should contain "second example in outer group"
|
44
|
-
And the output should contain "first example in outer group"
|
45
|
-
And the output should contain "example in nested group"
|
46
|
-
|
47
|
-
Scenario: nested groups - outer group inside block before example
|
48
|
-
When I run `rspec example_spec.rb:2 --format doc`
|
49
|
-
Then the examples should all pass
|
50
|
-
And the output should contain "second example in outer group"
|
51
|
-
And the output should contain "first example in outer group"
|
52
|
-
And the output should contain "example in nested group"
|
53
|
-
|
54
|
-
Scenario: nested groups - inner group on declaration line
|
55
|
-
When I run `rspec example_spec.rb:11 --format doc`
|
56
|
-
Then the examples should all pass
|
57
|
-
And the output should contain "example in nested group"
|
58
|
-
And the output should not contain "second example in outer group"
|
59
|
-
And the output should not contain "first example in outer group"
|
60
|
-
|
61
|
-
Scenario: nested groups - inner group inside block before example
|
62
|
-
When I run `rspec example_spec.rb:12 --format doc`
|
63
|
-
Then the examples should all pass
|
64
|
-
And the output should contain "example in nested group"
|
65
|
-
And the output should not contain "second example in outer group"
|
66
|
-
And the output should not contain "first example in outer group"
|
67
|
-
|
68
|
-
Scenario: two examples - first example on declaration line
|
69
|
-
When I run `rspec example_spec.rb:3 --format doc`
|
70
|
-
Then the examples should all pass
|
71
|
-
And the output should contain "first example in outer group"
|
72
|
-
But the output should not contain "second example in outer group"
|
73
|
-
And the output should not contain "example in nested group"
|
74
|
-
|
75
|
-
Scenario: two examples - first example inside block
|
76
|
-
When I run `rspec example_spec.rb:4 --format doc`
|
77
|
-
Then the examples should all pass
|
78
|
-
And the output should contain "first example in outer group"
|
79
|
-
But the output should not contain "second example in outer group"
|
80
|
-
And the output should not contain "example in nested group"
|
81
|
-
|
82
|
-
Scenario: two examples - first example on end
|
83
|
-
When I run `rspec example_spec.rb:5 --format doc`
|
84
|
-
Then the examples should all pass
|
85
|
-
And the output should contain "first example in outer group"
|
86
|
-
But the output should not contain "second example in outer group"
|
87
|
-
And the output should not contain "example in nested group"
|
88
|
-
|
89
|
-
Scenario: two examples - first example after end but before next example
|
90
|
-
When I run `rspec example_spec.rb:6 --format doc`
|
91
|
-
Then the examples should all pass
|
92
|
-
And the output should contain "first example in outer group"
|
93
|
-
But the output should not contain "second example in outer group"
|
94
|
-
And the output should not contain "example in nested group"
|
95
|
-
|
96
|
-
Scenario: two examples - second example on declaration line
|
97
|
-
When I run `rspec example_spec.rb:7 --format doc`
|
98
|
-
Then the examples should all pass
|
99
|
-
And the output should contain "second example in outer group"
|
100
|
-
But the output should not contain "first example in outer group"
|
101
|
-
And the output should not contain "example in nested group"
|
102
|
-
|
103
|
-
Scenario: two examples - second example inside block
|
104
|
-
When I run `rspec example_spec.rb:7 --format doc`
|
105
|
-
Then the examples should all pass
|
106
|
-
And the output should contain "second example in outer group"
|
107
|
-
But the output should not contain "first example in outer group"
|
108
|
-
And the output should not contain "example in nested group"
|
109
|
-
|
110
|
-
Scenario: two examples - second example on end
|
111
|
-
When I run `rspec example_spec.rb:7 --format doc`
|
112
|
-
Then the examples should all pass
|
113
|
-
And the output should contain "second example in outer group"
|
114
|
-
But the output should not contain "first example in outer group"
|
115
|
-
And the output should not contain "example in nested group"
|
116
|
-
|
117
|
-
Scenario: specified multiple times for different files
|
118
|
-
When I run `rspec example_spec.rb:7 example2_spec.rb:4 --format doc`
|
119
|
-
Then the examples should all pass
|
120
|
-
And the output should contain "second example in outer group"
|
121
|
-
And the output should contain "second example in second file"
|
122
|
-
But the output should not contain "first example in outer group"
|
123
|
-
And the output should not contain "nested group"
|
124
|
-
And the output should not contain "first example in second file"
|
125
|
-
|
126
|
-
Scenario: specified multiple times for the same file with multiple arguments
|
127
|
-
When I run `rspec example_spec.rb:7 example_spec.rb:11 --format doc`
|
128
|
-
Then the examples should all pass
|
129
|
-
And the output should contain "second example in outer group"
|
130
|
-
And the output should contain "nested group"
|
131
|
-
But the output should not contain "first example in outer group"
|
132
|
-
And the output should not contain "second file"
|
133
|
-
|
134
|
-
Scenario: specified multiple times for the same file with a single argument
|
135
|
-
When I run `rspec example_spec.rb:7:11 --format doc`
|
136
|
-
Then the examples should all pass
|
137
|
-
And the output should contain "second example in outer group"
|
138
|
-
And the output should contain "nested group"
|
139
|
-
But the output should not contain "first example in outer group"
|
140
|
-
And the output should not contain "second file"
|
@@ -1,58 +0,0 @@
|
|
1
|
-
Feature: --line_number option
|
2
|
-
|
3
|
-
To run a examples or groups by line numbers, one can use the --line_number option:
|
4
|
-
|
5
|
-
rspec path/to/example_spec.rb --line_number 37
|
6
|
-
|
7
|
-
This option can be specified multiple times.
|
8
|
-
|
9
|
-
Scenario: standard examples
|
10
|
-
Given a file named "example_spec.rb" with:
|
11
|
-
"""
|
12
|
-
require "rspec/expectations"
|
13
|
-
|
14
|
-
describe 9 do
|
15
|
-
|
16
|
-
it "should be > 8" do
|
17
|
-
9.should be > 8
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should be < 10" do
|
21
|
-
9.should be < 10
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should be 3 squared" do
|
25
|
-
9.should be 3*3
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
"""
|
30
|
-
When I run `rspec example_spec.rb --line_number 5 --format doc`
|
31
|
-
Then the examples should all pass
|
32
|
-
And the output should contain "should be > 8"
|
33
|
-
But the output should not contain "should be < 10"
|
34
|
-
And the output should not contain "should be 3*3"
|
35
|
-
|
36
|
-
When I run `rspec example_spec.rb --line_number 5 --line_number 9 --format doc`
|
37
|
-
Then the examples should all pass
|
38
|
-
And the output should contain "should be > 8"
|
39
|
-
And the output should contain "should be < 10"
|
40
|
-
But the output should not contain "should be 3*3"
|
41
|
-
|
42
|
-
Scenario: one liner
|
43
|
-
Given a file named "example_spec.rb" with:
|
44
|
-
"""
|
45
|
-
require "rspec/expectations"
|
46
|
-
|
47
|
-
describe 9 do
|
48
|
-
|
49
|
-
it { should be > 8 }
|
50
|
-
|
51
|
-
it { should be < 10 }
|
52
|
-
|
53
|
-
end
|
54
|
-
"""
|
55
|
-
When I run `rspec example_spec.rb --line_number 5 --format doc`
|
56
|
-
Then the examples should all pass
|
57
|
-
Then the output should contain "should be > 8"
|
58
|
-
But the output should not contain "should be < 10"
|
@@ -1,29 +0,0 @@
|
|
1
|
-
Feature: --order (new in rspec-core-2.8)
|
2
|
-
|
3
|
-
Use the `--order` option to tell RSpec how to order the files, groups, and
|
4
|
-
examples. Options are `default` and `rand`:
|
5
|
-
|
6
|
-
Default is:
|
7
|
-
|
8
|
-
* files are ordered based on the underlying file system's order (typically
|
9
|
-
case-sensitive alpha on *nix OS's and case-insenstive alpha in Windows)
|
10
|
-
* groups/examples are loaded in the order in which they are declared
|
11
|
-
|
12
|
-
Use `rand` to randomize the order of files, groups within files, and
|
13
|
-
examples within groups.*
|
14
|
-
|
15
|
-
* Nested groups are always run from top-level to bottom-level in order to avoid
|
16
|
-
executing `before(:all)` and `after(:all)` hooks more than once, but the order
|
17
|
-
of groups at each level is randomized.
|
18
|
-
|
19
|
-
You can also specify a seed
|
20
|
-
|
21
|
-
<h3>Examples</h3>
|
22
|
-
|
23
|
-
--order default
|
24
|
-
--order rand
|
25
|
-
--order rand:123
|
26
|
-
--seed 123 # same as --order rand:123
|
27
|
-
|
28
|
-
The `default` option is only necessary when you have `--order rand` stored in a
|
29
|
-
config file (e.g. `.rspec`) and you want to override it from the command line.
|
@@ -1,31 +0,0 @@
|
|
1
|
-
Feature: pattern option
|
2
|
-
|
3
|
-
By default, RSpec loads files matching the pattern:
|
4
|
-
|
5
|
-
"spec/**/*_spec.rb"
|
6
|
-
|
7
|
-
Use the `--pattern` option to declare a different pattern.
|
8
|
-
|
9
|
-
Scenario: default pattern
|
10
|
-
Given a file named "spec/example_spec.rb" with:
|
11
|
-
"""
|
12
|
-
describe "addition" do
|
13
|
-
it "adds things" do
|
14
|
-
(1 + 2).should eq(3)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
"""
|
18
|
-
When I run `rspec`
|
19
|
-
Then the output should contain "1 example, 0 failures"
|
20
|
-
|
21
|
-
Scenario: override the default pattern on the command line
|
22
|
-
Given a file named "spec/example.spec" with:
|
23
|
-
"""
|
24
|
-
describe "addition" do
|
25
|
-
it "adds things" do
|
26
|
-
(1 + 2).should eq(3)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
"""
|
30
|
-
When I run `rspec --pattern "spec/**/*.spec"`
|
31
|
-
Then the output should contain "1 example, 0 failures"
|
@@ -1,68 +0,0 @@
|
|
1
|
-
Feature: rake task
|
2
|
-
|
3
|
-
RSpec ships with a rake task with a number of useful options
|
4
|
-
|
5
|
-
Scenario: default options with passing spec (prints command and exit status is 0)
|
6
|
-
Given a file named "Rakefile" with:
|
7
|
-
"""
|
8
|
-
require 'rspec/core/rake_task'
|
9
|
-
|
10
|
-
RSpec::Core::RakeTask.new(:spec)
|
11
|
-
|
12
|
-
task :default => :spec
|
13
|
-
"""
|
14
|
-
And a file named "spec/thing_spec.rb" with:
|
15
|
-
"""
|
16
|
-
describe "something" do
|
17
|
-
it "does something" do
|
18
|
-
# pass
|
19
|
-
end
|
20
|
-
end
|
21
|
-
"""
|
22
|
-
When I run `rake`
|
23
|
-
Then the output should contain "ruby -S rspec"
|
24
|
-
Then the exit status should be 0
|
25
|
-
|
26
|
-
Scenario: default options with failing spec (exit status is 1)
|
27
|
-
Given a file named "Rakefile" with:
|
28
|
-
"""
|
29
|
-
require 'rspec/core/rake_task'
|
30
|
-
|
31
|
-
RSpec::Core::RakeTask.new(:spec)
|
32
|
-
|
33
|
-
task :default => :spec
|
34
|
-
"""
|
35
|
-
And a file named "spec/thing_spec.rb" with:
|
36
|
-
"""
|
37
|
-
describe "something" do
|
38
|
-
it "does something" do
|
39
|
-
fail
|
40
|
-
end
|
41
|
-
end
|
42
|
-
"""
|
43
|
-
When I run `rake`
|
44
|
-
Then the exit status should be 1
|
45
|
-
|
46
|
-
Scenario: fail_on_error = false with failing spec (exit status is 0)
|
47
|
-
Given a file named "Rakefile" with:
|
48
|
-
"""
|
49
|
-
require 'rspec/core/rake_task'
|
50
|
-
|
51
|
-
RSpec::Core::RakeTask.new(:spec) do |t|
|
52
|
-
t.fail_on_error = false
|
53
|
-
end
|
54
|
-
|
55
|
-
task :default => :spec
|
56
|
-
"""
|
57
|
-
And a file named "spec/thing_spec.rb" with:
|
58
|
-
"""
|
59
|
-
describe "something" do
|
60
|
-
it "does something" do
|
61
|
-
fail
|
62
|
-
end
|
63
|
-
end
|
64
|
-
"""
|
65
|
-
When I run `rake`
|
66
|
-
Then the exit status should be 0
|
67
|
-
|
68
|
-
|
@@ -1,22 +0,0 @@
|
|
1
|
-
Feature: run with ruby command
|
2
|
-
|
3
|
-
You can use the `ruby` command to run specs. You just need to require
|
4
|
-
`rspec/autorun`.
|
5
|
-
|
6
|
-
Generally speaking, you're better off using the `rspec` command, which
|
7
|
-
requires `rspec/autorun` for you, but some tools only work with the `ruby`
|
8
|
-
command.
|
9
|
-
|
10
|
-
Scenario:
|
11
|
-
Given a file named "example_spec.rb" with:
|
12
|
-
"""
|
13
|
-
require 'rspec/autorun'
|
14
|
-
|
15
|
-
describe 1 do
|
16
|
-
it "is < 2" do
|
17
|
-
1.should be < 2
|
18
|
-
end
|
19
|
-
end
|
20
|
-
"""
|
21
|
-
When I run `ruby example_spec.rb`
|
22
|
-
Then the output should contain "1 example, 0 failures"
|
@@ -1,91 +0,0 @@
|
|
1
|
-
Feature: --tag option
|
2
|
-
|
3
|
-
Use the --tag (or -t) option to filter the examples by tags.
|
4
|
-
|
5
|
-
The tag can be a simple name or a name:value pair. In the first case,
|
6
|
-
examples with :name => true will be filtered. In the second case, examples
|
7
|
-
with :name => value will be filtered, where value is always a string. In
|
8
|
-
both cases, name is converted to a symbol.
|
9
|
-
|
10
|
-
Tags can also be used to exclude examples by adding a ~ before the tag. For
|
11
|
-
example ~tag will exclude all examples marked with :tag => true and
|
12
|
-
~tag:value will exclude all examples marked with :tag => value.
|
13
|
-
|
14
|
-
To be compatible with the Cucumber syntax, tags can optionally start with
|
15
|
-
an @ symbol, which will be ignored.
|
16
|
-
|
17
|
-
Background:
|
18
|
-
Given a file named "tagged_spec.rb" with:
|
19
|
-
"""
|
20
|
-
describe "group with tagged specs" do
|
21
|
-
it "example I'm working now", :focus => true do; end
|
22
|
-
it "special example with string", :type => 'special' do; end
|
23
|
-
it "special example with symbol", :type => :special do; end
|
24
|
-
it "slow example", :skip => true do; end
|
25
|
-
it "ordinary example", :speed => 'slow' do; end
|
26
|
-
it "untagged example" do; end
|
27
|
-
end
|
28
|
-
"""
|
29
|
-
|
30
|
-
Scenario: filter examples with non-existent tag
|
31
|
-
When I run `rspec . --tag mytag`
|
32
|
-
And the examples should all pass
|
33
|
-
|
34
|
-
Scenario: filter examples with a simple tag
|
35
|
-
When I run `rspec . --tag focus`
|
36
|
-
Then the output should contain "include {:focus=>true}"
|
37
|
-
And the examples should all pass
|
38
|
-
|
39
|
-
Scenario: filter examples with a simple tag and @
|
40
|
-
When I run `rspec . --tag @focus`
|
41
|
-
Then the output should contain "include {:focus=>true}"
|
42
|
-
Then the examples should all pass
|
43
|
-
|
44
|
-
Scenario: filter examples with a name:value tag
|
45
|
-
When I run `rspec . --tag type:special`
|
46
|
-
Then the output should contain:
|
47
|
-
"""
|
48
|
-
include {:type=>"special"}
|
49
|
-
"""
|
50
|
-
And the output should contain "2 examples"
|
51
|
-
And the examples should all pass
|
52
|
-
|
53
|
-
Scenario: filter examples with a name:value tag and @
|
54
|
-
When I run `rspec . --tag @type:special`
|
55
|
-
Then the output should contain:
|
56
|
-
"""
|
57
|
-
include {:type=>"special"}
|
58
|
-
"""
|
59
|
-
And the examples should all pass
|
60
|
-
|
61
|
-
Scenario: exclude examples with a simple tag
|
62
|
-
When I run `rspec . --tag ~skip`
|
63
|
-
Then the output should contain "exclude {:skip=>true}"
|
64
|
-
Then the examples should all pass
|
65
|
-
|
66
|
-
Scenario: exclude examples with a simple tag and @
|
67
|
-
When I run `rspec . --tag ~@skip`
|
68
|
-
Then the output should contain "exclude {:skip=>true}"
|
69
|
-
Then the examples should all pass
|
70
|
-
|
71
|
-
Scenario: exclude examples with a name:value tag
|
72
|
-
When I run `rspec . --tag ~speed:slow`
|
73
|
-
Then the output should contain:
|
74
|
-
"""
|
75
|
-
exclude {:speed=>"slow"}
|
76
|
-
"""
|
77
|
-
Then the examples should all pass
|
78
|
-
|
79
|
-
Scenario: exclude examples with a name:value tag and @
|
80
|
-
When I run `rspec . --tag ~@speed:slow`
|
81
|
-
Then the output should contain:
|
82
|
-
"""
|
83
|
-
exclude {:speed=>"slow"}
|
84
|
-
"""
|
85
|
-
Then the examples should all pass
|
86
|
-
|
87
|
-
Scenario: filter examples with a simple tag, exclude examples with another tag
|
88
|
-
When I run `rspec . --tag focus --tag ~skip`
|
89
|
-
Then the output should contain "include {:focus=>true}"
|
90
|
-
And the output should contain "exclude {:skip=>true}"
|
91
|
-
And the examples should all pass
|
@@ -1,48 +0,0 @@
|
|
1
|
-
Feature: alias_example_to
|
2
|
-
|
3
|
-
Use `config.alias_example_to` to create new example group methods
|
4
|
-
that define examples with the configured metadata.
|
5
|
-
|
6
|
-
If you set the `treat_symbols_as_metadata_keys_with_true_values` config option
|
7
|
-
to `true`, you can specify metadata using only symbols.
|
8
|
-
|
9
|
-
Scenario: Use alias_example_to to define focused example
|
10
|
-
Given a file named "alias_example_to_spec.rb" with:
|
11
|
-
"""
|
12
|
-
RSpec.configure do |c|
|
13
|
-
c.alias_example_to :fit, :focused => true
|
14
|
-
c.filter_run :focused => true
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "an example group" do
|
18
|
-
it "does one thing" do
|
19
|
-
end
|
20
|
-
|
21
|
-
fit "does another thing" do
|
22
|
-
end
|
23
|
-
end
|
24
|
-
"""
|
25
|
-
When I run `rspec alias_example_to_spec.rb --format doc`
|
26
|
-
Then the output should contain "does another thing"
|
27
|
-
And the output should not contain "does one thing"
|
28
|
-
|
29
|
-
Scenario: use symbols as metadata
|
30
|
-
Given a file named "use_symbols_as_metadata_spec.rb" with:
|
31
|
-
"""
|
32
|
-
RSpec.configure do |c|
|
33
|
-
c.treat_symbols_as_metadata_keys_with_true_values = true
|
34
|
-
c.alias_example_to :fit, :focused
|
35
|
-
c.filter_run :focused
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "an example group" do
|
39
|
-
it "does one thing" do
|
40
|
-
end
|
41
|
-
|
42
|
-
fit "does another thing" do
|
43
|
-
end
|
44
|
-
end
|
45
|
-
"""
|
46
|
-
When I run `rspec use_symbols_as_metadata_spec.rb --format doc`
|
47
|
-
Then the output should contain "does another thing"
|
48
|
-
And the output should not contain "does one thing"
|
@@ -1,84 +0,0 @@
|
|
1
|
-
Feature: custom settings
|
2
|
-
|
3
|
-
Extensions like rspec-rails can add their own configuration settings.
|
4
|
-
|
5
|
-
Scenario: simple setting (with defaults)
|
6
|
-
Given a file named "additional_setting_spec.rb" with:
|
7
|
-
"""
|
8
|
-
RSpec.configure do |c|
|
9
|
-
c.add_setting :custom_setting
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "custom setting" do
|
13
|
-
it "is nil by default" do
|
14
|
-
RSpec.configuration.custom_setting.should be_nil
|
15
|
-
end
|
16
|
-
|
17
|
-
it "acts false by default" do
|
18
|
-
RSpec.configuration.custom_setting.should be_false
|
19
|
-
end
|
20
|
-
|
21
|
-
it "is exposed as a predicate" do
|
22
|
-
RSpec.configuration.custom_setting?.should be_false
|
23
|
-
end
|
24
|
-
|
25
|
-
it "can be overridden" do
|
26
|
-
RSpec.configuration.custom_setting = true
|
27
|
-
RSpec.configuration.custom_setting.should be_true
|
28
|
-
RSpec.configuration.custom_setting?.should be_true
|
29
|
-
end
|
30
|
-
end
|
31
|
-
"""
|
32
|
-
When I run `rspec ./additional_setting_spec.rb`
|
33
|
-
Then the examples should all pass
|
34
|
-
|
35
|
-
Scenario: default to true
|
36
|
-
Given a file named "additional_setting_spec.rb" with:
|
37
|
-
"""
|
38
|
-
RSpec.configure do |c|
|
39
|
-
c.add_setting :custom_setting, :default => true
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "custom setting" do
|
43
|
-
it "is true by default" do
|
44
|
-
RSpec.configuration.custom_setting.should be_true
|
45
|
-
end
|
46
|
-
|
47
|
-
it "is exposed as a predicate" do
|
48
|
-
RSpec.configuration.custom_setting?.should be_true
|
49
|
-
end
|
50
|
-
|
51
|
-
it "can be overridden" do
|
52
|
-
RSpec.configuration.custom_setting = false
|
53
|
-
RSpec.configuration.custom_setting.should be_false
|
54
|
-
RSpec.configuration.custom_setting?.should be_false
|
55
|
-
end
|
56
|
-
end
|
57
|
-
"""
|
58
|
-
When I run `rspec ./additional_setting_spec.rb`
|
59
|
-
Then the examples should all pass
|
60
|
-
|
61
|
-
Scenario: overridden in a subsequent RSpec.configure block
|
62
|
-
Given a file named "additional_setting_spec.rb" with:
|
63
|
-
"""
|
64
|
-
RSpec.configure do |c|
|
65
|
-
c.add_setting :custom_setting
|
66
|
-
end
|
67
|
-
|
68
|
-
RSpec.configure do |c|
|
69
|
-
c.custom_setting = true
|
70
|
-
end
|
71
|
-
|
72
|
-
describe "custom setting" do
|
73
|
-
it "returns the value set in the last cofigure block to get eval'd" do
|
74
|
-
RSpec.configuration.custom_setting.should be_true
|
75
|
-
end
|
76
|
-
|
77
|
-
it "is exposed as a predicate" do
|
78
|
-
RSpec.configuration.custom_setting?.should be_true
|
79
|
-
end
|
80
|
-
end
|
81
|
-
"""
|
82
|
-
When I run `rspec ./additional_setting_spec.rb`
|
83
|
-
Then the examples should all pass
|
84
|
-
|