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,106 +0,0 @@
|
|
1
|
-
Feature: skipped examples
|
2
|
-
|
3
|
-
RSpec offers a number of ways to indicate that an example should be skipped
|
4
|
-
and not executed.
|
5
|
-
|
6
|
-
Scenario: no implementation provided
|
7
|
-
Given a file named "example_without_block_spec.rb" with:
|
8
|
-
"""ruby
|
9
|
-
describe "an example" do
|
10
|
-
it "is a skipped example"
|
11
|
-
end
|
12
|
-
"""
|
13
|
-
When I run `rspec example_without_block_spec.rb`
|
14
|
-
Then the exit status should be 0
|
15
|
-
And the output should contain "1 example, 0 failures, 1 pending"
|
16
|
-
And the output should contain "Not yet implemented"
|
17
|
-
And the output should contain "example_without_block_spec.rb:2"
|
18
|
-
|
19
|
-
Scenario: skipping using `skip`
|
20
|
-
Given a file named "skipped_spec.rb" with:
|
21
|
-
"""ruby
|
22
|
-
describe "an example" do
|
23
|
-
skip "is skipped" do
|
24
|
-
end
|
25
|
-
end
|
26
|
-
"""
|
27
|
-
When I run `rspec skipped_spec.rb`
|
28
|
-
Then the exit status should be 0
|
29
|
-
And the output should contain "1 example, 0 failures, 1 pending"
|
30
|
-
And the output should contain:
|
31
|
-
"""
|
32
|
-
Pending:
|
33
|
-
an example is skipped
|
34
|
-
# No reason given
|
35
|
-
# ./skipped_spec.rb:2
|
36
|
-
"""
|
37
|
-
|
38
|
-
Scenario: skipping using `skip` inside an example
|
39
|
-
Given a file named "skipped_spec.rb" with:
|
40
|
-
"""ruby
|
41
|
-
describe "an example" do
|
42
|
-
it "is skipped" do
|
43
|
-
skip
|
44
|
-
end
|
45
|
-
end
|
46
|
-
"""
|
47
|
-
When I run `rspec skipped_spec.rb`
|
48
|
-
Then the exit status should be 0
|
49
|
-
And the output should contain "1 example, 0 failures, 1 pending"
|
50
|
-
And the output should contain:
|
51
|
-
"""
|
52
|
-
Pending:
|
53
|
-
an example is skipped
|
54
|
-
# No reason given
|
55
|
-
# ./skipped_spec.rb:2
|
56
|
-
"""
|
57
|
-
|
58
|
-
Scenario: temporarily skipping by prefixing `it`, `specify`, or `example` with an x
|
59
|
-
Given a file named "temporarily_skipped_spec.rb" with:
|
60
|
-
"""ruby
|
61
|
-
describe "an example" do
|
62
|
-
xit "is skipped using xit" do
|
63
|
-
end
|
64
|
-
|
65
|
-
xspecify "is skipped using xspecify" do
|
66
|
-
end
|
67
|
-
|
68
|
-
xexample "is skipped using xexample" do
|
69
|
-
end
|
70
|
-
end
|
71
|
-
"""
|
72
|
-
When I run `rspec temporarily_skipped_spec.rb`
|
73
|
-
Then the exit status should be 0
|
74
|
-
And the output should contain "3 examples, 0 failures, 3 pending"
|
75
|
-
And the output should contain:
|
76
|
-
"""
|
77
|
-
Pending:
|
78
|
-
an example is skipped using xit
|
79
|
-
# Temporarily skipped with xit
|
80
|
-
# ./temporarily_skipped_spec.rb:2
|
81
|
-
an example is skipped using xspecify
|
82
|
-
# Temporarily skipped with xspecify
|
83
|
-
# ./temporarily_skipped_spec.rb:5
|
84
|
-
an example is skipped using xexample
|
85
|
-
# Temporarily skipped with xexample
|
86
|
-
# ./temporarily_skipped_spec.rb:8
|
87
|
-
"""
|
88
|
-
|
89
|
-
Scenario: skipping using metadata
|
90
|
-
Given a file named "skipped_spec.rb" with:
|
91
|
-
"""ruby
|
92
|
-
describe "an example" do
|
93
|
-
example "is skipped", :skip => true do
|
94
|
-
end
|
95
|
-
end
|
96
|
-
"""
|
97
|
-
When I run `rspec skipped_spec.rb`
|
98
|
-
Then the exit status should be 0
|
99
|
-
And the output should contain "1 example, 0 failures, 1 pending"
|
100
|
-
And the output should contain:
|
101
|
-
"""
|
102
|
-
Pending:
|
103
|
-
an example is skipped
|
104
|
-
# No reason given
|
105
|
-
# ./skipped_spec.rb:2
|
106
|
-
"""
|
@@ -1,83 +0,0 @@
|
|
1
|
-
require 'rspec/core' # to fix annoying "undefined method `configuration' for RSpec:Module (NoMethodError)"
|
2
|
-
|
3
|
-
Then /^the output should contain all of these:$/ do |table|
|
4
|
-
table.raw.flatten.each do |string|
|
5
|
-
assert_partial_output(string, all_output)
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
Then /^the output should not contain any of these:$/ do |table|
|
10
|
-
table.raw.flatten.each do |string|
|
11
|
-
expect(all_output).not_to match(regexp(string))
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
Then /^the output should contain one of the following:$/ do |table|
|
16
|
-
matching_output = table.raw.flatten.select do |string|
|
17
|
-
all_output =~ regexp(string)
|
18
|
-
end
|
19
|
-
|
20
|
-
expect(matching_output.count).to eq(1)
|
21
|
-
end
|
22
|
-
|
23
|
-
Then /^the example(?:s)? should(?: all)? pass$/ do
|
24
|
-
step %q{the output should contain "0 failures"}
|
25
|
-
step %q{the output should not contain "0 examples"}
|
26
|
-
step %q{the exit status should be 0}
|
27
|
-
end
|
28
|
-
|
29
|
-
Then /^the process should succeed even though no examples were run$/ do
|
30
|
-
step %q{the output should contain "0 examples, 0 failures"}
|
31
|
-
step %q{the exit status should be 0}
|
32
|
-
end
|
33
|
-
|
34
|
-
Then /^the backtrace\-normalized output should contain:$/ do |partial_output|
|
35
|
-
# ruby 1.9 includes additional stuff in the backtrace,
|
36
|
-
# so we need to normalize it to compare it with our expected output.
|
37
|
-
normalized_output = all_output.split("\n").map do |line|
|
38
|
-
line =~ /(^\s+# [^:]+:\d+)/ ? $1 : line # http://rubular.com/r/zDD7DdWyzF
|
39
|
-
end.join("\n")
|
40
|
-
|
41
|
-
expect(normalized_output).to match(regexp(partial_output))
|
42
|
-
end
|
43
|
-
|
44
|
-
Then /^the output should not contain any error backtraces$/ do
|
45
|
-
step %q{the output should not contain "lib/rspec/core"}
|
46
|
-
end
|
47
|
-
|
48
|
-
# This step can be generalized if it's ever used to test other colors
|
49
|
-
Then /^the failing example is printed in magenta$/ do
|
50
|
-
# \e[35m = enable magenta
|
51
|
-
# \e[0m = reset colors
|
52
|
-
expect(all_output).to include("\e[35m" + "F" + "\e[0m")
|
53
|
-
end
|
54
|
-
|
55
|
-
Given /^I have a brand new project with no files$/ do
|
56
|
-
in_current_dir do
|
57
|
-
expect(Dir["**/*"]).to eq([])
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
Given /^I have run `([^`]*)`$/ do |cmd|
|
62
|
-
fail_on_error = true
|
63
|
-
run_simple(unescape(cmd), fail_on_error)
|
64
|
-
end
|
65
|
-
|
66
|
-
When "I accept the recommended settings by removing `=begin` and `=end` from `spec/spec_helper.rb`" do
|
67
|
-
in_current_dir do
|
68
|
-
spec_helper = File.read("spec/spec_helper.rb")
|
69
|
-
expect(spec_helper).to include("=begin", "=end")
|
70
|
-
|
71
|
-
to_keep = spec_helper.lines.reject do |line|
|
72
|
-
line.start_with?("=begin") || line.start_with?("=end")
|
73
|
-
end
|
74
|
-
|
75
|
-
File.open("spec/spec_helper.rb", "w") { |f| f.write(to_keep.join) }
|
76
|
-
expect(File.read("spec/spec_helper.rb")).not_to include("=begin", "=end")
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
When /^I create "([^"]*)" with the following content:$/ do |file_name, content|
|
81
|
-
write_file(file_name, content)
|
82
|
-
end
|
83
|
-
|
@@ -1,101 +0,0 @@
|
|
1
|
-
Feature: explicit subject
|
2
|
-
|
3
|
-
Use `subject` in the group scope to explicitly define the value that is
|
4
|
-
returned by the `subject` method in the example scope.
|
5
|
-
|
6
|
-
Note that while the examples below demonstrate how `subject` can be used as a
|
7
|
-
user-facing concept, we recommend that you reserve it for support of custom
|
8
|
-
matchers and/or extension libraries that hide its use from examples.
|
9
|
-
|
10
|
-
Scenario: subject in top level group
|
11
|
-
Given a file named "top_level_subject_spec.rb" with:
|
12
|
-
"""ruby
|
13
|
-
describe Array, "with some elements" do
|
14
|
-
subject { [1,2,3] }
|
15
|
-
it "should have the prescribed elements" do
|
16
|
-
expect(subject).to eq([1,2,3])
|
17
|
-
end
|
18
|
-
end
|
19
|
-
"""
|
20
|
-
When I run `rspec top_level_subject_spec.rb`
|
21
|
-
Then the examples should all pass
|
22
|
-
|
23
|
-
Scenario: subject in a nested group
|
24
|
-
Given a file named "nested_subject_spec.rb" with:
|
25
|
-
"""ruby
|
26
|
-
describe Array do
|
27
|
-
subject { [1,2,3] }
|
28
|
-
describe "with some elements" do
|
29
|
-
it "should have the prescribed elements" do
|
30
|
-
expect(subject).to eq([1,2,3])
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
"""
|
35
|
-
When I run `rspec nested_subject_spec.rb`
|
36
|
-
Then the examples should all pass
|
37
|
-
|
38
|
-
Scenario: access subject from before block
|
39
|
-
Given a file named "top_level_subject_spec.rb" with:
|
40
|
-
"""ruby
|
41
|
-
describe Array, "with some elements" do
|
42
|
-
subject { [] }
|
43
|
-
before { subject.push(1,2,3) }
|
44
|
-
it "should have the prescribed elements" do
|
45
|
-
expect(subject).to eq([1,2,3])
|
46
|
-
end
|
47
|
-
end
|
48
|
-
"""
|
49
|
-
When I run `rspec top_level_subject_spec.rb`
|
50
|
-
Then the examples should all pass
|
51
|
-
|
52
|
-
Scenario: invoke helper method from subject block
|
53
|
-
Given a file named "helper_subject_spec.rb" with:
|
54
|
-
"""ruby
|
55
|
-
describe Array do
|
56
|
-
def prepared_array; [1,2,3] end
|
57
|
-
subject { prepared_array }
|
58
|
-
describe "with some elements" do
|
59
|
-
it "should have the prescribed elements" do
|
60
|
-
expect(subject).to eq([1,2,3])
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
"""
|
65
|
-
When I run `rspec helper_subject_spec.rb`
|
66
|
-
Then the examples should all pass
|
67
|
-
|
68
|
-
Scenario: subject block is invoked at most once per example
|
69
|
-
Given a file named "nil_subject_spec.rb" with:
|
70
|
-
"""ruby
|
71
|
-
describe Array do
|
72
|
-
describe "#[]" do
|
73
|
-
context "with index out of bounds" do
|
74
|
-
before { expect(Array).to receive(:one_two_three).once.and_return([1,2,3]) }
|
75
|
-
subject { Array.one_two_three[42] }
|
76
|
-
it { is_expected.to be_nil }
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
"""
|
81
|
-
When I run `rspec nil_subject_spec.rb`
|
82
|
-
Then the examples should all pass
|
83
|
-
|
84
|
-
Scenario: subject bang method
|
85
|
-
Given a file named "subject_bang_spec.rb" with:
|
86
|
-
"""ruby
|
87
|
-
describe Array do
|
88
|
-
describe '#pop' do
|
89
|
-
let(:prepared_array) { [1,2,3] }
|
90
|
-
subject! { prepared_array.pop }
|
91
|
-
it "removes the last value from the array" do
|
92
|
-
expect(prepared_array).to eq([1,2])
|
93
|
-
end
|
94
|
-
it "returns the last value of the array" do
|
95
|
-
expect(subject).to eq(3)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
"""
|
100
|
-
When I run `rspec subject_bang_spec.rb`
|
101
|
-
Then the examples should all pass
|
@@ -1,63 +0,0 @@
|
|
1
|
-
Feature: implicitly defined subject
|
2
|
-
|
3
|
-
If the first argument to the outermost example group is a class, an instance
|
4
|
-
of that class is exposed to each example via the `subject` method.
|
5
|
-
|
6
|
-
While the examples below demonstrate how `subject` can be used as a
|
7
|
-
user-facing concept, we recommend that you reserve it for support of custom
|
8
|
-
matchers and/or extension libraries that hide its use from examples.
|
9
|
-
|
10
|
-
Scenario: subject exposed in top level group
|
11
|
-
Given a file named "top_level_subject_spec.rb" with:
|
12
|
-
"""ruby
|
13
|
-
describe Array do
|
14
|
-
it "should be empty when first created" do
|
15
|
-
expect(subject).to be_empty
|
16
|
-
end
|
17
|
-
end
|
18
|
-
"""
|
19
|
-
When I run `rspec ./top_level_subject_spec.rb`
|
20
|
-
Then the examples should all pass
|
21
|
-
|
22
|
-
Scenario: subject in a nested group
|
23
|
-
Given a file named "nested_subject_spec.rb" with:
|
24
|
-
"""ruby
|
25
|
-
describe Array do
|
26
|
-
describe "when first created" do
|
27
|
-
it "should be empty" do
|
28
|
-
expect(subject).to be_empty
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
"""
|
33
|
-
When I run `rspec nested_subject_spec.rb`
|
34
|
-
Then the examples should all pass
|
35
|
-
|
36
|
-
Scenario: subject in a nested group with a different class (outermost wins)
|
37
|
-
Given a file named "nested_subject_spec.rb" with:
|
38
|
-
"""ruby
|
39
|
-
class ArrayWithOneElement < Array
|
40
|
-
def initialize(*)
|
41
|
-
super
|
42
|
-
unshift "first element"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe Array do
|
47
|
-
describe ArrayWithOneElement do
|
48
|
-
context "referenced as subject" do
|
49
|
-
it "should be empty (because it is the Array declared at the top)" do
|
50
|
-
expect(subject).to be_empty
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context "created in the example" do
|
55
|
-
it "should not be empty" do
|
56
|
-
expect(ArrayWithOneElement.new).not_to be_empty
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
"""
|
62
|
-
When I run `rspec nested_subject_spec.rb`
|
63
|
-
Then the examples should all pass
|
@@ -1,71 +0,0 @@
|
|
1
|
-
Feature: One-liner syntax
|
2
|
-
|
3
|
-
RSpec supports a one-liner syntax for setting an expectation
|
4
|
-
on the `subject`. RSpec will give the examples a doc string
|
5
|
-
that is auto-generated from the matcher used in the example.
|
6
|
-
This is designed specifically to help avoid duplication in
|
7
|
-
situations where the doc string and the matcher used in the
|
8
|
-
example mirror each other exactly. When used excessively,
|
9
|
-
it can produce documentation output that does not read well
|
10
|
-
or contribute to understanding the object you are describing.
|
11
|
-
|
12
|
-
This comes in two flavors:
|
13
|
-
|
14
|
-
* `is_expected` is defined simply as `expect(subject)` and is
|
15
|
-
designed for when you are using rspec-expectations with its
|
16
|
-
newer expect-based syntax.
|
17
|
-
* `should` was designed back when rspec-expectations only had
|
18
|
-
a should-based syntax. However, it continues to be available
|
19
|
-
and work even if the `:should` syntax is disabled (since that
|
20
|
-
merely removes `Object#should` but this is
|
21
|
-
`RSpec::Core::ExampleGroup#should`).
|
22
|
-
|
23
|
-
Note: this feature is only available when using rspec-expectations.
|
24
|
-
|
25
|
-
Scenario: implicit subject
|
26
|
-
Given a file named "example_spec.rb" with:
|
27
|
-
"""ruby
|
28
|
-
describe Array do
|
29
|
-
describe "when first created" do
|
30
|
-
# Rather than:
|
31
|
-
# it "should be empty" do
|
32
|
-
# subject.should be_empty
|
33
|
-
# end
|
34
|
-
|
35
|
-
it { should be_empty }
|
36
|
-
# or
|
37
|
-
it { is_expected.to be_empty }
|
38
|
-
end
|
39
|
-
end
|
40
|
-
"""
|
41
|
-
When I run `rspec example_spec.rb --format doc`
|
42
|
-
Then the examples should all pass
|
43
|
-
And the output should contain:
|
44
|
-
"""
|
45
|
-
Array
|
46
|
-
when first created
|
47
|
-
should be empty
|
48
|
-
should be empty
|
49
|
-
"""
|
50
|
-
|
51
|
-
Scenario: explicit subject
|
52
|
-
Given a file named "example_spec.rb" with:
|
53
|
-
"""ruby
|
54
|
-
describe Array do
|
55
|
-
describe "with 3 items" do
|
56
|
-
subject { [1,2,3] }
|
57
|
-
it { should_not be_empty }
|
58
|
-
# or
|
59
|
-
it { is_expected.not_to be_empty }
|
60
|
-
end
|
61
|
-
end
|
62
|
-
"""
|
63
|
-
When I run `rspec example_spec.rb --format doc`
|
64
|
-
Then the examples should all pass
|
65
|
-
And the output should contain:
|
66
|
-
"""
|
67
|
-
Array
|
68
|
-
with 3 items
|
69
|
-
should not be empty
|
70
|
-
should not be empty
|
71
|
-
"""
|
data/features/support/env.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'aruba/cucumber'
|
2
|
-
|
3
|
-
Before do
|
4
|
-
if RUBY_PLATFORM =~ /java/ || defined?(Rubinius)
|
5
|
-
@aruba_timeout_seconds = 60
|
6
|
-
else
|
7
|
-
@aruba_timeout_seconds = 10
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
Aruba.configure do |config|
|
12
|
-
config.before_cmd do |cmd|
|
13
|
-
set_env('JRUBY_OPTS', "-X-C #{ENV['JRUBY_OPTS']}") # disable JIT since these processes are so short lived
|
14
|
-
end
|
15
|
-
end if RUBY_PLATFORM == 'java'
|
16
|
-
|
17
|
-
Aruba.configure do |config|
|
18
|
-
config.before_cmd do |cmd|
|
19
|
-
set_env('RBXOPT', "-Xint=true #{ENV['RBXOPT']}") # disable JIT since these processes are so short lived
|
20
|
-
end
|
21
|
-
end if defined?(Rubinius)
|