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,94 +0,0 @@
|
|
1
|
-
Feature: mock with flexmock
|
2
|
-
|
3
|
-
Configure RSpec to use flexmock as shown in the scenarios below.
|
4
|
-
|
5
|
-
Scenario: passing message expectation
|
6
|
-
Given a file named "example_spec.rb" with:
|
7
|
-
"""ruby
|
8
|
-
RSpec.configure do |config|
|
9
|
-
config.mock_framework = :flexmock
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "mocking with Flexmock" do
|
13
|
-
it "passes when it should" do
|
14
|
-
receiver = flexmock('receiver')
|
15
|
-
receiver.should_receive(:message).once
|
16
|
-
receiver.message
|
17
|
-
end
|
18
|
-
end
|
19
|
-
"""
|
20
|
-
When I run `rspec example_spec.rb`
|
21
|
-
Then the examples should all pass
|
22
|
-
|
23
|
-
Scenario: failing message expecation
|
24
|
-
Given a file named "example_spec.rb" with:
|
25
|
-
"""ruby
|
26
|
-
RSpec.configure do |config|
|
27
|
-
config.mock_framework = :flexmock
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "mocking with Flexmock" do
|
31
|
-
it "fails when it should" do
|
32
|
-
receiver = flexmock('receiver')
|
33
|
-
receiver.should_receive(:message).once
|
34
|
-
end
|
35
|
-
end
|
36
|
-
"""
|
37
|
-
When I run `rspec example_spec.rb`
|
38
|
-
Then the output should contain "1 example, 1 failure"
|
39
|
-
|
40
|
-
Scenario: failing message expectation in pending example (remains pending)
|
41
|
-
Given a file named "example_spec.rb" with:
|
42
|
-
"""ruby
|
43
|
-
RSpec.configure do |config|
|
44
|
-
config.mock_framework = :flexmock
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "failed message expectation in a pending example" do
|
48
|
-
it "is listed as pending" do
|
49
|
-
pending
|
50
|
-
receiver = flexmock('receiver')
|
51
|
-
receiver.should_receive(:message).once
|
52
|
-
end
|
53
|
-
end
|
54
|
-
"""
|
55
|
-
When I run `rspec example_spec.rb`
|
56
|
-
Then the output should contain "1 example, 0 failures, 1 pending"
|
57
|
-
And the exit status should be 0
|
58
|
-
|
59
|
-
Scenario: passing message expectation in pending example (fails)
|
60
|
-
Given a file named "example_spec.rb" with:
|
61
|
-
"""ruby
|
62
|
-
RSpec.configure do |config|
|
63
|
-
config.mock_framework = :flexmock
|
64
|
-
end
|
65
|
-
|
66
|
-
describe "passing message expectation in a pending example" do
|
67
|
-
it "fails with FIXED" do
|
68
|
-
pending
|
69
|
-
receiver = flexmock('receiver')
|
70
|
-
receiver.should_receive(:message).once
|
71
|
-
receiver.message
|
72
|
-
end
|
73
|
-
end
|
74
|
-
"""
|
75
|
-
When I run `rspec example_spec.rb`
|
76
|
-
Then the output should contain "FIXED"
|
77
|
-
Then the output should contain "1 example, 1 failure"
|
78
|
-
And the exit status should be 1
|
79
|
-
|
80
|
-
Scenario: accessing RSpec.configuration.mock_framework.framework_name
|
81
|
-
Given a file named "example_spec.rb" with:
|
82
|
-
"""ruby
|
83
|
-
RSpec.configure do |config|
|
84
|
-
config.mock_framework = :flexmock
|
85
|
-
end
|
86
|
-
|
87
|
-
describe "RSpec.configuration.mock_framework.framework_name" do
|
88
|
-
it "returns :flexmock" do
|
89
|
-
expect(RSpec.configuration.mock_framework.framework_name).to eq(:flexmock)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
"""
|
93
|
-
When I run `rspec example_spec.rb`
|
94
|
-
Then the examples should all pass
|
@@ -1,95 +0,0 @@
|
|
1
|
-
Feature: mock with mocha
|
2
|
-
|
3
|
-
Configure RSpec to use mocha as shown in the scenarios below.
|
4
|
-
|
5
|
-
Scenario: passing message expectation
|
6
|
-
Given a file named "example_spec.rb" with:
|
7
|
-
"""ruby
|
8
|
-
RSpec.configure do |config|
|
9
|
-
config.mock_framework = :mocha
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "mocking with RSpec" do
|
13
|
-
it "passes when it should" do
|
14
|
-
receiver = mock('receiver')
|
15
|
-
receiver.expects(:message).once
|
16
|
-
receiver.message
|
17
|
-
end
|
18
|
-
end
|
19
|
-
"""
|
20
|
-
When I run `rspec example_spec.rb`
|
21
|
-
Then the examples should all pass
|
22
|
-
|
23
|
-
Scenario: failing message expecation
|
24
|
-
Given a file named "example_spec.rb" with:
|
25
|
-
"""ruby
|
26
|
-
RSpec.configure do |config|
|
27
|
-
config.mock_framework = :mocha
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "mocking with RSpec" do
|
31
|
-
it "fails when it should" do
|
32
|
-
receiver = mock('receiver')
|
33
|
-
receiver.expects(:message).once
|
34
|
-
end
|
35
|
-
end
|
36
|
-
"""
|
37
|
-
When I run `rspec example_spec.rb`
|
38
|
-
Then the output should contain "1 example, 1 failure"
|
39
|
-
|
40
|
-
Scenario: failing message expectation in pending example (remains pending)
|
41
|
-
Given a file named "example_spec.rb" with:
|
42
|
-
"""ruby
|
43
|
-
RSpec.configure do |config|
|
44
|
-
config.mock_framework = :mocha
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "failed message expectation in a pending example" do
|
48
|
-
it "is listed as pending" do
|
49
|
-
pending
|
50
|
-
receiver = mock('receiver')
|
51
|
-
receiver.expects(:message).once
|
52
|
-
end
|
53
|
-
end
|
54
|
-
"""
|
55
|
-
When I run `rspec example_spec.rb`
|
56
|
-
Then the output should contain "1 example, 0 failures, 1 pending"
|
57
|
-
And the exit status should be 0
|
58
|
-
|
59
|
-
Scenario: passing message expectation in pending example (fails)
|
60
|
-
Given a file named "example_spec.rb" with:
|
61
|
-
"""ruby
|
62
|
-
RSpec.configure do |config|
|
63
|
-
config.mock_framework = :mocha
|
64
|
-
end
|
65
|
-
|
66
|
-
describe "passing message expectation in a pending example" do
|
67
|
-
it "fails with FIXED" do
|
68
|
-
pending
|
69
|
-
receiver = mock('receiver')
|
70
|
-
receiver.expects(:message).once
|
71
|
-
receiver.message
|
72
|
-
end
|
73
|
-
end
|
74
|
-
"""
|
75
|
-
When I run `rspec example_spec.rb`
|
76
|
-
Then the output should contain "FIXED"
|
77
|
-
Then the output should contain "1 example, 1 failure"
|
78
|
-
And the exit status should be 1
|
79
|
-
|
80
|
-
Scenario: accessing RSpec.configuration.mock_framework.framework_name
|
81
|
-
Given a file named "example_spec.rb" with:
|
82
|
-
"""ruby
|
83
|
-
RSpec.configure do |config|
|
84
|
-
config.mock_framework = :mocha
|
85
|
-
end
|
86
|
-
|
87
|
-
describe "RSpec.configuration.mock_framework.framework_name" do
|
88
|
-
it "returns :mocha" do
|
89
|
-
expect(RSpec.configuration.mock_framework.framework_name).to eq(:mocha)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
"""
|
93
|
-
When I run `rspec example_spec.rb`
|
94
|
-
Then the examples should all pass
|
95
|
-
|
@@ -1,96 +0,0 @@
|
|
1
|
-
Feature: mock with rr
|
2
|
-
|
3
|
-
Configure RSpec to use rr as shown in the scenarios below.
|
4
|
-
|
5
|
-
Scenario: passing message expectation
|
6
|
-
Given a file named "example_spec.rb" with:
|
7
|
-
"""ruby
|
8
|
-
RSpec.configure do |config|
|
9
|
-
config.mock_framework = :rr
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "mocking with RSpec" do
|
13
|
-
it "passes when it should" do
|
14
|
-
receiver = Object.new
|
15
|
-
mock(receiver).message
|
16
|
-
receiver.message
|
17
|
-
end
|
18
|
-
end
|
19
|
-
"""
|
20
|
-
When I run `rspec example_spec.rb`
|
21
|
-
Then the examples should all pass
|
22
|
-
|
23
|
-
Scenario: failing message expecation
|
24
|
-
Given a file named "example_spec.rb" with:
|
25
|
-
"""ruby
|
26
|
-
RSpec.configure do |config|
|
27
|
-
config.mock_framework = :rr
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "mocking with RSpec" do
|
31
|
-
it "fails when it should" do
|
32
|
-
receiver = Object.new
|
33
|
-
mock(receiver).message
|
34
|
-
end
|
35
|
-
end
|
36
|
-
"""
|
37
|
-
When I run `rspec example_spec.rb`
|
38
|
-
Then the output should contain "1 example, 1 failure"
|
39
|
-
|
40
|
-
Scenario: failing message expectation in pending example (remains pending)
|
41
|
-
Given a file named "example_spec.rb" with:
|
42
|
-
"""ruby
|
43
|
-
RSpec.configure do |config|
|
44
|
-
config.mock_framework = :rr
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "failed message expectation in a pending example" do
|
48
|
-
it "is listed as pending" do
|
49
|
-
pending
|
50
|
-
receiver = Object.new
|
51
|
-
mock(receiver).message
|
52
|
-
end
|
53
|
-
end
|
54
|
-
"""
|
55
|
-
When I run `rspec example_spec.rb`
|
56
|
-
Then the output should contain "1 example, 0 failures, 1 pending"
|
57
|
-
And the exit status should be 0
|
58
|
-
|
59
|
-
Scenario: passing message expectation in pending example (fails)
|
60
|
-
Given a file named "example_spec.rb" with:
|
61
|
-
"""ruby
|
62
|
-
RSpec.configure do |config|
|
63
|
-
config.mock_framework = :rr
|
64
|
-
end
|
65
|
-
|
66
|
-
describe "passing message expectation in a pending example" do
|
67
|
-
it "fails with FIXED" do
|
68
|
-
pending
|
69
|
-
receiver = Object.new
|
70
|
-
mock(receiver).message
|
71
|
-
receiver.message
|
72
|
-
end
|
73
|
-
end
|
74
|
-
"""
|
75
|
-
When I run `rspec example_spec.rb`
|
76
|
-
Then the output should contain "FIXED"
|
77
|
-
Then the output should contain "1 example, 1 failure"
|
78
|
-
And the exit status should be 1
|
79
|
-
|
80
|
-
Scenario: accessing RSpec.configuration.mock_framework.framework_name
|
81
|
-
Given a file named "example_spec.rb" with:
|
82
|
-
"""ruby
|
83
|
-
RSpec.configure do |config|
|
84
|
-
config.mock_framework = :rr
|
85
|
-
end
|
86
|
-
|
87
|
-
describe "RSpec.configuration.mock_framework.framework_name" do
|
88
|
-
it "returns :rr" do
|
89
|
-
expect(RSpec.configuration.mock_framework.framework_name).to eq(:rr)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
"""
|
93
|
-
When I run `rspec example_spec.rb`
|
94
|
-
Then the examples should all pass
|
95
|
-
|
96
|
-
|
@@ -1,95 +0,0 @@
|
|
1
|
-
Feature: mock with rspec
|
2
|
-
|
3
|
-
RSpec uses its own mocking framework by default, or you can configure it
|
4
|
-
explicitly.
|
5
|
-
|
6
|
-
Scenario: passing message expectation
|
7
|
-
Given a file named "example_spec.rb" with:
|
8
|
-
"""ruby
|
9
|
-
RSpec.configure do |config|
|
10
|
-
config.mock_framework = :rspec
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "mocking with RSpec" do
|
14
|
-
it "passes when it should" do
|
15
|
-
receiver = double('receiver')
|
16
|
-
expect(receiver).to receive(:message)
|
17
|
-
receiver.message
|
18
|
-
end
|
19
|
-
end
|
20
|
-
"""
|
21
|
-
When I run `rspec example_spec.rb`
|
22
|
-
Then the examples should all pass
|
23
|
-
|
24
|
-
Scenario: failing message expecation
|
25
|
-
Given a file named "example_spec.rb" with:
|
26
|
-
"""ruby
|
27
|
-
RSpec.configure do |config|
|
28
|
-
config.mock_framework = :rspec
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "mocking with RSpec" do
|
32
|
-
it "fails when it should" do
|
33
|
-
receiver = double('receiver')
|
34
|
-
expect(receiver).to receive(:message)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
"""
|
38
|
-
When I run `rspec example_spec.rb`
|
39
|
-
Then the output should contain "1 example, 1 failure"
|
40
|
-
|
41
|
-
Scenario: failing message expectation in pending example (remains pending)
|
42
|
-
Given a file named "example_spec.rb" with:
|
43
|
-
"""ruby
|
44
|
-
RSpec.configure do |config|
|
45
|
-
config.mock_framework = :rspec
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "failed message expectation in a pending example" do
|
49
|
-
it "is listed as pending" do
|
50
|
-
pending
|
51
|
-
receiver = double('receiver')
|
52
|
-
expect(receiver).to receive(:message)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
"""
|
56
|
-
When I run `rspec example_spec.rb`
|
57
|
-
Then the output should contain "1 example, 0 failures, 1 pending"
|
58
|
-
And the exit status should be 0
|
59
|
-
|
60
|
-
Scenario: passing message expectation in pending example (fails)
|
61
|
-
Given a file named "example_spec.rb" with:
|
62
|
-
"""ruby
|
63
|
-
RSpec.configure do |config|
|
64
|
-
config.mock_framework = :rspec
|
65
|
-
end
|
66
|
-
|
67
|
-
describe "passing message expectation in a pending example" do
|
68
|
-
it "fails with FIXED" do
|
69
|
-
pending
|
70
|
-
receiver = double('receiver')
|
71
|
-
expect(receiver).to receive(:message)
|
72
|
-
receiver.message
|
73
|
-
end
|
74
|
-
end
|
75
|
-
"""
|
76
|
-
When I run `rspec example_spec.rb`
|
77
|
-
Then the output should contain "FIXED"
|
78
|
-
Then the output should contain "1 example, 1 failure"
|
79
|
-
And the exit status should be 1
|
80
|
-
|
81
|
-
Scenario: accessing RSpec.configuration.mock_framework.framework_name
|
82
|
-
Given a file named "example_spec.rb" with:
|
83
|
-
"""ruby
|
84
|
-
RSpec.configure do |config|
|
85
|
-
config.mock_framework = :rspec
|
86
|
-
end
|
87
|
-
|
88
|
-
describe "RSpec.configuration.mock_framework.framework_name" do
|
89
|
-
it "returns :rspec" do
|
90
|
-
expect(RSpec.configuration.mock_framework.framework_name).to eq(:rspec)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
"""
|
94
|
-
When I run `rspec example_spec.rb`
|
95
|
-
Then the examples should all pass
|
@@ -1,3 +0,0 @@
|
|
1
|
-
Sometimes you will have a failing example that can not be fixed, but is useful to keep around. For instance, the fix could depend on an upstream patch being merged, or the example is not supported on JRuby. RSpec provides two features for dealing with this scenario.
|
2
|
-
|
3
|
-
An example can either be marked as _skipped_, in which is it not executed, or _pending_ in which it is executed but failure will not cause a failure of the entire suite. When a pending example passes (i.e. the underlying reasons for it being marked pending is no longer present) it will fail to communicate to you that it should no longer be marked as pending.
|
@@ -1,118 +0,0 @@
|
|
1
|
-
Feature: pending examples
|
2
|
-
|
3
|
-
RSpec offers a number of different ways to indicate that an example is
|
4
|
-
disabled pending some action.
|
5
|
-
|
6
|
-
Scenario: pending any arbitrary reason with a failing example
|
7
|
-
Given a file named "pending_without_block_spec.rb" with:
|
8
|
-
"""ruby
|
9
|
-
describe "an example" do
|
10
|
-
it "is implemented but waiting" do
|
11
|
-
pending("something else getting finished")
|
12
|
-
fail
|
13
|
-
end
|
14
|
-
end
|
15
|
-
"""
|
16
|
-
When I run `rspec pending_without_block_spec.rb`
|
17
|
-
Then the exit status should be 0
|
18
|
-
And the output should contain "1 example, 0 failures, 1 pending"
|
19
|
-
And the output should contain:
|
20
|
-
"""
|
21
|
-
Pending:
|
22
|
-
an example is implemented but waiting
|
23
|
-
# something else getting finished
|
24
|
-
# ./pending_without_block_spec.rb:2
|
25
|
-
"""
|
26
|
-
Scenario: pending any arbitrary reason with a passing example
|
27
|
-
Given a file named "pending_with_passing_example_spec.rb" with:
|
28
|
-
"""ruby
|
29
|
-
describe "an example" do
|
30
|
-
it "is implemented but waiting" do
|
31
|
-
pending("something else getting finished")
|
32
|
-
expect(1).to be(1)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
"""
|
36
|
-
When I run `rspec pending_with_passing_example_spec.rb`
|
37
|
-
Then the exit status should not be 0
|
38
|
-
And the output should contain "1 example, 1 failure"
|
39
|
-
And the output should contain "FIXED"
|
40
|
-
And the output should contain "Expected pending 'something else getting finished' to fail. No Error was raised."
|
41
|
-
And the output should contain "pending_with_passing_example_spec.rb:2"
|
42
|
-
|
43
|
-
Scenario: pending for an example that is currently passing
|
44
|
-
Given a file named "pending_with_passing_block_spec.rb" with:
|
45
|
-
"""ruby
|
46
|
-
describe "an example" do
|
47
|
-
pending("something else getting finished") do
|
48
|
-
expect(1).to eq(1)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
"""
|
52
|
-
When I run `rspec pending_with_passing_block_spec.rb`
|
53
|
-
Then the exit status should not be 0
|
54
|
-
And the output should contain "1 example, 1 failure"
|
55
|
-
And the output should contain "FIXED"
|
56
|
-
And the output should contain "Expected pending 'No reason given' to fail. No Error was raised."
|
57
|
-
And the output should contain "pending_with_passing_block_spec.rb:2"
|
58
|
-
|
59
|
-
Scenario: pending for an example that is currently passing with a reason
|
60
|
-
Given a file named "pending_with_passing_block_spec.rb" with:
|
61
|
-
"""ruby
|
62
|
-
describe "an example" do
|
63
|
-
example("something else getting finished", :pending => 'unimplemented') do
|
64
|
-
expect(1).to eq(1)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
"""
|
68
|
-
When I run `rspec pending_with_passing_block_spec.rb`
|
69
|
-
Then the exit status should not be 0
|
70
|
-
And the output should contain "1 example, 1 failure"
|
71
|
-
And the output should contain "FIXED"
|
72
|
-
And the output should contain "Expected pending 'unimplemented' to fail. No Error was raised."
|
73
|
-
And the output should contain "pending_with_passing_block_spec.rb:2"
|
74
|
-
|
75
|
-
Scenario: example with no docstring and pending method using documentation formatter
|
76
|
-
Given a file named "pending_with_no_docstring_spec.rb" with:
|
77
|
-
"""ruby
|
78
|
-
describe "an example" do
|
79
|
-
it "checks something" do
|
80
|
-
expect(1).to eq(1)
|
81
|
-
end
|
82
|
-
specify do
|
83
|
-
pending
|
84
|
-
fail
|
85
|
-
end
|
86
|
-
end
|
87
|
-
"""
|
88
|
-
When I run `rspec pending_with_no_docstring_spec.rb --format documentation`
|
89
|
-
Then the exit status should be 0
|
90
|
-
And the output should contain "2 examples, 0 failures, 1 pending"
|
91
|
-
And the output should contain:
|
92
|
-
"""
|
93
|
-
an example
|
94
|
-
checks something
|
95
|
-
example at ./pending_with_no_docstring_spec.rb:5 (PENDING: No reason given)
|
96
|
-
"""
|
97
|
-
|
98
|
-
Scenario: pending with no docstring using documentation formatter
|
99
|
-
Given a file named "pending_with_no_docstring_spec.rb" with:
|
100
|
-
"""ruby
|
101
|
-
describe "an example" do
|
102
|
-
it "checks something" do
|
103
|
-
expect(1).to eq(1)
|
104
|
-
end
|
105
|
-
pending do
|
106
|
-
fail
|
107
|
-
end
|
108
|
-
end
|
109
|
-
"""
|
110
|
-
When I run `rspec pending_with_no_docstring_spec.rb --format documentation`
|
111
|
-
Then the exit status should be 0
|
112
|
-
And the output should contain "2 examples, 0 failures, 1 pending"
|
113
|
-
And the output should contain:
|
114
|
-
"""
|
115
|
-
an example
|
116
|
-
checks something
|
117
|
-
example at ./pending_with_no_docstring_spec.rb:5 (PENDING: No reason given)
|
118
|
-
"""
|