rspec-core 2.0.0.beta.22 → 2.6.4
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/.gitignore +1 -0
- data/.rspec +0 -1
- data/.travis.yml +9 -0
- data/Changelog.md +305 -0
- data/Gemfile +45 -20
- data/Guardfile +5 -0
- data/License.txt +2 -1
- data/{README.markdown → README.md} +23 -5
- data/Rakefile +63 -32
- data/bin/autospec +13 -0
- data/bin/rspec +24 -2
- data/cucumber.yml +1 -1
- data/features/.nav +57 -0
- data/features/Autotest.md +38 -0
- data/features/README.md +17 -0
- data/features/Upgrade.md +320 -0
- data/features/command_line/README.md +28 -0
- data/features/command_line/configure.feature +18 -15
- data/features/command_line/example_name_option.feature +37 -23
- data/features/command_line/exit_status.feature +16 -31
- data/features/command_line/format_option.feature +73 -0
- data/features/command_line/line_number_appended_to_path.feature +25 -27
- data/features/command_line/line_number_option.feature +11 -10
- data/features/command_line/rake_task.feature +68 -0
- data/features/command_line/tag.feature +90 -0
- data/features/configuration/alias_example_to.feature +48 -0
- data/features/configuration/custom_settings.feature +8 -10
- data/features/configuration/fail_fast.feature +77 -0
- data/features/configuration/read_options_from_file.feature +42 -26
- data/features/example_groups/basic_structure.feature +55 -0
- data/features/example_groups/shared_context.feature +74 -0
- data/features/example_groups/shared_example_group.feature +56 -41
- data/features/expectation_framework_integration/configure_expectation_framework.feature +73 -0
- data/features/filtering/exclusion_filters.feature +69 -9
- data/features/filtering/if_and_unless.feature +168 -0
- data/features/filtering/inclusion_filters.feature +58 -26
- data/features/filtering/run_all_when_everything_filtered.feature +46 -0
- data/features/formatters/custom_formatter.feature +17 -13
- data/features/formatters/text_formatter.feature +43 -0
- data/features/helper_methods/arbitrary_methods.feature +40 -0
- data/features/helper_methods/let.feature +50 -0
- data/features/helper_methods/modules.feature +149 -0
- data/features/hooks/around_hooks.feature +99 -69
- data/features/hooks/before_and_after_hooks.feature +74 -40
- data/features/hooks/filtering.feature +227 -0
- data/features/metadata/current_example.feature +17 -0
- data/features/metadata/described_class.feature +17 -0
- data/features/metadata/user_defined.feature +111 -0
- data/features/mock_framework_integration/use_any_framework.feature +106 -0
- data/features/mock_framework_integration/use_flexmock.feature +84 -11
- data/features/mock_framework_integration/use_mocha.feature +85 -11
- data/features/mock_framework_integration/use_rr.feature +86 -11
- data/features/mock_framework_integration/use_rspec.feature +85 -11
- data/features/pending/pending_examples.feature +143 -5
- data/features/spec_files/arbitrary_file_suffix.feature +2 -2
- data/features/step_definitions/additional_cli_steps.rb +30 -0
- data/features/subject/attribute_of_subject.feature +93 -15
- data/features/subject/explicit_subject.feature +28 -17
- data/features/subject/implicit_receiver.feature +29 -0
- data/features/subject/implicit_subject.feature +9 -10
- data/features/support/env.rb +6 -1
- data/lib/autotest/discover.rb +1 -0
- data/lib/autotest/rspec2.rb +15 -11
- data/lib/rspec/autorun.rb +2 -0
- data/lib/rspec/core/backward_compatibility.rb +32 -3
- data/lib/rspec/core/command_line.rb +4 -28
- data/lib/rspec/core/command_line_configuration.rb +16 -16
- data/lib/rspec/core/configuration.rb +286 -89
- data/lib/rspec/core/configuration_options.rb +74 -40
- data/lib/rspec/core/deprecation.rb +1 -1
- data/lib/rspec/core/drb_command_line.rb +5 -11
- data/lib/rspec/core/dsl.rb +11 -0
- data/lib/rspec/core/example.rb +63 -39
- data/lib/rspec/core/example_group.rb +109 -59
- data/lib/rspec/core/expecting/with_rspec.rb +9 -0
- data/lib/rspec/core/expecting/with_stdlib.rb +9 -0
- data/lib/rspec/core/extensions/kernel.rb +1 -1
- data/lib/rspec/core/extensions.rb +0 -1
- data/lib/rspec/core/formatters/base_formatter.rb +30 -15
- data/lib/rspec/core/formatters/base_text_formatter.rb +68 -40
- data/lib/rspec/core/formatters/documentation_formatter.rb +4 -2
- data/lib/rspec/core/formatters/helpers.rb +0 -4
- data/lib/rspec/core/formatters/html_formatter.rb +146 -41
- data/lib/rspec/core/formatters/progress_formatter.rb +1 -0
- data/lib/rspec/core/formatters/snippet_extractor.rb +1 -1
- data/lib/rspec/core/formatters/text_mate_formatter.rb +3 -1
- data/lib/rspec/core/hooks.rb +56 -17
- data/lib/rspec/core/metadata.rb +75 -64
- 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 +49 -7
- data/lib/rspec/core/pending.rb +22 -4
- data/lib/rspec/core/rake_task.rb +64 -28
- data/lib/rspec/core/reporter.rb +6 -5
- data/lib/rspec/core/ruby_project.rb +2 -2
- data/lib/rspec/core/runner.rb +50 -6
- data/lib/rspec/core/shared_context.rb +16 -0
- data/lib/rspec/core/shared_example_group.rb +19 -4
- data/lib/rspec/core/subject.rb +92 -65
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +85 -27
- data/lib/rspec/core.rb +55 -24
- data/lib/rspec/monkey/spork/test_framework/rspec.rb +1 -0
- data/rspec-core.gemspec +4 -25
- data/script/FullBuildRakeFile +63 -0
- data/script/cucumber +1 -0
- data/script/full_build +1 -0
- data/script/spec +1 -0
- data/spec/autotest/discover_spec.rb +19 -0
- data/spec/autotest/failed_results_re_spec.rb +25 -9
- data/spec/autotest/rspec_spec.rb +32 -41
- data/spec/rspec/core/command_line_spec.rb +62 -7
- data/spec/rspec/core/configuration_options_spec.rb +216 -148
- data/spec/rspec/core/configuration_spec.rb +419 -108
- data/spec/rspec/core/deprecations_spec.rb +38 -1
- data/spec/rspec/core/drb_command_line_spec.rb +21 -56
- data/spec/rspec/core/example_group_spec.rb +366 -127
- data/spec/rspec/core/example_spec.rb +125 -45
- data/spec/rspec/core/formatters/base_formatter_spec.rb +61 -1
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +134 -97
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +7 -6
- data/spec/rspec/core/formatters/helpers_spec.rb +1 -1
- data/spec/rspec/core/formatters/html_formatted-1.8.6.html +199 -81
- data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +195 -83
- data/spec/rspec/core/formatters/html_formatted-1.8.7.html +199 -81
- data/spec/rspec/core/formatters/html_formatted-1.9.1.html +206 -81
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +206 -61
- data/spec/rspec/core/formatters/html_formatter_spec.rb +17 -9
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +1 -1
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +199 -81
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +195 -81
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +199 -81
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.1.html +206 -81
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +206 -81
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +22 -7
- data/spec/rspec/core/hooks_filtering_spec.rb +128 -5
- data/spec/rspec/core/hooks_spec.rb +90 -4
- data/spec/rspec/core/metadata_spec.rb +176 -163
- data/spec/rspec/core/option_parser_spec.rb +73 -6
- data/spec/rspec/core/pending_example_spec.rb +137 -35
- data/spec/rspec/core/rake_task_spec.rb +62 -29
- data/spec/rspec/core/reporter_spec.rb +20 -4
- data/spec/rspec/core/resources/formatter_specs.rb +25 -1
- data/spec/rspec/core/rspec_matchers_spec.rb +45 -0
- data/spec/rspec/core/runner_spec.rb +60 -10
- data/spec/rspec/core/shared_context_spec.rb +30 -0
- data/spec/rspec/core/shared_example_group_spec.rb +59 -23
- data/spec/rspec/core/subject_spec.rb +136 -0
- data/spec/rspec/core/world_spec.rb +211 -68
- data/spec/rspec/core_spec.rb +28 -0
- data/spec/spec_helper.rb +41 -24
- 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 +100 -170
- data/.treasure_map.rb +0 -23
- data/History.md +0 -30
- data/Upgrade.markdown +0 -150
- data/autotest/discover.rb +0 -2
- data/features/README.markdown +0 -12
- data/features/example_groups/describe_aliases.feature +0 -25
- data/features/example_groups/nested_groups.feature +0 -44
- data/features/hooks/described_class.feature +0 -14
- data/features/hooks/halt.feature +0 -26
- data/lib/rspec/core/around_proxy.rb +0 -14
- data/lib/rspec/core/extensions/object.rb +0 -15
- data/lib/rspec/core/formatters.rb +0 -8
- data/spec/ruby_forker.rb +0 -13
- data/specs.watchr +0 -59
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
Background:
|
|
23
|
+
Given a file named "example_spec.rb" with:
|
|
24
|
+
"""
|
|
25
|
+
describe "something" do
|
|
26
|
+
it "does something that passes" do
|
|
27
|
+
5.should eq(5)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "does something that fails" do
|
|
31
|
+
5.should eq(4)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "does something that is pending", :pending => true do
|
|
35
|
+
5.should be > 3
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
Scenario: progress bar format (default)
|
|
41
|
+
When I run `rspec example_spec.rb`
|
|
42
|
+
Then the output should contain ".F*"
|
|
43
|
+
|
|
44
|
+
Scenario: documentation format
|
|
45
|
+
When I run `rspec example_spec.rb --format documentation`
|
|
46
|
+
Then the output should contain:
|
|
47
|
+
"""
|
|
48
|
+
something
|
|
49
|
+
does something that passes
|
|
50
|
+
does something that fails (FAILED - 1)
|
|
51
|
+
does something that is pending (PENDING: Not Yet Implemented)
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
Scenario: documentation format saved to a file
|
|
55
|
+
When I run `rspec example_spec.rb --format documentation --out rspec.txt`
|
|
56
|
+
Then the file "rspec.txt" should contain:
|
|
57
|
+
"""
|
|
58
|
+
something
|
|
59
|
+
does something that passes
|
|
60
|
+
does something that fails (FAILED - 1)
|
|
61
|
+
does something that is pending (PENDING: Not Yet Implemented)
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
Scenario: multiple formats
|
|
65
|
+
When I run `rspec example_spec.rb --format progress --format documentation --out rspec.txt`
|
|
66
|
+
Then the output should contain ".F*"
|
|
67
|
+
And the file "rspec.txt" should contain:
|
|
68
|
+
"""
|
|
69
|
+
something
|
|
70
|
+
does something that passes
|
|
71
|
+
does something that fails (FAILED - 1)
|
|
72
|
+
does something that is pending (PENDING: Not Yet Implemented)
|
|
73
|
+
"""
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Feature: line number appended to file path
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
To run a single example or group, you can append the line number to the path, e.g.
|
|
4
|
+
|
|
5
|
+
rspec path/to/example_spec.rb:37
|
|
6
6
|
|
|
7
7
|
Background:
|
|
8
8
|
Given a file named "example_spec.rb" with:
|
|
@@ -29,80 +29,78 @@ 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
|
|
33
|
-
Then the
|
|
32
|
+
When I run `rspec example_spec.rb:1 --format doc`
|
|
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
|
|
40
|
-
Then the
|
|
39
|
+
When I run `rspec example_spec.rb:2 --format doc`
|
|
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
|
|
47
|
-
Then the
|
|
46
|
+
When I run `rspec example_spec.rb:11 --format doc`
|
|
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
|
|
54
|
-
Then the
|
|
53
|
+
When I run `rspec example_spec.rb:12 --format doc`
|
|
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
|
|
61
|
-
Then the
|
|
60
|
+
When I run `rspec example_spec.rb:3 --format doc`
|
|
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
|
|
68
|
-
Then the
|
|
67
|
+
When I run `rspec example_spec.rb:4 --format doc`
|
|
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
|
|
75
|
-
Then the
|
|
74
|
+
When I run `rspec example_spec.rb:5 --format doc`
|
|
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
|
|
82
|
-
Then the
|
|
81
|
+
When I run `rspec example_spec.rb:6 --format doc`
|
|
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
|
|
89
|
-
Then the
|
|
88
|
+
When I run `rspec example_spec.rb:7 --format doc`
|
|
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
|
|
96
|
-
Then the
|
|
95
|
+
When I run `rspec example_spec.rb:7 --format doc`
|
|
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
|
|
103
|
-
Then the
|
|
102
|
+
When I run `rspec example_spec.rb:7 --format doc`
|
|
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"
|
|
106
106
|
And the output should not contain "example in nested group"
|
|
107
|
-
|
|
108
|
-
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
Feature:
|
|
1
|
+
Feature: --line_number option
|
|
2
|
+
|
|
3
|
+
To run a single example or group, you can use the --line_number option:
|
|
4
|
+
|
|
5
|
+
rspec path/to/example_spec.rb --line_number 37
|
|
2
6
|
|
|
3
|
-
As an RSpec user
|
|
4
|
-
I want to run one example identified by the line number
|
|
5
|
-
|
|
6
7
|
Scenario: standard examples
|
|
7
8
|
Given a file named "example_spec.rb" with:
|
|
8
9
|
"""
|
|
@@ -20,10 +21,10 @@ Feature: line number option
|
|
|
20
21
|
|
|
21
22
|
end
|
|
22
23
|
"""
|
|
23
|
-
When I run
|
|
24
|
-
Then the
|
|
24
|
+
When I run `rspec example_spec.rb --line_number 5 --format doc`
|
|
25
|
+
Then the examples should all pass
|
|
25
26
|
Then the output should contain "should be > 8"
|
|
26
|
-
But the
|
|
27
|
+
But the output should not contain "should be < 10"
|
|
27
28
|
|
|
28
29
|
Scenario: one liner
|
|
29
30
|
Given a file named "example_spec.rb" with:
|
|
@@ -38,7 +39,7 @@ Feature: line number option
|
|
|
38
39
|
|
|
39
40
|
end
|
|
40
41
|
"""
|
|
41
|
-
When I run
|
|
42
|
-
Then the
|
|
42
|
+
When I run `rspec example_spec.rb --line_number 5 --format doc`
|
|
43
|
+
Then the examples should all pass
|
|
43
44
|
Then the output should contain "should be > 8"
|
|
44
|
-
But the
|
|
45
|
+
But the output should not contain "should be < 10"
|
|
@@ -0,0 +1,68 @@
|
|
|
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 stderr 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
|
+
|
|
@@ -0,0 +1,90 @@
|
|
|
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 "Run filtered including {: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 "Run filtered including {: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
|
+
Run filtered including {: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
|
+
Run filtered including {: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 "Run filtered excluding {: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 "Run filtered excluding {: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
|
+
Run filtered excluding {: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
|
+
Run filtered excluding {: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 "Run filtered including {:focus=>true}, excluding {:skip=>true}"
|
|
90
|
+
And the examples should all pass
|
|
@@ -0,0 +1,48 @@
|
|
|
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,10 +1,8 @@
|
|
|
1
1
|
Feature: custom settings
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
As an RSpec extenstion-library author
|
|
5
|
-
I want to define new settings on the RSpec.configuration object
|
|
3
|
+
Extensions like rspec-rails can add their own configuration settings.
|
|
6
4
|
|
|
7
|
-
Scenario: simple setting
|
|
5
|
+
Scenario: simple setting (with defaults)
|
|
8
6
|
Given a file named "additional_setting_spec.rb" with:
|
|
9
7
|
"""
|
|
10
8
|
RSpec.configure do |c|
|
|
@@ -31,8 +29,8 @@ Feature: custom settings
|
|
|
31
29
|
end
|
|
32
30
|
end
|
|
33
31
|
"""
|
|
34
|
-
When I run
|
|
35
|
-
Then the
|
|
32
|
+
When I run `rspec ./additional_setting_spec.rb`
|
|
33
|
+
Then the examples should all pass
|
|
36
34
|
|
|
37
35
|
Scenario: default to true
|
|
38
36
|
Given a file named "additional_setting_spec.rb" with:
|
|
@@ -57,8 +55,8 @@ Feature: custom settings
|
|
|
57
55
|
end
|
|
58
56
|
end
|
|
59
57
|
"""
|
|
60
|
-
When I run
|
|
61
|
-
Then the
|
|
58
|
+
When I run `rspec ./additional_setting_spec.rb`
|
|
59
|
+
Then the examples should all pass
|
|
62
60
|
|
|
63
61
|
Scenario: overridden in a subsequent RSpec.configure block
|
|
64
62
|
Given a file named "additional_setting_spec.rb" with:
|
|
@@ -81,6 +79,6 @@ Feature: custom settings
|
|
|
81
79
|
end
|
|
82
80
|
end
|
|
83
81
|
"""
|
|
84
|
-
When I run
|
|
85
|
-
Then the
|
|
82
|
+
When I run `rspec ./additional_setting_spec.rb`
|
|
83
|
+
Then the examples should all pass
|
|
86
84
|
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Feature: fail fast
|
|
2
|
+
|
|
3
|
+
Use the fail_fast option to tell RSpec to abort the run on first failure:
|
|
4
|
+
|
|
5
|
+
RSpec.configure {|c| c.fail_fast = true}
|
|
6
|
+
|
|
7
|
+
Background:
|
|
8
|
+
Given a file named "spec/spec_helper.rb" with:
|
|
9
|
+
"""
|
|
10
|
+
RSpec.configure {|c| c.fail_fast = true}
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
Scenario: fail_fast with no failures (runs all examples)
|
|
14
|
+
Given a file named "spec/example_spec.rb" with:
|
|
15
|
+
"""
|
|
16
|
+
describe "something" do
|
|
17
|
+
it "passes" do
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "passes too" do
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
"""
|
|
24
|
+
When I run `rspec spec/example_spec.rb`
|
|
25
|
+
Then the examples should all pass
|
|
26
|
+
|
|
27
|
+
Scenario: fail_fast with first example failing (only runs the one example)
|
|
28
|
+
Given a file named "spec/example_spec.rb" with:
|
|
29
|
+
"""
|
|
30
|
+
require "spec_helper"
|
|
31
|
+
describe "something" do
|
|
32
|
+
it "fails" do
|
|
33
|
+
fail
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "passes" do
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
"""
|
|
40
|
+
When I run `rspec spec/example_spec.rb -fd`
|
|
41
|
+
Then the output should contain "1 example, 1 failure"
|
|
42
|
+
|
|
43
|
+
Scenario: fail_fast with multiple files, second example failing (only runs the first two examples)
|
|
44
|
+
Given a file named "spec/example_1_spec.rb" with:
|
|
45
|
+
"""
|
|
46
|
+
require "spec_helper"
|
|
47
|
+
describe "something" do
|
|
48
|
+
it "passes" do
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "fails" do
|
|
52
|
+
fail
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
describe "something else" do
|
|
57
|
+
it "fails" do
|
|
58
|
+
fail
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
"""
|
|
62
|
+
And a file named "spec/example_2_spec.rb" with:
|
|
63
|
+
"""
|
|
64
|
+
require "spec_helper"
|
|
65
|
+
describe "something" do
|
|
66
|
+
it "passes" do
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe "something else" do
|
|
71
|
+
it "fails" do
|
|
72
|
+
fail
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
"""
|
|
76
|
+
When I run `rspec spec`
|
|
77
|
+
Then the output should contain "2 examples, 1 failure"
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
Feature: read command line configuration options from files
|
|
2
2
|
|
|
3
|
-
RSpec
|
|
4
|
-
|
|
3
|
+
RSpec reads command line configuration options from files in two different
|
|
4
|
+
locations:
|
|
5
5
|
|
|
6
6
|
Local: "./.rspec" (i.e. in the project's root directory)
|
|
7
7
|
Global: "~/.rspec" (i.e. in the user's home directory)
|
|
8
8
|
|
|
9
9
|
Options declared in the local file override those in the global file, while
|
|
10
10
|
those declared in RSpec.configure will override any ".rspec" file.
|
|
11
|
-
|
|
12
|
-
NOTE: For backwards compatibility with rspec-1, you can write command line
|
|
13
|
-
options in a "spec/spec.opts" file and it will be loaded automatically.
|
|
14
|
-
|
|
11
|
+
|
|
15
12
|
Scenario: color set in .rspec
|
|
16
13
|
Given a file named ".rspec" with:
|
|
17
14
|
"""
|
|
@@ -21,39 +18,58 @@ Feature: read command line configuration options from files
|
|
|
21
18
|
"""
|
|
22
19
|
describe "color_enabled" do
|
|
23
20
|
context "when set with RSpec.configure" do
|
|
21
|
+
before do
|
|
22
|
+
# color is disabled for non-tty output, so stub the output stream
|
|
23
|
+
# to say it is tty, even though we're running this with cucumber
|
|
24
|
+
RSpec.configuration.output_stream.stub(:tty?) { true }
|
|
25
|
+
end
|
|
26
|
+
|
|
24
27
|
it "is true" do
|
|
25
28
|
RSpec.configuration.should be_color_enabled
|
|
26
29
|
end
|
|
27
30
|
end
|
|
28
31
|
end
|
|
29
32
|
"""
|
|
30
|
-
When I run
|
|
31
|
-
Then the
|
|
33
|
+
When I run `rspec ./spec/example_spec.rb`
|
|
34
|
+
Then the examples should all pass
|
|
32
35
|
|
|
33
|
-
Scenario:
|
|
34
|
-
Given a file named ".
|
|
36
|
+
Scenario: custom options file
|
|
37
|
+
Given a file named "my.options" with:
|
|
38
|
+
"""
|
|
39
|
+
--format documentation
|
|
40
|
+
"""
|
|
41
|
+
And a file named "spec/example_spec.rb" with:
|
|
42
|
+
"""
|
|
43
|
+
describe "formatter set in custom options file" do
|
|
44
|
+
it "sets formatter" do
|
|
45
|
+
RSpec.configuration.formatters.first.
|
|
46
|
+
should be_a(RSpec::Core::Formatters::DocumentationFormatter)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
35
49
|
"""
|
|
36
|
-
|
|
50
|
+
When I run `rspec spec/example_spec.rb --options my.options`
|
|
51
|
+
Then the examples should all pass
|
|
52
|
+
|
|
53
|
+
Scenario: RSpec ignores ./.rspec when custom options file is used
|
|
54
|
+
Given a file named "my.options" with:
|
|
37
55
|
"""
|
|
38
|
-
|
|
56
|
+
--format documentation
|
|
39
57
|
"""
|
|
40
|
-
|
|
58
|
+
And a file named ".rspec" with:
|
|
59
|
+
"""
|
|
60
|
+
--color
|
|
41
61
|
"""
|
|
42
62
|
And a file named "spec/example_spec.rb" with:
|
|
43
63
|
"""
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
context "when set with RSpec.configure and in spec.opts" do
|
|
48
|
-
it "takes the value set in spec.opts" do
|
|
49
|
-
RSpec.configuration.formatter.should be_an(RSpec::Core::Formatters::DocumentationFormatter)
|
|
50
|
-
end
|
|
64
|
+
describe "custom options file" do
|
|
65
|
+
it "causes .rspec to be ignored" do
|
|
66
|
+
RSpec.configuration.color_enabled.should be_false
|
|
51
67
|
end
|
|
52
68
|
end
|
|
53
69
|
"""
|
|
54
|
-
When I run
|
|
55
|
-
Then the
|
|
56
|
-
|
|
70
|
+
When I run `rspec spec/example_spec.rb --options my.options`
|
|
71
|
+
Then the examples should all pass
|
|
72
|
+
|
|
57
73
|
Scenario: using ERB in .rspec
|
|
58
74
|
Given a file named ".rspec" with:
|
|
59
75
|
"""
|
|
@@ -63,9 +79,9 @@ Feature: read command line configuration options from files
|
|
|
63
79
|
"""
|
|
64
80
|
describe "formatter" do
|
|
65
81
|
it "is set to documentation" do
|
|
66
|
-
RSpec.configuration.
|
|
82
|
+
RSpec.configuration.formatters.first.should be_an(RSpec::Core::Formatters::DocumentationFormatter)
|
|
67
83
|
end
|
|
68
84
|
end
|
|
69
85
|
"""
|
|
70
|
-
When I run
|
|
71
|
-
Then the
|
|
86
|
+
When I run `rspec ./spec/example_spec.rb`
|
|
87
|
+
Then the examples should all pass
|