rspec-core 2.99.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- checksums.yaml.gz.sig +0 -0
- data/.yardopts +1 -0
- data/Changelog.md +339 -1
- data/License.txt +1 -0
- data/README.md +19 -37
- data/exe/rspec +2 -23
- data/lib/rspec/core/backport_random.rb +336 -0
- data/lib/rspec/core/backtrace_formatter.rb +70 -0
- data/lib/rspec/core/configuration.rb +479 -577
- data/lib/rspec/core/configuration_options.rb +71 -54
- data/lib/rspec/core/drb.rb +111 -0
- data/lib/rspec/core/dsl.rb +86 -18
- data/lib/rspec/core/example.rb +267 -119
- data/lib/rspec/core/example_group.rb +381 -393
- data/lib/rspec/core/filter_manager.rb +133 -114
- data/lib/rspec/core/flat_map.rb +18 -0
- data/lib/rspec/core/formatters/base_formatter.rb +51 -125
- data/lib/rspec/core/formatters/base_text_formatter.rb +34 -286
- data/lib/rspec/core/formatters/console_codes.rb +24 -1
- data/lib/rspec/core/formatters/deprecation_formatter.rb +25 -26
- data/lib/rspec/core/formatters/documentation_formatter.rb +27 -25
- data/lib/rspec/core/formatters/helpers.rb +14 -36
- data/lib/rspec/core/formatters/html_formatter.rb +58 -65
- data/lib/rspec/core/formatters/html_printer.rb +12 -18
- data/lib/rspec/core/formatters/json_formatter.rb +54 -31
- data/lib/rspec/core/formatters/profile_formatter.rb +67 -0
- data/lib/rspec/core/formatters/progress_formatter.rb +11 -15
- data/lib/rspec/core/formatters/snippet_extractor.rb +22 -11
- data/lib/rspec/core/formatters.rb +90 -43
- data/lib/rspec/core/hooks.rb +325 -270
- data/lib/rspec/core/memoized_helpers.rb +45 -156
- data/lib/rspec/core/metadata.rb +284 -236
- data/lib/rspec/core/metadata_filter.rb +86 -0
- data/lib/rspec/core/mocking_adapters/flexmock.rb +29 -0
- data/lib/rspec/core/{mocking/with_mocha.rb → mocking_adapters/mocha.rb} +19 -16
- data/lib/rspec/core/mocking_adapters/null.rb +12 -0
- data/lib/rspec/core/mocking_adapters/rr.rb +29 -0
- data/lib/rspec/core/mocking_adapters/rspec.rb +30 -0
- data/lib/rspec/core/notifications.rb +511 -0
- data/lib/rspec/core/option_parser.rb +49 -74
- data/lib/rspec/core/ordering.rb +156 -0
- data/lib/rspec/core/pending.rb +94 -96
- data/lib/rspec/core/project_initializer/.rspec +3 -0
- data/lib/rspec/core/project_initializer/spec/spec_helper.rb +78 -0
- data/lib/rspec/core/project_initializer.rb +24 -64
- data/lib/rspec/core/rake_task.rb +44 -130
- data/lib/rspec/core/reporter.rb +76 -59
- data/lib/rspec/core/ruby_project.rb +2 -1
- data/lib/rspec/core/runner.rb +117 -52
- data/lib/rspec/core/shared_context.rb +10 -10
- data/lib/rspec/core/shared_example_group.rb +108 -121
- data/lib/rspec/core/version.rb +3 -1
- data/lib/rspec/core/warnings.rb +40 -0
- data/lib/rspec/core/world.rb +66 -10
- data/lib/rspec/core.rb +64 -104
- data.tar.gz.sig +3 -0
- metadata +75 -322
- metadata.gz.sig +1 -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 -97
- data/features/command_line/exit_status.feature +0 -82
- data/features/command_line/format_option.feature +0 -75
- 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 -53
- data/features/command_line/order.feature +0 -26
- data/features/command_line/pattern_option.feature +0 -49
- data/features/command_line/rake_task.feature +0 -122
- data/features/command_line/require_option.feature +0 -43
- data/features/command_line/ruby.feature +0 -22
- 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 -48
- data/features/configuration/backtrace_clean_patterns.feature +0 -102
- 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/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/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/configuration/show_failures_in_pending_blocks.feature +0 -61
- data/features/configuration/treat_symbols_as_metadata_keys_with_true_values.feature +0 -52
- 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 -294
- data/features/expectation_framework_integration/configure_expectation_framework.feature +0 -197
- data/features/filtering/exclusion_filters.feature +0 -138
- data/features/filtering/if_and_unless.feature +0 -168
- data/features/filtering/inclusion_filters.feature +0 -105
- data/features/formatters/configurable_colors.feature +0 -31
- data/features/formatters/custom_formatter.feature +0 -36
- data/features/formatters/json_formatter.feature +0 -30
- 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 -427
- data/features/hooks/filtering.feature +0 -234
- data/features/metadata/current_example.feature +0 -56
- 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 -49
- data/features/subject/attribute_of_subject.feature +0 -124
- 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 -14
- data/features/support/rubinius.rb +0 -6
- data/lib/autotest/discover.rb +0 -10
- data/lib/autotest/rspec2.rb +0 -77
- data/lib/rspec/core/backtrace_cleaner.rb +0 -46
- data/lib/rspec/core/backward_compatibility.rb +0 -55
- data/lib/rspec/core/caller_filter.rb +0 -60
- data/lib/rspec/core/command_line.rb +0 -47
- data/lib/rspec/core/deprecated_mutable_array_proxy.rb +0 -32
- data/lib/rspec/core/deprecation.rb +0 -26
- 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 -27
- data/lib/rspec/core/formatters/text_mate_formatter.rb +0 -34
- 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_rr.rb +0 -27
- data/lib/rspec/core/mocking/with_rspec.rb +0 -27
- data/lib/rspec/core/shared_example_group/collection.rb +0 -45
- data/spec/autotest/discover_spec.rb +0 -49
- data/spec/autotest/failed_results_re_spec.rb +0 -45
- data/spec/autotest/rspec_spec.rb +0 -133
- data/spec/command_line/order_spec.rb +0 -204
- data/spec/rspec/core/backtrace_cleaner_spec.rb +0 -68
- data/spec/rspec/core/caller_filter_spec.rb +0 -58
- data/spec/rspec/core/command_line_spec.rb +0 -127
- data/spec/rspec/core/command_line_spec_output.txt +0 -0
- data/spec/rspec/core/configuration_options_spec.rb +0 -417
- data/spec/rspec/core/configuration_spec.rb +0 -2072
- data/spec/rspec/core/deprecation_spec.rb +0 -27
- data/spec/rspec/core/deprecations_spec.rb +0 -59
- 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 -25
- data/spec/rspec/core/example_group_spec.rb +0 -1337
- data/spec/rspec/core/example_spec.rb +0 -502
- data/spec/rspec/core/filter_manager_spec.rb +0 -246
- data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -108
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +0 -524
- data/spec/rspec/core/formatters/console_codes_spec.rb +0 -50
- data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +0 -263
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +0 -89
- data/spec/rspec/core/formatters/helpers_spec.rb +0 -104
- data/spec/rspec/core/formatters/html_formatted.html +0 -397
- data/spec/rspec/core/formatters/html_formatter_spec.rb +0 -131
- data/spec/rspec/core/formatters/json_formatter_spec.rb +0 -115
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -30
- data/spec/rspec/core/formatters/snippet_extractor_spec.rb +0 -26
- data/spec/rspec/core/formatters/text_mate_formatted.html +0 -397
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +0 -107
- data/spec/rspec/core/hooks_filtering_spec.rb +0 -227
- data/spec/rspec/core/hooks_spec.rb +0 -269
- data/spec/rspec/core/kernel_extensions_spec.rb +0 -9
- data/spec/rspec/core/memoized_helpers_spec.rb +0 -776
- data/spec/rspec/core/metadata_spec.rb +0 -514
- data/spec/rspec/core/option_parser_spec.rb +0 -297
- data/spec/rspec/core/pending_example_spec.rb +0 -260
- data/spec/rspec/core/pending_spec.rb +0 -27
- data/spec/rspec/core/project_initializer_spec.rb +0 -130
- data/spec/rspec/core/rake_task_spec.rb +0 -202
- data/spec/rspec/core/reporter_spec.rb +0 -167
- 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 -26
- data/spec/rspec/core/runner_spec.rb +0 -82
- data/spec/rspec/core/shared_context_spec.rb +0 -114
- data/spec/rspec/core/shared_example_group/collection_spec.rb +0 -70
- data/spec/rspec/core/shared_example_group_spec.rb +0 -138
- data/spec/rspec/core/world_spec.rb +0 -142
- data/spec/rspec/core_spec.rb +0 -108
- data/spec/spec_helper.rb +0 -135
- data/spec/support/config_options_helper.rb +0 -15
- data/spec/support/helper_methods.rb +0 -55
- data/spec/support/in_sub_process.rb +0 -37
- data/spec/support/isolate_load_path_mutation.rb +0 -6
- data/spec/support/isolated_directory.rb +0 -10
- data/spec/support/isolated_home_directory.rb +0 -16
- data/spec/support/matchers.rb +0 -65
- data/spec/support/mathn_integration_support.rb +0 -12
- data/spec/support/sandboxed_mock_space.rb +0 -116
- data/spec/support/shared_example_groups.rb +0 -42
- data/spec/support/silence_dsl_deprecations.rb +0 -32
- data/spec/support/spec_files.rb +0 -44
|
@@ -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" 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
|
-
RSpec.configuration.output_stream.stub(:tty?) { true }
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it "is true" do
|
|
31
|
-
RSpec.configuration.should 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
|
-
RSpec.configuration.formatters.first.
|
|
49
|
-
should 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
|
-
RSpec.configuration.color.should 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
|
-
RSpec.configuration.formatters.first.should 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
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
Feature: run all when everything filtered
|
|
2
|
-
|
|
3
|
-
Use the run_all_when_everything_filtered option to tell RSpec to run all the
|
|
4
|
-
specs in the case where you try to run a filtered list of specs but no specs
|
|
5
|
-
match that filter. This works well when paired with an inclusion filter like
|
|
6
|
-
`:focus => true`, as it will run all the examples when none match the
|
|
7
|
-
inclusion filter.
|
|
8
|
-
|
|
9
|
-
RSpec.configure { |c| c.run_all_when_everything_filtered = true }
|
|
10
|
-
|
|
11
|
-
Background:
|
|
12
|
-
Given a file named "spec/spec_helper.rb" with:
|
|
13
|
-
"""ruby
|
|
14
|
-
RSpec.configure {|c| c.run_all_when_everything_filtered = true}
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
Scenario: by default, no specs are run if they are all filtered out by an inclusion tag
|
|
18
|
-
Given a file named "spec/example_spec.rb" with:
|
|
19
|
-
"""ruby
|
|
20
|
-
describe "examples" do
|
|
21
|
-
it "with no tag" do
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it "with no tag as well" do
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
"""
|
|
28
|
-
When I run `rspec spec/example_spec.rb --tag some_tag`
|
|
29
|
-
Then the output should contain "0 examples, 0 failures"
|
|
30
|
-
|
|
31
|
-
Scenario: specs are still run if they are filtered out by an exclusion tag
|
|
32
|
-
Given a file named "spec/example_spec.rb" with:
|
|
33
|
-
"""ruby
|
|
34
|
-
describe "examples" do
|
|
35
|
-
it "with no tag" do
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it "with no tag as well" do
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
"""
|
|
42
|
-
When I run `rspec spec/example_spec.rb --tag ~some_tag`
|
|
43
|
-
Then the output should contain "2 examples, 0 failures"
|
|
44
|
-
|
|
45
|
-
Scenario: when the run_all_when_everything_filtered option is turned on, if there are any matches for the filtering tag, only those features are run
|
|
46
|
-
Given a file named "spec/example_spec.rb" with:
|
|
47
|
-
"""ruby
|
|
48
|
-
require "spec_helper"
|
|
49
|
-
describe "examples" do
|
|
50
|
-
it "with no tag", :some_tag => true do
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
it "with no tag as well" do
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
"""
|
|
57
|
-
When I run `rspec spec/example_spec.rb --tag some_tag`
|
|
58
|
-
Then the output should contain "1 example, 0 failures"
|
|
59
|
-
And the output should contain "Run options: include {:some_tag=>true}"
|
|
60
|
-
|
|
61
|
-
Scenario: when the run_all_when_everything_filtered option is turned on, all the specs are run when the tag has no matches
|
|
62
|
-
Given a file named "spec/example_spec.rb" with:
|
|
63
|
-
"""ruby
|
|
64
|
-
require "spec_helper"
|
|
65
|
-
describe "examples" do
|
|
66
|
-
it "with no tag" do
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
it "with no tag as well" do
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
"""
|
|
73
|
-
When I run `rspec spec/example_spec.rb --tag some_tag`
|
|
74
|
-
Then the output should contain "2 examples, 0 failures"
|
|
75
|
-
And the output should contain "All examples were filtered out; ignoring {:some_tag=>true}"
|
|
76
|
-
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
Feature: show_failures_in_pending_blocks
|
|
2
|
-
|
|
3
|
-
Use the show_failures_in_pending_blocks option to run the code in pending blocks while keeping the tests pending.
|
|
4
|
-
|
|
5
|
-
RSpec.configure { |c| c.show_failures_in_pending_blocks = true }
|
|
6
|
-
|
|
7
|
-
Background:
|
|
8
|
-
Given a file named "spec/spec_helper.rb" with:
|
|
9
|
-
"""ruby
|
|
10
|
-
RSpec.configure {|c| c.show_failures_in_pending_blocks = true}
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
Scenario: by default, code in pending examples is not exercised
|
|
14
|
-
Given a file named "spec/example_spec.rb" with:
|
|
15
|
-
"""ruby
|
|
16
|
-
describe "fails" do
|
|
17
|
-
pending "code will not be exercised" do
|
|
18
|
-
fail
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
"""
|
|
22
|
-
When I run `rspec spec/example_spec.rb`
|
|
23
|
-
Then the output should not contain "Failure/Error: pending { fail }"
|
|
24
|
-
|
|
25
|
-
Scenario: by default, code in pending blocks inside examples is not exercised
|
|
26
|
-
Given a file named "spec/example_spec.rb" with:
|
|
27
|
-
"""ruby
|
|
28
|
-
describe "fails" do
|
|
29
|
-
it "code will not be exercised" do
|
|
30
|
-
pending { fail }
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
"""
|
|
34
|
-
When I run `rspec spec/example_spec.rb`
|
|
35
|
-
Then the output should not contain "Failure/Error: pending { fail }"
|
|
36
|
-
|
|
37
|
-
Scenario: when turned on, pending code blocks inside examples are exercised
|
|
38
|
-
Given a file named "spec/example_spec.rb" with:
|
|
39
|
-
"""ruby
|
|
40
|
-
require "spec_helper"
|
|
41
|
-
describe "fails" do
|
|
42
|
-
it "code will be exercised" do
|
|
43
|
-
pending { fail }
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
"""
|
|
47
|
-
When I run `rspec spec/example_spec.rb`
|
|
48
|
-
Then the output should contain "Failure/Error: pending { fail }"
|
|
49
|
-
|
|
50
|
-
Scenario: when turned on, code inside pending examples is not exercised
|
|
51
|
-
Given a file named "spec/example_spec.rb" with:
|
|
52
|
-
"""ruby
|
|
53
|
-
require "spec_helper"
|
|
54
|
-
describe "fails" do
|
|
55
|
-
pending "code will not be exercised" do
|
|
56
|
-
fail
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
"""
|
|
60
|
-
When I run `rspec spec/example_spec.rb`
|
|
61
|
-
Then the output should not contain "Failure/Error: pending { fail }"
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
Feature: treat symbols as metadata keys with true values
|
|
2
|
-
|
|
3
|
-
Use the treat_symbols_as_metadata_keys_with_true_values option to tell RSpec that :key is shorthand for :key => true.
|
|
4
|
-
|
|
5
|
-
RSpec.configure { |c| c.treat_symbols_as_metadata_keys_with_true_values = true }
|
|
6
|
-
|
|
7
|
-
Background:
|
|
8
|
-
Given a file named "spec/spec_helper.rb" with:
|
|
9
|
-
"""ruby
|
|
10
|
-
RSpec.configure { |c| c.treat_symbols_as_metadata_keys_with_true_values = true }
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
Scenario: by default, symbols without values are ignored and the specs are filtered out
|
|
14
|
-
Given a file named "spec/example_spec.rb" with:
|
|
15
|
-
"""ruby
|
|
16
|
-
describe "failed filtering" do
|
|
17
|
-
it "this will be filted out", :some_tag do
|
|
18
|
-
true
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it "so will this" do
|
|
22
|
-
false
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
"""
|
|
26
|
-
When I run `rspec spec/example_spec.rb --tag some_tag`
|
|
27
|
-
Then the output should contain "0 examples, 0 failures"
|
|
28
|
-
And the output should contain "All examples were filtered out"
|
|
29
|
-
|
|
30
|
-
Scenario: when treat_symbols_as_metadata_keys_with_true_values is true, specs can be tagged with only a symbol
|
|
31
|
-
Given a file named "spec/example_spec.rb" with:
|
|
32
|
-
"""ruby
|
|
33
|
-
require "spec_helper"
|
|
34
|
-
describe "run me", :some_tag do
|
|
35
|
-
it "runs" do
|
|
36
|
-
true
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
describe "run one of these" do
|
|
41
|
-
it "run this one", :some_tag do
|
|
42
|
-
true
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it "but not me" do
|
|
46
|
-
false
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
"""
|
|
50
|
-
When I run `rspec spec/example_spec.rb --tag some_tag`
|
|
51
|
-
Then the output should contain "2 examples, 0 failures"
|
|
52
|
-
And the output should contain "Run options: include {:some_tag=>true}"
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
Feature: basic structure (describe/it)
|
|
2
|
-
|
|
3
|
-
RSpec is a DSL for creating executable examples of how code is expected to
|
|
4
|
-
behave, organized in groups. It uses the words "describe" and "it" so we can
|
|
5
|
-
express concepts like a conversation:
|
|
6
|
-
|
|
7
|
-
"Describe an account when it is first opened."
|
|
8
|
-
"It has a balance of zero."
|
|
9
|
-
|
|
10
|
-
The `describe` method creates an example group. Within the block passed to
|
|
11
|
-
`describe` you can declare nested groups using the `describe` or `context`
|
|
12
|
-
methods, or you can declare examples using the `it` or `specify` methods.
|
|
13
|
-
|
|
14
|
-
Under the hood, an example group is a class in which the block passed to
|
|
15
|
-
`describe` or `context` is evaluated. The blocks passed to `it` are evaluated
|
|
16
|
-
in the context of an _instance_ of that class.
|
|
17
|
-
|
|
18
|
-
Scenario: one group, one example
|
|
19
|
-
Given a file named "sample_spec.rb" with:
|
|
20
|
-
"""ruby
|
|
21
|
-
describe "something" do
|
|
22
|
-
it "does something" do
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
"""
|
|
26
|
-
When I run `rspec sample_spec.rb -f doc`
|
|
27
|
-
Then the output should contain:
|
|
28
|
-
"""
|
|
29
|
-
something
|
|
30
|
-
does something
|
|
31
|
-
"""
|
|
32
|
-
|
|
33
|
-
Scenario: nested example groups (using context)
|
|
34
|
-
Given a file named "nested_example_groups_spec.rb" with:
|
|
35
|
-
"""ruby
|
|
36
|
-
describe "something" do
|
|
37
|
-
context "in one context" do
|
|
38
|
-
it "does one thing" do
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
context "in another context" do
|
|
42
|
-
it "does another thing" do
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
"""
|
|
47
|
-
When I run `rspec nested_example_groups_spec.rb -fdoc`
|
|
48
|
-
Then the output should contain:
|
|
49
|
-
"""
|
|
50
|
-
something
|
|
51
|
-
in one context
|
|
52
|
-
does one thing
|
|
53
|
-
in another context
|
|
54
|
-
does another thing
|
|
55
|
-
"""
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
Feature: shared context
|
|
2
|
-
|
|
3
|
-
Use `shared_context` to define a block that will be evaluated in the context
|
|
4
|
-
of example groups either explicitly, using `include_context`, or implicitly by
|
|
5
|
-
matching metadata.
|
|
6
|
-
|
|
7
|
-
Background:
|
|
8
|
-
Given a file named "shared_stuff.rb" with:
|
|
9
|
-
"""ruby
|
|
10
|
-
shared_context "shared stuff", :a => :b do
|
|
11
|
-
before { @some_var = :some_value }
|
|
12
|
-
def shared_method
|
|
13
|
-
"it works"
|
|
14
|
-
end
|
|
15
|
-
let(:shared_let) { {'arbitrary' => 'object'} }
|
|
16
|
-
subject do
|
|
17
|
-
'this is the subject'
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
"""
|
|
21
|
-
|
|
22
|
-
Scenario: declare shared context and include it with include_context
|
|
23
|
-
Given a file named "shared_context_example.rb" with:
|
|
24
|
-
"""ruby
|
|
25
|
-
require "./shared_stuff.rb"
|
|
26
|
-
|
|
27
|
-
describe "group that includes a shared context using 'include_context'" do
|
|
28
|
-
include_context "shared stuff"
|
|
29
|
-
|
|
30
|
-
it "has access to methods defined in shared context" do
|
|
31
|
-
shared_method.should eq("it works")
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it "has access to methods defined with let in shared context" do
|
|
35
|
-
shared_let['arbitrary'].should eq('object')
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it "runs the before hooks defined in the shared context" do
|
|
39
|
-
@some_var.should be(:some_value)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it "accesses the subject defined in the shared context" do
|
|
43
|
-
subject.should eq('this is the subject')
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
"""
|
|
47
|
-
When I run `rspec shared_context_example.rb`
|
|
48
|
-
Then the examples should all pass
|
|
49
|
-
|
|
50
|
-
Scenario: declare shared context and include it with metadata
|
|
51
|
-
Given a file named "shared_context_example.rb" with:
|
|
52
|
-
"""ruby
|
|
53
|
-
require "./shared_stuff.rb"
|
|
54
|
-
|
|
55
|
-
describe "group that includes a shared context using metadata", :a => :b do
|
|
56
|
-
it "has access to methods defined in shared context" do
|
|
57
|
-
shared_method.should eq("it works")
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
it "has access to methods defined with let in shared context" do
|
|
61
|
-
shared_let['arbitrary'].should eq('object')
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
it "runs the before hooks defined in the shared context" do
|
|
65
|
-
@some_var.should be(:some_value)
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
it "accesses the subject defined in the shared context" do
|
|
69
|
-
subject.should eq('this is the subject')
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
"""
|
|
73
|
-
When I run `rspec shared_context_example.rb`
|
|
74
|
-
Then the examples should all pass
|