rspec-core 3.0.0.beta2 → 3.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.yardopts +1 -0
- data/Changelog.md +297 -57
- data/README.md +16 -13
- data/lib/rspec/core.rb +55 -84
- data/lib/rspec/core/backport_random.rb +35 -3
- data/lib/rspec/core/backtrace_formatter.rb +4 -13
- data/lib/rspec/core/configuration.rb +330 -114
- data/lib/rspec/core/configuration_options.rb +38 -22
- data/lib/rspec/core/drb.rb +111 -0
- data/lib/rspec/core/dsl.rb +8 -2
- data/lib/rspec/core/example.rb +203 -94
- data/lib/rspec/core/example_group.rb +344 -316
- data/lib/rspec/core/filter_manager.rb +135 -90
- data/lib/rspec/core/flat_map.rb +1 -0
- data/lib/rspec/core/formatters.rb +50 -14
- data/lib/rspec/core/formatters/base_formatter.rb +32 -138
- data/lib/rspec/core/formatters/base_text_formatter.rb +32 -253
- data/lib/rspec/core/formatters/console_codes.rb +65 -0
- data/lib/rspec/core/formatters/deprecation_formatter.rb +24 -15
- data/lib/rspec/core/formatters/documentation_formatter.rb +7 -10
- data/lib/rspec/core/formatters/helpers.rb +15 -9
- data/lib/rspec/core/formatters/html_formatter.rb +17 -16
- data/lib/rspec/core/formatters/html_printer.rb +1 -0
- data/lib/rspec/core/formatters/json_formatter.rb +18 -20
- data/lib/rspec/core/formatters/profile_formatter.rb +67 -0
- data/lib/rspec/core/formatters/progress_formatter.rb +6 -7
- data/lib/rspec/core/formatters/snippet_extractor.rb +8 -6
- data/lib/rspec/core/hooks.rb +131 -125
- data/lib/rspec/core/memoized_helpers.rb +31 -26
- data/lib/rspec/core/metadata.rb +277 -184
- data/lib/rspec/core/metadata_filter.rb +86 -0
- data/lib/rspec/core/minitest_assertions_adapter.rb +28 -0
- data/lib/rspec/core/mocking_adapters/flexmock.rb +1 -1
- data/lib/rspec/core/mocking_adapters/mocha.rb +1 -1
- data/lib/rspec/core/mocking_adapters/null.rb +1 -1
- data/lib/rspec/core/mocking_adapters/rr.rb +2 -1
- data/lib/rspec/core/mocking_adapters/rspec.rb +1 -1
- data/lib/rspec/core/notifications.rb +435 -24
- data/lib/rspec/core/option_parser.rb +16 -25
- data/lib/rspec/core/ordering.rb +3 -1
- data/lib/rspec/core/pending.rb +57 -33
- data/lib/rspec/core/project_initializer.rb +2 -0
- data/lib/rspec/core/project_initializer/spec_helper.rb +5 -4
- data/lib/rspec/core/rake_task.rb +45 -20
- data/lib/rspec/core/reporter.rb +50 -22
- data/lib/rspec/core/ruby_project.rb +1 -0
- data/lib/rspec/core/runner.rb +93 -39
- data/lib/rspec/core/shared_context.rb +7 -5
- data/lib/rspec/core/shared_example_group.rb +85 -77
- data/lib/rspec/core/test_unit_assertions_adapter.rb +30 -0
- data/lib/rspec/core/version.rb +3 -1
- data/lib/rspec/core/warnings.rb +35 -17
- data/lib/rspec/core/world.rb +57 -5
- metadata +56 -369
- metadata.gz.sig +3 -3
- data/features/README.md +0 -13
- data/features/Upgrade.md +0 -352
- data/features/command_line/README.md +0 -25
- data/features/command_line/dry_run.feature +0 -29
- data/features/command_line/example_name_option.feature +0 -97
- data/features/command_line/exit_status.feature +0 -82
- data/features/command_line/fail_fast.feature +0 -26
- data/features/command_line/format_option.feature +0 -75
- data/features/command_line/init.feature +0 -57
- data/features/command_line/line_number_appended_to_path.feature +0 -140
- data/features/command_line/line_number_option.feature +0 -58
- data/features/command_line/order.feature +0 -25
- data/features/command_line/pattern_option.feature +0 -49
- data/features/command_line/rake_task.feature +0 -122
- data/features/command_line/randomization.feature +0 -63
- data/features/command_line/require_option.feature +0 -43
- data/features/command_line/ruby.feature +0 -23
- data/features/command_line/tag.feature +0 -98
- data/features/command_line/warnings_option.feature +0 -29
- data/features/configuration/alias_example_to.feature +0 -39
- data/features/configuration/backtrace_exclusion_patterns.feature +0 -105
- data/features/configuration/custom_settings.feature +0 -84
- data/features/configuration/default_path.feature +0 -38
- data/features/configuration/deprecation_stream.feature +0 -58
- data/features/configuration/enable_global_dsl.feature +0 -54
- data/features/configuration/fail_fast.feature +0 -77
- data/features/configuration/failure_exit_code.feature +0 -36
- data/features/configuration/order_and_seed.feature +0 -3
- data/features/configuration/output_stream.feature +0 -24
- data/features/configuration/overriding_global_ordering.feature +0 -93
- data/features/configuration/pattern.feature +0 -38
- data/features/configuration/profile.feature +0 -220
- data/features/configuration/read_options_from_file.feature +0 -90
- data/features/configuration/run_all_when_everything_filtered.feature +0 -76
- data/features/example_groups/aliasing.feature +0 -48
- data/features/example_groups/basic_structure.feature +0 -55
- data/features/example_groups/shared_context.feature +0 -74
- data/features/example_groups/shared_examples.feature +0 -286
- data/features/expectation_framework_integration/configure_expectation_framework.feature +0 -102
- data/features/filtering/exclusion_filters.feature +0 -135
- data/features/filtering/if_and_unless.feature +0 -138
- data/features/filtering/inclusion_filters.feature +0 -101
- data/features/formatters/configurable_colors.feature +0 -31
- data/features/formatters/custom_formatter.feature +0 -68
- data/features/formatters/json_formatter.feature +0 -30
- data/features/formatters/regression_tests.feature +0 -95
- data/features/formatters/text_formatter.feature +0 -46
- data/features/helper_methods/arbitrary_methods.feature +0 -40
- data/features/helper_methods/let.feature +0 -50
- data/features/helper_methods/modules.feature +0 -146
- data/features/hooks/around_hooks.feature +0 -344
- data/features/hooks/before_and_after_hooks.feature +0 -427
- data/features/hooks/filtering.feature +0 -232
- data/features/metadata/current_example.feature +0 -56
- data/features/metadata/described_class.feature +0 -17
- data/features/metadata/user_defined.feature +0 -100
- data/features/mock_framework_integration/use_any_framework.feature +0 -106
- data/features/mock_framework_integration/use_flexmock.feature +0 -94
- data/features/mock_framework_integration/use_mocha.feature +0 -95
- data/features/mock_framework_integration/use_rr.feature +0 -96
- data/features/mock_framework_integration/use_rspec.feature +0 -95
- data/features/pending_and_skipped_examples/README.md +0 -3
- data/features/pending_and_skipped_examples/pending_examples.feature +0 -118
- data/features/pending_and_skipped_examples/skipped_examples.feature +0 -106
- data/features/spec_files/arbitrary_file_suffix.feature +0 -13
- data/features/step_definitions/additional_cli_steps.rb +0 -83
- data/features/subject/explicit_subject.feature +0 -101
- data/features/subject/implicit_subject.feature +0 -63
- data/features/subject/one_liner_syntax.feature +0 -71
- data/features/support/env.rb +0 -21
- data/features/support/require_expect_syntax_in_aruba_specs.rb +0 -16
- data/features/support/rubinius.rb +0 -6
- data/lib/rspec/core/command_line.rb +0 -35
- data/lib/rspec/core/drb_command_line.rb +0 -26
- data/lib/rspec/core/drb_options.rb +0 -87
- data/lib/rspec/core/formatters/legacy_formatter.rb +0 -227
- data/lib/rspec/core/shared_example_group/collection.rb +0 -27
- data/spec/command_line/order_spec.rb +0 -211
- data/spec/rspec/core/backtrace_formatter_spec.rb +0 -230
- data/spec/rspec/core/command_line_spec.rb +0 -112
- data/spec/rspec/core/command_line_spec_output.txt +0 -0
- data/spec/rspec/core/configuration_options_spec.rb +0 -409
- data/spec/rspec/core/configuration_spec.rb +0 -1479
- data/spec/rspec/core/drb_command_line_spec.rb +0 -102
- data/spec/rspec/core/drb_options_spec.rb +0 -193
- data/spec/rspec/core/dsl_spec.rb +0 -88
- data/spec/rspec/core/example_group_spec.rb +0 -1533
- data/spec/rspec/core/example_spec.rb +0 -642
- data/spec/rspec/core/filter_manager_spec.rb +0 -229
- data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -64
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +0 -303
- data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +0 -208
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +0 -75
- data/spec/rspec/core/formatters/helpers_spec.rb +0 -104
- data/spec/rspec/core/formatters/html_formatted-2.1.0.html +0 -392
- data/spec/rspec/core/formatters/html_formatted.html +0 -397
- data/spec/rspec/core/formatters/html_formatter_spec.rb +0 -122
- data/spec/rspec/core/formatters/json_formatter_spec.rb +0 -206
- data/spec/rspec/core/formatters/legacy_formatter_spec.rb +0 -137
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -43
- data/spec/rspec/core/formatters/snippet_extractor_spec.rb +0 -26
- data/spec/rspec/core/formatters_spec.rb +0 -120
- data/spec/rspec/core/hooks_filtering_spec.rb +0 -227
- data/spec/rspec/core/hooks_spec.rb +0 -294
- data/spec/rspec/core/memoized_helpers_spec.rb +0 -495
- data/spec/rspec/core/metadata_spec.rb +0 -491
- data/spec/rspec/core/option_parser_spec.rb +0 -262
- data/spec/rspec/core/ordering_spec.rb +0 -102
- data/spec/rspec/core/pending_example_spec.rb +0 -117
- data/spec/rspec/core/pending_spec.rb +0 -8
- data/spec/rspec/core/project_initializer_spec.rb +0 -73
- data/spec/rspec/core/rake_task_spec.rb +0 -146
- data/spec/rspec/core/random_spec.rb +0 -47
- data/spec/rspec/core/reporter_spec.rb +0 -155
- data/spec/rspec/core/resources/a_bar.rb +0 -0
- data/spec/rspec/core/resources/a_foo.rb +0 -0
- data/spec/rspec/core/resources/a_spec.rb +0 -1
- data/spec/rspec/core/resources/custom_example_group_runner.rb +0 -14
- data/spec/rspec/core/resources/formatter_specs.rb +0 -58
- data/spec/rspec/core/resources/utf8_encoded.rb +0 -8
- data/spec/rspec/core/rspec_matchers_spec.rb +0 -45
- data/spec/rspec/core/ruby_project_spec.rb +0 -26
- data/spec/rspec/core/runner_spec.rb +0 -151
- data/spec/rspec/core/shared_context_spec.rb +0 -102
- data/spec/rspec/core/shared_example_group/collection_spec.rb +0 -57
- data/spec/rspec/core/shared_example_group_spec.rb +0 -114
- data/spec/rspec/core/warnings_spec.rb +0 -29
- data/spec/rspec/core/world_spec.rb +0 -142
- data/spec/rspec/core_spec.rb +0 -91
- data/spec/spec_helper.rb +0 -160
- data/spec/support/config_options_helper.rb +0 -13
- data/spec/support/formatter_support.rb +0 -83
- data/spec/support/helper_methods.rb +0 -26
- data/spec/support/isolate_load_path_mutation.rb +0 -5
- data/spec/support/isolated_directory.rb +0 -10
- data/spec/support/isolated_home_directory.rb +0 -16
- data/spec/support/legacy_formatter_using_sub_classing_example.rb +0 -87
- data/spec/support/matchers.rb +0 -85
- data/spec/support/mathn_integration_support.rb +0 -12
- data/spec/support/old_style_formatter_example.rb +0 -69
- data/spec/support/shared_example_groups.rb +0 -13
- data/spec/support/spec_files.rb +0 -44
- data/spec/support/stderr_splitter.rb +0 -36
@@ -1,24 +0,0 @@
|
|
1
|
-
Feature: output_stream
|
2
|
-
|
3
|
-
Define a custom output stream (default `$stdout`). Aliases: `:output`, `:out`.
|
4
|
-
|
5
|
-
RSpec.configure { |c| c.output_stream = File.open('saved_output', 'w') }
|
6
|
-
|
7
|
-
Background:
|
8
|
-
Given a file named "spec/spec_helper.rb" with:
|
9
|
-
"""ruby
|
10
|
-
RSpec.configure {|c| c.output_stream = File.open('saved_output', 'w') }
|
11
|
-
"""
|
12
|
-
|
13
|
-
Scenario: redirecting output
|
14
|
-
Given a file named "spec/example_spec.rb" with:
|
15
|
-
"""ruby
|
16
|
-
require 'spec_helper'
|
17
|
-
describe "an example" do
|
18
|
-
it "passes" do
|
19
|
-
true
|
20
|
-
end
|
21
|
-
end
|
22
|
-
"""
|
23
|
-
When I run `rspec spec/example_spec.rb`
|
24
|
-
Then the file "saved_output" should contain "1 example, 0 failures"
|
@@ -1,93 +0,0 @@
|
|
1
|
-
Feature: Overriding global ordering
|
2
|
-
|
3
|
-
You can customize how RSpec orders examples and example groups.
|
4
|
-
For an individual group, you can control it by tagging it with
|
5
|
-
`:order` metadata:
|
6
|
-
|
7
|
-
* `:defined` runs the examples (and sub groups) in defined order.
|
8
|
-
* `:random` runs them in random order.
|
9
|
-
|
10
|
-
If you have more specialized needs, you can register your own ordering
|
11
|
-
using the `register_ordering` configuration option. If you register
|
12
|
-
an ordering as `:global`, it will be the global default, used by all
|
13
|
-
groups that do not have `:order` metadata (and by RSpec to order the
|
14
|
-
top-level groups).
|
15
|
-
|
16
|
-
Scenario: running a specific examples group in order
|
17
|
-
Given a file named "order_dependent_spec.rb" with:
|
18
|
-
"""ruby
|
19
|
-
describe "examples only pass when they are run in order", :order => :defined do
|
20
|
-
before(:all) { @list = [] }
|
21
|
-
|
22
|
-
it "passes when run first" do
|
23
|
-
@list << 1
|
24
|
-
expect(@list).to eq([1])
|
25
|
-
end
|
26
|
-
|
27
|
-
it "passes when run second" do
|
28
|
-
@list << 2
|
29
|
-
expect(@list).to eq([1, 2])
|
30
|
-
end
|
31
|
-
|
32
|
-
it "passes when run third" do
|
33
|
-
@list << 3
|
34
|
-
expect(@list).to eq([1, 2, 3])
|
35
|
-
end
|
36
|
-
end
|
37
|
-
"""
|
38
|
-
|
39
|
-
When I run `rspec order_dependent_spec.rb --order random:1`
|
40
|
-
Then the examples should all pass
|
41
|
-
|
42
|
-
Scenario: Registering a custom ordering
|
43
|
-
Given a file named "register_custom_ordering_spec.rb" with:
|
44
|
-
"""ruby
|
45
|
-
RSpec.configure do |rspec|
|
46
|
-
rspec.register_ordering(:reverse) do |items|
|
47
|
-
items.reverse
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "A group that must run in reverse order", :order => :reverse do
|
52
|
-
before(:all) { @list = [] }
|
53
|
-
|
54
|
-
it "passes when run second" do
|
55
|
-
@list << 2
|
56
|
-
expect(@list).to eq([1, 2])
|
57
|
-
end
|
58
|
-
|
59
|
-
it "passes when run first" do
|
60
|
-
@list << 1
|
61
|
-
expect(@list).to eq([1])
|
62
|
-
end
|
63
|
-
end
|
64
|
-
"""
|
65
|
-
When I run `rspec register_custom_ordering_spec.rb`
|
66
|
-
Then the examples should all pass
|
67
|
-
|
68
|
-
Scenario: Using a custom global ordering
|
69
|
-
Given a file named "register_global_ordering_spec.rb" with:
|
70
|
-
"""ruby
|
71
|
-
RSpec.configure do |rspec|
|
72
|
-
rspec.register_ordering(:global) do |items|
|
73
|
-
items.reverse
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe "A group without :order metadata" do
|
78
|
-
before(:all) { @list = [] }
|
79
|
-
|
80
|
-
it "passes when run second" do
|
81
|
-
@list << 2
|
82
|
-
expect(@list).to eq([1, 2])
|
83
|
-
end
|
84
|
-
|
85
|
-
it "passes when run first" do
|
86
|
-
@list << 1
|
87
|
-
expect(@list).to eq([1])
|
88
|
-
end
|
89
|
-
end
|
90
|
-
"""
|
91
|
-
When I run `rspec register_global_ordering_spec.rb`
|
92
|
-
Then the examples should all pass
|
93
|
-
|
@@ -1,38 +0,0 @@
|
|
1
|
-
Feature: pattern
|
2
|
-
|
3
|
-
Use the pattern option to tell RSpec to look for specs in files that match a pattern other than "**/*_spec.rb".
|
4
|
-
|
5
|
-
Background:
|
6
|
-
Given a file named "spec/example_spec.rb" with:
|
7
|
-
"""ruby
|
8
|
-
describe "two specs here" do
|
9
|
-
it "passes" do
|
10
|
-
end
|
11
|
-
|
12
|
-
it "passes too" do
|
13
|
-
end
|
14
|
-
end
|
15
|
-
"""
|
16
|
-
And a file named "spec/example_test.rb" with:
|
17
|
-
"""ruby
|
18
|
-
describe "only one spec" do
|
19
|
-
it "passes" do
|
20
|
-
end
|
21
|
-
end
|
22
|
-
"""
|
23
|
-
|
24
|
-
Scenario: by default, RSpec runs files that match "**/*_spec.rb"
|
25
|
-
When I run `rspec`
|
26
|
-
Then the output should contain "2 examples, 0 failures"
|
27
|
-
|
28
|
-
Scenario: the --pattern flag makes RSpec run files matching the specified pattern and ignore the default pattern
|
29
|
-
When I run `rspec -P "**/*_test.rb"`
|
30
|
-
Then the output should contain "1 example, 0 failures"
|
31
|
-
|
32
|
-
Scenario: the --pattern flag can be used to pass in multiple patterns, separated by comma
|
33
|
-
When I run `rspec -P "**/*_test.rb,**/*_spec.rb"`
|
34
|
-
Then the output should contain "3 examples, 0 failures"
|
35
|
-
|
36
|
-
Scenario: the --pattern flag accepts shell style glob unions
|
37
|
-
When I run `rspec -P "**/*_{test,spec}.rb"`
|
38
|
-
Then the output should contain "3 examples, 0 failures"
|
@@ -1,220 +0,0 @@
|
|
1
|
-
Feature: Profile examples
|
2
|
-
|
3
|
-
The `--profile` command line option (available from `RSpec.configure` as
|
4
|
-
`#profile_examples`), when set, will cause RSpec to dump out a list of
|
5
|
-
your slowest examples. By default, it prints the 10 slowest examples,
|
6
|
-
but you can set it to a different value to have it print more or fewer
|
7
|
-
slow examples. If `--fail-fast` option is used together with `--profile`
|
8
|
-
and there is a failure, slow examples are not shown.
|
9
|
-
|
10
|
-
Background:
|
11
|
-
Given a file named "spec/spec_helper.rb" with:
|
12
|
-
"""ruby
|
13
|
-
"""
|
14
|
-
And a file named "spec/example_spec.rb" with:
|
15
|
-
"""ruby
|
16
|
-
require "spec_helper"
|
17
|
-
|
18
|
-
describe "something" do
|
19
|
-
it "sleeps for 0.1 seconds (example 1)" do
|
20
|
-
sleep 0.1
|
21
|
-
expect(1).to eq(1)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "sleeps for 0 seconds (example 2)" do
|
25
|
-
expect(2).to eq(2)
|
26
|
-
end
|
27
|
-
|
28
|
-
it "sleeps for 0.15 seconds (example 3)" do
|
29
|
-
sleep 0.15
|
30
|
-
expect(3).to eq(3)
|
31
|
-
end
|
32
|
-
|
33
|
-
it "sleeps for 0.05 seconds (example 4)" do
|
34
|
-
sleep 0.05
|
35
|
-
expect(4).to eq(4)
|
36
|
-
end
|
37
|
-
|
38
|
-
it "sleeps for 0.05 seconds (example 5)" do
|
39
|
-
sleep 0.05
|
40
|
-
expect(5).to eq(5)
|
41
|
-
end
|
42
|
-
|
43
|
-
it "sleeps for 0.05 seconds (example 6)" do
|
44
|
-
sleep 0.05
|
45
|
-
expect(6).to eq(6)
|
46
|
-
end
|
47
|
-
|
48
|
-
it "sleeps for 0.05 seconds (example 7)" do
|
49
|
-
sleep 0.05
|
50
|
-
expect(7).to eq(7)
|
51
|
-
end
|
52
|
-
|
53
|
-
it "sleeps for 0.05 seconds (example 8)" do
|
54
|
-
sleep 0.05
|
55
|
-
expect(8).to eq(8)
|
56
|
-
end
|
57
|
-
|
58
|
-
it "sleeps for 0.05 seconds (example 9)" do
|
59
|
-
sleep 0.05
|
60
|
-
expect(9).to eq(9)
|
61
|
-
end
|
62
|
-
|
63
|
-
it "sleeps for 0.05 seconds (example 10)" do
|
64
|
-
sleep 0.05
|
65
|
-
expect(10).to eq(10)
|
66
|
-
end
|
67
|
-
|
68
|
-
it "sleeps for 0.05 seconds (example 11)" do
|
69
|
-
sleep 0.05
|
70
|
-
expect(11).to eq(11)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
"""
|
74
|
-
|
75
|
-
Scenario: by default does not show profile
|
76
|
-
When I run `rspec spec`
|
77
|
-
Then the examples should all pass
|
78
|
-
And the output should not contain "example 1"
|
79
|
-
And the output should not contain "example 2"
|
80
|
-
And the output should not contain "example 3"
|
81
|
-
And the output should not contain "example 4"
|
82
|
-
And the output should not contain "example 5"
|
83
|
-
And the output should not contain "example 6"
|
84
|
-
And the output should not contain "example 7"
|
85
|
-
And the output should not contain "example 8"
|
86
|
-
And the output should not contain "example 9"
|
87
|
-
And the output should not contain "example 10"
|
88
|
-
And the output should not contain "example 11"
|
89
|
-
|
90
|
-
Scenario: setting `profile_examples` to true shows 10 examples
|
91
|
-
Given a file named "spec/spec_helper.rb" with:
|
92
|
-
"""ruby
|
93
|
-
RSpec.configure { |c| c.profile_examples = true }
|
94
|
-
"""
|
95
|
-
When I run `rspec spec`
|
96
|
-
Then the examples should all pass
|
97
|
-
And the output should contain "Top 10 slowest examples"
|
98
|
-
And the output should contain "example 1"
|
99
|
-
And the output should not contain "example 2"
|
100
|
-
And the output should contain "example 3"
|
101
|
-
And the output should contain "example 4"
|
102
|
-
And the output should contain "example 5"
|
103
|
-
And the output should contain "example 6"
|
104
|
-
And the output should contain "example 7"
|
105
|
-
And the output should contain "example 8"
|
106
|
-
And the output should contain "example 9"
|
107
|
-
And the output should contain "example 10"
|
108
|
-
And the output should contain "example 11"
|
109
|
-
|
110
|
-
Scenario: setting `profile_examples` to 2 shows 2 examples
|
111
|
-
Given a file named "spec/spec_helper.rb" with:
|
112
|
-
"""ruby
|
113
|
-
RSpec.configure { |c| c.profile_examples = 2 }
|
114
|
-
"""
|
115
|
-
When I run `rspec spec`
|
116
|
-
Then the examples should all pass
|
117
|
-
And the output should contain "Top 2 slowest examples"
|
118
|
-
And the output should contain "example 1"
|
119
|
-
And the output should not contain "example 2"
|
120
|
-
And the output should contain "example 3"
|
121
|
-
And the output should not contain "example 4"
|
122
|
-
And the output should not contain "example 5"
|
123
|
-
And the output should not contain "example 6"
|
124
|
-
And the output should not contain "example 7"
|
125
|
-
And the output should not contain "example 8"
|
126
|
-
And the output should not contain "example 9"
|
127
|
-
And the output should not contain "example 10"
|
128
|
-
And the output should not contain "example 11"
|
129
|
-
|
130
|
-
Scenario: setting profile examples through CLI
|
131
|
-
When I run `rspec spec --profile 2`
|
132
|
-
Then the examples should all pass
|
133
|
-
And the output should contain "Top 2 slowest examples"
|
134
|
-
And the output should contain "example 1"
|
135
|
-
And the output should not contain "example 2"
|
136
|
-
And the output should contain "example 3"
|
137
|
-
And the output should not contain "example 4"
|
138
|
-
And the output should not contain "example 5"
|
139
|
-
And the output should not contain "example 6"
|
140
|
-
And the output should not contain "example 7"
|
141
|
-
And the output should not contain "example 8"
|
142
|
-
And the output should not contain "example 9"
|
143
|
-
And the output should not contain "example 10"
|
144
|
-
And the output should not contain "example 11"
|
145
|
-
|
146
|
-
Scenario: Using `--no-profile` overrules config options
|
147
|
-
Given a file named "spec/spec_helper.rb" with:
|
148
|
-
"""ruby
|
149
|
-
RSpec.configure { |c| c.profile_examples = true }
|
150
|
-
"""
|
151
|
-
When I run `rspec spec --no-profile`
|
152
|
-
Then the examples should all pass
|
153
|
-
And the output should not contain "example 1"
|
154
|
-
And the output should not contain "example 2"
|
155
|
-
And the output should not contain "example 3"
|
156
|
-
And the output should not contain "example 4"
|
157
|
-
And the output should not contain "example 5"
|
158
|
-
And the output should not contain "example 6"
|
159
|
-
And the output should not contain "example 7"
|
160
|
-
And the output should not contain "example 8"
|
161
|
-
And the output should not contain "example 9"
|
162
|
-
And the output should not contain "example 10"
|
163
|
-
And the output should not contain "example 11"
|
164
|
-
|
165
|
-
Scenario: Using `--profile` with `--fail-fast` shows slow examples if everything passes
|
166
|
-
When I run `rspec spec --fail-fast --profile`
|
167
|
-
Then the examples should all pass
|
168
|
-
And the output should contain "Top 10 slowest examples"
|
169
|
-
And the output should contain "example 1"
|
170
|
-
And the output should not contain "example 2"
|
171
|
-
And the output should contain "example 3"
|
172
|
-
And the output should contain "example 4"
|
173
|
-
And the output should contain "example 5"
|
174
|
-
And the output should contain "example 6"
|
175
|
-
And the output should contain "example 7"
|
176
|
-
And the output should contain "example 8"
|
177
|
-
And the output should contain "example 9"
|
178
|
-
And the output should contain "example 10"
|
179
|
-
And the output should contain "example 11"
|
180
|
-
|
181
|
-
Scenario: Using `--profile` shows slow examples even in case of failures
|
182
|
-
Given a file named "spec/example_spec.rb" with:
|
183
|
-
"""ruby
|
184
|
-
require "spec_helper"
|
185
|
-
|
186
|
-
describe "something" do
|
187
|
-
it "sleeps for 0.1 seconds (example 1)" do
|
188
|
-
sleep 0.1
|
189
|
-
expect(1).to eq(1)
|
190
|
-
end
|
191
|
-
|
192
|
-
it "fails" do
|
193
|
-
fail
|
194
|
-
end
|
195
|
-
end
|
196
|
-
"""
|
197
|
-
When I run `rspec spec --profile`
|
198
|
-
Then the output should contain "2 examples, 1 failure"
|
199
|
-
And the output should contain "Top 2 slowest examples"
|
200
|
-
And the output should contain "example 1"
|
201
|
-
|
202
|
-
Scenario: Using `--profile` with `--fail-fast` doesn't show slow examples in case of failures
|
203
|
-
Given a file named "spec/example_spec.rb" with:
|
204
|
-
"""ruby
|
205
|
-
require "spec_helper"
|
206
|
-
|
207
|
-
describe "something" do
|
208
|
-
it "sleeps for 0.1 seconds (example 1)" do
|
209
|
-
sleep 0.1
|
210
|
-
expect(1).to eq(1)
|
211
|
-
end
|
212
|
-
|
213
|
-
it "fails" do
|
214
|
-
fail
|
215
|
-
end
|
216
|
-
end
|
217
|
-
"""
|
218
|
-
When I run `rspec spec --fail-fast --profile`
|
219
|
-
Then the output should not contain "Top 2 slowest examples"
|
220
|
-
And the output should not contain "example 1"
|
@@ -1,90 +0,0 @@
|
|
1
|
-
Feature: read command line configuration options from files
|
2
|
-
|
3
|
-
RSpec reads command line configuration options from files in two different
|
4
|
-
locations:
|
5
|
-
|
6
|
-
Local: `./.rspec-local` (i.e. in the project's root directory, can be gitignored)
|
7
|
-
Project: `./.rspec` (i.e. in the project's root directory, usually checked into the project)
|
8
|
-
Global: `~/.rspec` (i.e. in the user's home directory)
|
9
|
-
|
10
|
-
Configuration options are loaded from `~/.rspec`, `.rspec`,
|
11
|
-
`.rspec-local`, command line switches, and the `SPEC_OPTS` environment
|
12
|
-
variable (listed in lowest to highest precedence; for example, an option
|
13
|
-
in `~/.rspec` can be overridden by an option in `.rspec-local`).
|
14
|
-
|
15
|
-
Scenario: color set in .rspec
|
16
|
-
Given a file named ".rspec" with:
|
17
|
-
"""
|
18
|
-
--color
|
19
|
-
"""
|
20
|
-
And a file named "spec/example_spec.rb" with:
|
21
|
-
"""ruby
|
22
|
-
describe "color_enabled" do
|
23
|
-
context "when set with RSpec.configure" do
|
24
|
-
before do
|
25
|
-
# color is disabled for non-tty output, so stub the output stream
|
26
|
-
# to say it is tty, even though we're running this with cucumber
|
27
|
-
allow(RSpec.configuration.output_stream).to receive(:tty?) { true }
|
28
|
-
end
|
29
|
-
|
30
|
-
it "is true" do
|
31
|
-
expect(RSpec.configuration).to be_color_enabled
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
"""
|
36
|
-
When I run `rspec ./spec/example_spec.rb`
|
37
|
-
Then the examples should all pass
|
38
|
-
|
39
|
-
Scenario: custom options file
|
40
|
-
Given a file named "my.options" with:
|
41
|
-
"""
|
42
|
-
--format documentation
|
43
|
-
"""
|
44
|
-
And a file named "spec/example_spec.rb" with:
|
45
|
-
"""ruby
|
46
|
-
describe "formatter set in custom options file" do
|
47
|
-
it "sets formatter" do
|
48
|
-
expect(RSpec.configuration.formatters.first).
|
49
|
-
to be_a(RSpec::Core::Formatters::DocumentationFormatter)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
"""
|
53
|
-
When I run `rspec spec/example_spec.rb --options my.options`
|
54
|
-
Then the examples should all pass
|
55
|
-
|
56
|
-
Scenario: RSpec ignores ./.rspec when custom options file is used
|
57
|
-
Given a file named "my.options" with:
|
58
|
-
"""
|
59
|
-
--format documentation
|
60
|
-
"""
|
61
|
-
And a file named ".rspec" with:
|
62
|
-
"""
|
63
|
-
--color
|
64
|
-
"""
|
65
|
-
And a file named "spec/example_spec.rb" with:
|
66
|
-
"""ruby
|
67
|
-
describe "custom options file" do
|
68
|
-
it "causes .rspec to be ignored" do
|
69
|
-
expect(RSpec.configuration.color_enabled).to be_falsey
|
70
|
-
end
|
71
|
-
end
|
72
|
-
"""
|
73
|
-
When I run `rspec spec/example_spec.rb --options my.options`
|
74
|
-
Then the examples should all pass
|
75
|
-
|
76
|
-
Scenario: using ERB in .rspec
|
77
|
-
Given a file named ".rspec" with:
|
78
|
-
"""
|
79
|
-
--format <%= true ? 'documentation' : 'progress' %>
|
80
|
-
"""
|
81
|
-
And a file named "spec/example_spec.rb" with:
|
82
|
-
"""ruby
|
83
|
-
describe "formatter" do
|
84
|
-
it "is set to documentation" do
|
85
|
-
expect(RSpec.configuration.formatters.first).to be_an(RSpec::Core::Formatters::DocumentationFormatter)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
"""
|
89
|
-
When I run `rspec ./spec/example_spec.rb`
|
90
|
-
Then the examples should all pass
|