rspec-core 3.0.0.beta2 → 3.0.0.rc1
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.
- 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,105 +0,0 @@
|
|
1
|
-
Feature: Excluding lines from the backtrace
|
2
|
-
|
3
|
-
To reduce the noise when diagnosing , RSpec excludes matching lines from
|
4
|
-
backtraces. The default exclusion patterns are:
|
5
|
-
|
6
|
-
/\/lib\d*\/ruby\//,
|
7
|
-
/org\/jruby\//,
|
8
|
-
/bin\//,
|
9
|
-
/gems/,
|
10
|
-
/spec\/spec_helper\.rb/,
|
11
|
-
/lib\/rspec\/(core|expectations|matchers|mocks)/
|
12
|
-
|
13
|
-
This list can be modified or replaced with the `backtrace_exclusion_patterns`
|
14
|
-
option. Additionally, rspec can be run with the `--backtrace` option to skip
|
15
|
-
backtrace cleaning entirely.
|
16
|
-
|
17
|
-
Scenario: using default backtrace_exclusion_patterns
|
18
|
-
Given a file named "spec/failing_spec.rb" with:
|
19
|
-
"""ruby
|
20
|
-
describe "2 + 2" do
|
21
|
-
it "is 5" do
|
22
|
-
expect(2+2).to eq(5)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
"""
|
26
|
-
When I run `rspec`
|
27
|
-
Then the output should contain "1 example, 1 failure"
|
28
|
-
And the output should not contain "lib/rspec/expectations"
|
29
|
-
|
30
|
-
Scenario: replacing backtrace_exclusion_patterns
|
31
|
-
Given a file named "spec/spec_helper.rb" with:
|
32
|
-
"""ruby
|
33
|
-
RSpec.configure do |config|
|
34
|
-
config.backtrace_exclusion_patterns = [
|
35
|
-
/spec_helper/
|
36
|
-
]
|
37
|
-
end
|
38
|
-
|
39
|
-
def foo
|
40
|
-
"bar"
|
41
|
-
end
|
42
|
-
"""
|
43
|
-
And a file named "spec/example_spec.rb" with:
|
44
|
-
"""ruby
|
45
|
-
require 'spec_helper'
|
46
|
-
describe "foo" do
|
47
|
-
it "returns baz" do
|
48
|
-
expect(foo).to eq("baz")
|
49
|
-
end
|
50
|
-
end
|
51
|
-
"""
|
52
|
-
When I run `rspec`
|
53
|
-
Then the output should contain "1 example, 1 failure"
|
54
|
-
And the output should contain "lib/rspec/expectations"
|
55
|
-
|
56
|
-
Scenario: appending to backtrace_exclusion_patterns
|
57
|
-
Given a file named "spec/matchers/be_baz_matcher.rb" with:
|
58
|
-
"""ruby
|
59
|
-
RSpec::Matchers.define :be_baz do |_|
|
60
|
-
match do |actual|
|
61
|
-
actual == "baz"
|
62
|
-
end
|
63
|
-
end
|
64
|
-
"""
|
65
|
-
And a file named "spec/example_spec.rb" with:
|
66
|
-
"""ruby
|
67
|
-
RSpec.configure do |config|
|
68
|
-
config.backtrace_exclusion_patterns << /be_baz_matcher/
|
69
|
-
end
|
70
|
-
|
71
|
-
describe "bar" do
|
72
|
-
it "is baz" do
|
73
|
-
expect("bar").to be_baz
|
74
|
-
end
|
75
|
-
end
|
76
|
-
"""
|
77
|
-
When I run `rspec`
|
78
|
-
Then the output should contain "1 example, 1 failure"
|
79
|
-
But the output should not contain "be_baz_matcher"
|
80
|
-
And the output should not contain "lib/rspec/expectations"
|
81
|
-
|
82
|
-
Scenario: running rspec with the --backtrace option
|
83
|
-
Given a file named "spec/matchers/be_baz_matcher.rb" with:
|
84
|
-
"""ruby
|
85
|
-
RSpec::Matchers.define :be_baz do |_|
|
86
|
-
match do |actual|
|
87
|
-
actual == "baz"
|
88
|
-
end
|
89
|
-
end
|
90
|
-
"""
|
91
|
-
And a file named "spec/example_spec.rb" with:
|
92
|
-
"""ruby
|
93
|
-
RSpec.configure do |config|
|
94
|
-
config.backtrace_exclusion_patterns << /be_baz_matcher/
|
95
|
-
end
|
96
|
-
|
97
|
-
describe "bar" do
|
98
|
-
it "is baz" do
|
99
|
-
expect("bar").to be_baz
|
100
|
-
end
|
101
|
-
end
|
102
|
-
"""
|
103
|
-
When I run `rspec --backtrace`
|
104
|
-
Then the output should contain "1 example, 1 failure"
|
105
|
-
And the output should not contain "be_baz_matcher"
|
@@ -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
|
-
"""ruby
|
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
|
-
expect(RSpec.configuration.custom_setting).to be_nil
|
15
|
-
end
|
16
|
-
|
17
|
-
it "acts false by default" do
|
18
|
-
expect(RSpec.configuration.custom_setting).to be_falsey
|
19
|
-
end
|
20
|
-
|
21
|
-
it "is exposed as a predicate" do
|
22
|
-
expect(RSpec.configuration.custom_setting?).to be_falsey
|
23
|
-
end
|
24
|
-
|
25
|
-
it "can be overridden" do
|
26
|
-
RSpec.configuration.custom_setting = true
|
27
|
-
expect(RSpec.configuration.custom_setting).to be_truthy
|
28
|
-
expect(RSpec.configuration.custom_setting?).to be_truthy
|
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
|
-
"""ruby
|
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
|
-
expect(RSpec.configuration.custom_setting).to be_truthy
|
45
|
-
end
|
46
|
-
|
47
|
-
it "is exposed as a predicate" do
|
48
|
-
expect(RSpec.configuration.custom_setting?).to be_truthy
|
49
|
-
end
|
50
|
-
|
51
|
-
it "can be overridden" do
|
52
|
-
RSpec.configuration.custom_setting = false
|
53
|
-
expect(RSpec.configuration.custom_setting).to be_falsey
|
54
|
-
expect(RSpec.configuration.custom_setting?).to be_falsey
|
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
|
-
"""ruby
|
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
|
-
expect(RSpec.configuration.custom_setting).to be_truthy
|
75
|
-
end
|
76
|
-
|
77
|
-
it "is exposed as a predicate" do
|
78
|
-
expect(RSpec.configuration.custom_setting?).to be_truthy
|
79
|
-
end
|
80
|
-
end
|
81
|
-
"""
|
82
|
-
When I run `rspec ./additional_setting_spec.rb`
|
83
|
-
Then the examples should all pass
|
84
|
-
|
@@ -1,38 +0,0 @@
|
|
1
|
-
Feature: default_path
|
2
|
-
|
3
|
-
As of rspec-2.7, you can just type `rspec` to run all specs that live
|
4
|
-
in the `spec` directory.
|
5
|
-
|
6
|
-
This is supported by a `--default_path` option, which is set to `spec` by
|
7
|
-
default. If you prefer to keep your specs in a different directory, or assign
|
8
|
-
an individual file to `--default_path`, you can do so on the command line or
|
9
|
-
in a configuration file (`.rspec`, `~/.rspec`, or a custom file).
|
10
|
-
|
11
|
-
NOTE: this option is not supported on `RSpec.configuration`, as it needs to
|
12
|
-
be set before spec files are loaded.
|
13
|
-
|
14
|
-
Scenario: run `rspec` with default default_path (`spec` directory)
|
15
|
-
Given a file named "spec/example_spec.rb" with:
|
16
|
-
"""ruby
|
17
|
-
describe "an example" do
|
18
|
-
it "passes" do
|
19
|
-
end
|
20
|
-
end
|
21
|
-
"""
|
22
|
-
When I run `rspec`
|
23
|
-
Then the output should contain "1 example, 0 failures"
|
24
|
-
|
25
|
-
Scenario: run `rspec` with customized default_path
|
26
|
-
Given a file named ".rspec" with:
|
27
|
-
"""
|
28
|
-
--default_path behavior
|
29
|
-
"""
|
30
|
-
Given a file named "behavior/example_spec.rb" with:
|
31
|
-
"""ruby
|
32
|
-
describe "an example" do
|
33
|
-
it "passes" do
|
34
|
-
end
|
35
|
-
end
|
36
|
-
"""
|
37
|
-
When I run `rspec`
|
38
|
-
Then the output should contain "1 example, 0 failures"
|
@@ -1,58 +0,0 @@
|
|
1
|
-
Feature: deprecation_stream
|
2
|
-
|
3
|
-
Define a custom output stream for warning about deprecations (default `$stderr`).
|
4
|
-
|
5
|
-
RSpec.configure {|c| c.deprecation_stream = File.open('deprecations.txt', 'w') }
|
6
|
-
|
7
|
-
or
|
8
|
-
|
9
|
-
RSpec.configure {|c| c.deprecation_stream = 'deprecations.txt' }
|
10
|
-
|
11
|
-
Background:
|
12
|
-
Given a file named "lib/foo.rb" with:
|
13
|
-
"""ruby
|
14
|
-
class Foo
|
15
|
-
def bar
|
16
|
-
RSpec.deprecate "Foo#bar"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
"""
|
20
|
-
|
21
|
-
Scenario: default - print deprecations to $stderr
|
22
|
-
Given a file named "spec/example_spec.rb" with:
|
23
|
-
"""ruby
|
24
|
-
require "foo"
|
25
|
-
describe "calling a deprecated method" do
|
26
|
-
example { Foo.new.bar }
|
27
|
-
end
|
28
|
-
"""
|
29
|
-
When I run `rspec spec/example_spec.rb`
|
30
|
-
Then the output should contain "Deprecation Warnings:\n\nFoo#bar is deprecated"
|
31
|
-
|
32
|
-
Scenario: configure using the path to a file
|
33
|
-
Given a file named "spec/example_spec.rb" with:
|
34
|
-
"""ruby
|
35
|
-
require "foo"
|
36
|
-
RSpec.configure {|c| c.deprecation_stream = 'deprecations.txt' }
|
37
|
-
describe "calling a deprecated method" do
|
38
|
-
example { Foo.new.bar }
|
39
|
-
end
|
40
|
-
"""
|
41
|
-
When I run `rspec spec/example_spec.rb`
|
42
|
-
Then the output should not contain "Deprecation Warnings:"
|
43
|
-
But the output should contain "1 deprecation logged to deprecations.txt"
|
44
|
-
And the file "deprecations.txt" should contain "Foo#bar is deprecated"
|
45
|
-
|
46
|
-
Scenario: configure using a File object
|
47
|
-
Given a file named "spec/example_spec.rb" with:
|
48
|
-
"""ruby
|
49
|
-
require "foo"
|
50
|
-
RSpec.configure {|c| c.deprecation_stream = File.open('deprecations.txt', 'w') }
|
51
|
-
describe "calling a deprecated method" do
|
52
|
-
example { Foo.new.bar }
|
53
|
-
end
|
54
|
-
"""
|
55
|
-
When I run `rspec spec/example_spec.rb`
|
56
|
-
Then the output should not contain "Deprecation Warnings:"
|
57
|
-
But the output should contain "1 deprecation logged to deprecations.txt"
|
58
|
-
And the file "deprecations.txt" should contain "Foo#bar is deprecated"
|
@@ -1,54 +0,0 @@
|
|
1
|
-
Feature: Global namespace DSL
|
2
|
-
|
3
|
-
RSpec has a few top-level constructs that allow you to begin describing
|
4
|
-
behaviour:
|
5
|
-
|
6
|
-
* `RSpec.describe`: Define a named context for a group of examples.
|
7
|
-
* `RSpec.shared_examples_for`: Define a set of shared examples that can later be included in an example group.
|
8
|
-
* `RSpec.shared_context`: define some common context (using `before`, `let`, helper methods, etc) that can later be included in an example group.
|
9
|
-
|
10
|
-
Historically, these constructs have been available directly off of the main
|
11
|
-
object, so that you could use these at the start of a file without the
|
12
|
-
`RSpec.` prefix. They have also been available off of any class or module so
|
13
|
-
that you can scope your examples within a particular constant namespace.
|
14
|
-
|
15
|
-
RSpec 3 now provides an option to disable this global monkey patching:
|
16
|
-
|
17
|
-
`config.expose_dsl_globally = false`.
|
18
|
-
|
19
|
-
For backwards compatibility it defaults to true.
|
20
|
-
|
21
|
-
Scenario: by default RSpec allows the DSL to be used globally
|
22
|
-
Given a file named "spec/example_spec.rb" with:
|
23
|
-
"""ruby
|
24
|
-
describe "specs here" do
|
25
|
-
it "passes" do
|
26
|
-
end
|
27
|
-
end
|
28
|
-
"""
|
29
|
-
When I run `rspec`
|
30
|
-
Then the output should contain "1 example, 0 failures"
|
31
|
-
|
32
|
-
Scenario: when exposing globally is disabled the top level DSL no longer works
|
33
|
-
Given a file named "spec/example_spec.rb" with:
|
34
|
-
"""ruby
|
35
|
-
RSpec.configure { |c| c.expose_dsl_globally = false }
|
36
|
-
describe "specs here" do
|
37
|
-
it "passes" do
|
38
|
-
end
|
39
|
-
end
|
40
|
-
"""
|
41
|
-
When I run `rspec`
|
42
|
-
Then the output should contain "undefined method `describe'"
|
43
|
-
|
44
|
-
Scenario: regardless of setting
|
45
|
-
Given a file named "spec/example_spec.rb" with:
|
46
|
-
"""ruby
|
47
|
-
RSpec.configure { |c| c.expose_dsl_globally = true }
|
48
|
-
RSpec.describe "specs here" do
|
49
|
-
it "passes" do
|
50
|
-
end
|
51
|
-
end
|
52
|
-
"""
|
53
|
-
When I run `rspec`
|
54
|
-
Then the output should contain "1 example, 0 failures"
|
@@ -1,77 +0,0 @@
|
|
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
|
-
"""ruby
|
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
|
-
"""ruby
|
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
|
-
"""ruby
|
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
|
-
"""ruby
|
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
|
-
"""ruby
|
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,36 +0,0 @@
|
|
1
|
-
Feature: failure exit code
|
2
|
-
|
3
|
-
Use the feature_exit_code option to set a custom exit code when RSpec fails.
|
4
|
-
|
5
|
-
RSpec.configure { |c| c.failure_exit_code = 42 }
|
6
|
-
|
7
|
-
Background:
|
8
|
-
Given a file named "spec/spec_helper.rb" with:
|
9
|
-
"""ruby
|
10
|
-
RSpec.configure { |c| c.failure_exit_code = 42 }
|
11
|
-
"""
|
12
|
-
|
13
|
-
Scenario: a failing spec with the default exit code
|
14
|
-
Given a file named "spec/example_spec.rb" with:
|
15
|
-
"""ruby
|
16
|
-
describe "something" do
|
17
|
-
it "fails" do
|
18
|
-
fail
|
19
|
-
end
|
20
|
-
end
|
21
|
-
"""
|
22
|
-
When I run `rspec spec/example_spec.rb`
|
23
|
-
Then the exit status should be 1
|
24
|
-
|
25
|
-
Scenario: a failing spec with a custom exit code
|
26
|
-
Given a file named "spec/example_spec.rb" with:
|
27
|
-
"""ruby
|
28
|
-
require 'spec_helper'
|
29
|
-
describe "something" do
|
30
|
-
it "fails" do
|
31
|
-
fail
|
32
|
-
end
|
33
|
-
end
|
34
|
-
"""
|
35
|
-
When I run `rspec spec/example_spec.rb`
|
36
|
-
Then the exit status should be 42
|