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,297 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
module RSpec::Core
|
|
4
|
-
describe OptionParser do
|
|
5
|
-
let(:output_file){ mock File }
|
|
6
|
-
|
|
7
|
-
before do
|
|
8
|
-
File.stub(:open).with("foo.txt",'w') { (output_file) }
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it "does not parse empty args" do
|
|
12
|
-
parser = Parser.new
|
|
13
|
-
OptionParser.should_not_receive(:new)
|
|
14
|
-
parser.parse!([])
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "proposes you to use --help and returns an error on incorrect argument" do
|
|
18
|
-
parser = Parser.new
|
|
19
|
-
option = "--my_wrong_arg"
|
|
20
|
-
|
|
21
|
-
parser.should_receive(:abort) do |msg|
|
|
22
|
-
expect(msg).to include('use --help', option)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
parser.parse!([option])
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
describe "--formatter" do
|
|
29
|
-
it "is deprecated" do
|
|
30
|
-
expect_deprecation_with_no_call_site(%r{`--formatter`})
|
|
31
|
-
Parser.parse!(%w[--formatter doc])
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it "gets converted to --format" do
|
|
35
|
-
options = Parser.parse!(%w[--formatter doc])
|
|
36
|
-
expect(options[:formatters].first).to eq(["doc"])
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
describe "--default_path" do
|
|
41
|
-
it "is deprecated" do
|
|
42
|
-
expect_deprecation_with_no_call_site(%r{`--default_path`})
|
|
43
|
-
Parser.parse!(%w[--default_path foo])
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it "gets converted to --default-path" do
|
|
47
|
-
options = Parser.parse!(%w[--default_path foo])
|
|
48
|
-
expect(options[:default_path]).to eq "foo"
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
describe "--line_number" do
|
|
53
|
-
it "is deprecated" do
|
|
54
|
-
expect_deprecation_with_no_call_site(%r{`--line-number`/`-l`})
|
|
55
|
-
Parser.parse!(%w[--line_number 3])
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
it "gets converted to --line-number" do
|
|
59
|
-
options = Parser.parse!(%w[--line_number 3])
|
|
60
|
-
expect(options[:line_numbers]).to eq ["3"]
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
describe "--default-path" do
|
|
65
|
-
it "sets the default path where RSpec looks for examples" do
|
|
66
|
-
options = Parser.parse!(%w[--default-path foo])
|
|
67
|
-
expect(options[:default_path]).to eq "foo"
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
%w[--line-number -l].each do |option|
|
|
72
|
-
describe option do
|
|
73
|
-
it "sets the line number of an example to run" do
|
|
74
|
-
options = Parser.parse!([option, "3"])
|
|
75
|
-
expect(options[:line_numbers]).to eq ["3"]
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
it "is deprecated" do
|
|
79
|
-
expect_deprecation_with_no_call_site(%r{`--line-number`/`-l`})
|
|
80
|
-
Parser.parse!([option, "3"])
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
%w[--format -f].each do |option|
|
|
86
|
-
describe option do
|
|
87
|
-
it "defines the formatter" do
|
|
88
|
-
options = Parser.parse!([option, 'doc'])
|
|
89
|
-
expect(options[:formatters].first).to eq(["doc"])
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
describe "--deprecation-out" do
|
|
95
|
-
it 'configures the deprecation stream' do
|
|
96
|
-
expect {
|
|
97
|
-
Parser.parse!(['--deprecation-out', 'path/to/file.log'])
|
|
98
|
-
}.to change { RSpec.configuration.deprecation_stream }.to('path/to/file.log')
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
it 'sets the deprecation stream before processing other options that issue deprecations' do
|
|
102
|
-
expect(RSpec).to receive(:deprecate) do
|
|
103
|
-
expect(RSpec.configuration.deprecation_stream).to eq('path/to/file.log')
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
Parser.parse!(['--line-number', '3', '--deprecation-out', 'path/to/file.log'])
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
it 'issues an appropriate error when no file arg is provided' do
|
|
110
|
-
out_error = Parser.parse!(['--out']) rescue $!
|
|
111
|
-
expect {
|
|
112
|
-
Parser.parse!(['--deprecation-out'])
|
|
113
|
-
}.to raise_error(out_error.class, out_error.message.gsub('--out', '--deprecation-out'))
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
%w[--out -o].each do |option|
|
|
118
|
-
describe option do
|
|
119
|
-
let(:options) { Parser.parse!([option, 'out.txt']) }
|
|
120
|
-
|
|
121
|
-
it "sets the output stream for the formatter" do
|
|
122
|
-
expect(options[:formatters].last).to eq(['progress', 'out.txt'])
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
context "with multiple formatters" do
|
|
126
|
-
context "after last formatter" do
|
|
127
|
-
it "sets the output stream for the last formatter" do
|
|
128
|
-
options = Parser.parse!(['-f', 'progress', '-f', 'doc', option, 'out.txt'])
|
|
129
|
-
expect(options[:formatters][0]).to eq(['progress'])
|
|
130
|
-
expect(options[:formatters][1]).to eq(['doc', 'out.txt'])
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
context "after first formatter" do
|
|
135
|
-
it "sets the output stream for the first formatter" do
|
|
136
|
-
options = Parser.parse!(['-f', 'progress', option, 'out.txt', '-f', 'doc'])
|
|
137
|
-
expect(options[:formatters][0]).to eq(['progress', 'out.txt'])
|
|
138
|
-
expect(options[:formatters][1]).to eq(['doc'])
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
%w[--example -e].each do |option|
|
|
146
|
-
describe option do
|
|
147
|
-
it "escapes the arg" do
|
|
148
|
-
options = Parser.parse!([option, "this (and that)"])
|
|
149
|
-
expect(options[:full_description].length).to eq(1)
|
|
150
|
-
expect("this (and that)").to match(options[:full_description].first)
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
%w[--pattern -P].each do |option|
|
|
156
|
-
describe option do
|
|
157
|
-
it "sets the filename pattern" do
|
|
158
|
-
options = Parser.parse!([option, 'spec/**/*.spec'])
|
|
159
|
-
expect(options[:pattern]).to eq('spec/**/*.spec')
|
|
160
|
-
end
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
%w[--tag -t].each do |option|
|
|
165
|
-
describe option do
|
|
166
|
-
context "without ~" do
|
|
167
|
-
it "treats no value as true" do
|
|
168
|
-
options = Parser.parse!([option, 'foo'])
|
|
169
|
-
expect(options[:inclusion_filter]).to eq(:foo => true)
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
it "treats 'true' as true" do
|
|
173
|
-
options = Parser.parse!([option, 'foo:true'])
|
|
174
|
-
expect(options[:inclusion_filter]).to eq(:foo => true)
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
it "treats 'nil' as nil" do
|
|
178
|
-
options = Parser.parse!([option, 'foo:nil'])
|
|
179
|
-
expect(options[:inclusion_filter]).to eq(:foo => nil)
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
it "treats 'false' as false" do
|
|
183
|
-
options = Parser.parse!([option, 'foo:false'])
|
|
184
|
-
expect(options[:inclusion_filter]).to eq(:foo => false)
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
it "merges muliple invocations" do
|
|
188
|
-
options = Parser.parse!([option, 'foo:false', option, 'bar:true', option, 'foo:true'])
|
|
189
|
-
expect(options[:inclusion_filter]).to eq(:foo => true, :bar => true)
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
it "treats 'any_string' as 'any_string'" do
|
|
193
|
-
options = Parser.parse!([option, 'foo:any_string'])
|
|
194
|
-
expect(options[:inclusion_filter]).to eq(:foo => 'any_string')
|
|
195
|
-
end
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
context "with ~" do
|
|
199
|
-
it "treats no value as true" do
|
|
200
|
-
options = Parser.parse!([option, '~foo'])
|
|
201
|
-
expect(options[:exclusion_filter]).to eq(:foo => true)
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
it "treats 'true' as true" do
|
|
205
|
-
options = Parser.parse!([option, '~foo:true'])
|
|
206
|
-
expect(options[:exclusion_filter]).to eq(:foo => true)
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
it "treats 'nil' as nil" do
|
|
210
|
-
options = Parser.parse!([option, '~foo:nil'])
|
|
211
|
-
expect(options[:exclusion_filter]).to eq(:foo => nil)
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
it "treats 'false' as false" do
|
|
215
|
-
options = Parser.parse!([option, '~foo:false'])
|
|
216
|
-
expect(options[:exclusion_filter]).to eq(:foo => false)
|
|
217
|
-
end
|
|
218
|
-
end
|
|
219
|
-
end
|
|
220
|
-
end
|
|
221
|
-
|
|
222
|
-
describe "--order" do
|
|
223
|
-
it "is nil by default" do
|
|
224
|
-
expect(Parser.parse!([])[:order]).to be_nil
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
%w[rand random].each do |option|
|
|
228
|
-
context "with #{option}" do
|
|
229
|
-
it "defines the order as random" do
|
|
230
|
-
options = Parser.parse!(['--order', option])
|
|
231
|
-
expect(options[:order]).to eq(option)
|
|
232
|
-
end
|
|
233
|
-
end
|
|
234
|
-
end
|
|
235
|
-
|
|
236
|
-
context "with default" do
|
|
237
|
-
it 'defines the order as defined' do
|
|
238
|
-
options = Parser.parse!(['--order', 'default'])
|
|
239
|
-
expect(options[:order]).to eq('defined')
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
it 'prints a deprecation warning' do
|
|
243
|
-
expect_deprecation_with_no_call_site(/default/)
|
|
244
|
-
Parser.parse!(['--order', 'default'])
|
|
245
|
-
end
|
|
246
|
-
end
|
|
247
|
-
|
|
248
|
-
context "with defined" do
|
|
249
|
-
it 'defines the order as defined' do
|
|
250
|
-
options = Parser.parse!(['--order', 'defined'])
|
|
251
|
-
expect(options[:order]).to eq('defined')
|
|
252
|
-
end
|
|
253
|
-
end
|
|
254
|
-
end
|
|
255
|
-
|
|
256
|
-
describe "--seed" do
|
|
257
|
-
it "sets the order to rand:SEED" do
|
|
258
|
-
options = Parser.parse!(%w[--seed 123])
|
|
259
|
-
expect(options[:order]).to eq("rand:123")
|
|
260
|
-
end
|
|
261
|
-
end
|
|
262
|
-
|
|
263
|
-
describe '--profile' do
|
|
264
|
-
it 'sets profile_examples to true by default' do
|
|
265
|
-
options = Parser.parse!(%w[--profile])
|
|
266
|
-
expect(options[:profile_examples]).to eq true
|
|
267
|
-
end
|
|
268
|
-
|
|
269
|
-
it 'sets profile_examples to supplied int' do
|
|
270
|
-
options = Parser.parse!(%w[--profile 10])
|
|
271
|
-
expect(options[:profile_examples]).to eq 10
|
|
272
|
-
end
|
|
273
|
-
|
|
274
|
-
it 'sets profile_examples to true when accidentally combined with path' do
|
|
275
|
-
allow(Kernel).to receive(:warn)
|
|
276
|
-
options = Parser.parse!(%w[--profile some/path])
|
|
277
|
-
expect(options[:profile_examples]).to eq true
|
|
278
|
-
end
|
|
279
|
-
|
|
280
|
-
it 'warns when accidentally combined with path' do
|
|
281
|
-
expect(Kernel).to receive(:warn) do |msg|
|
|
282
|
-
expect(msg).to match "Non integer specified as profile count"
|
|
283
|
-
end
|
|
284
|
-
options = Parser.parse!(%w[--profile some/path])
|
|
285
|
-
expect(options[:profile_examples]).to eq true
|
|
286
|
-
end
|
|
287
|
-
end
|
|
288
|
-
|
|
289
|
-
describe '--warning' do
|
|
290
|
-
it 'enables warnings' do
|
|
291
|
-
options = Parser.parse!(%w[--warnings])
|
|
292
|
-
expect(options[:warnings]).to eq true
|
|
293
|
-
end
|
|
294
|
-
end
|
|
295
|
-
|
|
296
|
-
end
|
|
297
|
-
end
|
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe "an example" do
|
|
4
|
-
matcher :be_pending_with do |message|
|
|
5
|
-
match do |example|
|
|
6
|
-
example.pending? && example.metadata[:execution_result][:pending_message] == message
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
failure_message_for_should do |example|
|
|
10
|
-
"expected: example pending with #{message.inspect}\n got: #{example.metadata[:execution_result][:pending_message].inspect}"
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
context "declared pending with metadata" do
|
|
15
|
-
it "uses the value assigned to :pending as the message" do
|
|
16
|
-
group = RSpec::Core::ExampleGroup.describe('group') do
|
|
17
|
-
example "example", :pending => 'just because' do
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
example = group.examples.first
|
|
21
|
-
example.run(group.new, double.as_null_object)
|
|
22
|
-
expect(example).to be_pending_with('just because')
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it "sets the message to 'No reason given' if :pending => true" do
|
|
26
|
-
group = RSpec::Core::ExampleGroup.describe('group') do
|
|
27
|
-
example "example", :pending => true do
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
example = group.examples.first
|
|
31
|
-
example.run(group.new, double.as_null_object)
|
|
32
|
-
expect(example).to be_pending_with('No reason given')
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
context "with no block" do
|
|
37
|
-
it "is listed as pending with 'Not yet implemented'" do
|
|
38
|
-
group = RSpec::Core::ExampleGroup.describe('group') do
|
|
39
|
-
it "has no block"
|
|
40
|
-
end
|
|
41
|
-
example = group.examples.first
|
|
42
|
-
example.run(group.new, double.as_null_object)
|
|
43
|
-
expect(example).to be_pending_with('Not yet implemented')
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
context "with no args" do
|
|
48
|
-
it "is listed as pending with the default message" do
|
|
49
|
-
group = RSpec::Core::ExampleGroup.describe('group') do
|
|
50
|
-
it "does something" do
|
|
51
|
-
pending
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
example = group.examples.first
|
|
55
|
-
example.run(group.new, double.as_null_object)
|
|
56
|
-
expect(example).to be_pending_with(RSpec::Core::Pending::NO_REASON_GIVEN)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it 'shows upgrade warning' do
|
|
60
|
-
expect_warn_deprecation_with_call_site(
|
|
61
|
-
"pending_example_spec.rb", __LINE__ + 4
|
|
62
|
-
)
|
|
63
|
-
group = RSpec::Core::ExampleGroup.describe('group') do
|
|
64
|
-
it "does something" do
|
|
65
|
-
pending
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
example = group.examples.first
|
|
69
|
-
example.run(group.new, double.as_null_object)
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
context "with no docstring" do
|
|
74
|
-
context "declared with the pending method" do
|
|
75
|
-
it "does not have an auto-generated description" do
|
|
76
|
-
group = RSpec::Core::ExampleGroup.describe('group') do
|
|
77
|
-
it "checks something" do
|
|
78
|
-
expect((3+4)).to eq(7)
|
|
79
|
-
end
|
|
80
|
-
pending do
|
|
81
|
-
expect("string".reverse).to eq("gnirts")
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
example = group.examples.last
|
|
85
|
-
example.run(group.new, double.as_null_object)
|
|
86
|
-
expect(example.description).to match(/example at/)
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
context "after another example with some assertion" do
|
|
91
|
-
it "does not show any message" do
|
|
92
|
-
group = RSpec::Core::ExampleGroup.describe('group') do
|
|
93
|
-
it "checks something" do
|
|
94
|
-
expect((3+4)).to eq(7)
|
|
95
|
-
end
|
|
96
|
-
specify do
|
|
97
|
-
pending
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
example = group.examples.last
|
|
101
|
-
example.run(group.new, double.as_null_object)
|
|
102
|
-
expect(example.description).to match(/example at/)
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
context "with a message" do
|
|
108
|
-
it "is listed as pending with the supplied message" do
|
|
109
|
-
group = RSpec::Core::ExampleGroup.describe('group') do
|
|
110
|
-
it "does something" do
|
|
111
|
-
pending("just because")
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
example = group.examples.first
|
|
115
|
-
example.run(group.new, double.as_null_object)
|
|
116
|
-
expect(example).to be_pending_with('just because')
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
context "skip with a block" do
|
|
121
|
-
it "does not execute the block" do
|
|
122
|
-
called = false
|
|
123
|
-
group = RSpec::Core::ExampleGroup.describe('group') do
|
|
124
|
-
it "does something" do
|
|
125
|
-
skip { called = true }
|
|
126
|
-
end
|
|
127
|
-
end
|
|
128
|
-
example = group.examples.first
|
|
129
|
-
example.run(group.new, double.as_null_object)
|
|
130
|
-
expect(called).to eq(false)
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
context "with a block" do
|
|
135
|
-
def run_example(*pending_args, &block)
|
|
136
|
-
group = RSpec::Core::ExampleGroup.describe('group') do
|
|
137
|
-
it "does something" do
|
|
138
|
-
pending(*pending_args) { block.call if block }
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
example = group.examples.first
|
|
142
|
-
example.run(group.new, double.as_null_object)
|
|
143
|
-
example
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
it 'shows upgrade warning' do
|
|
147
|
-
expect_warn_deprecation_with_call_site(
|
|
148
|
-
"pending_example_spec.rb", __LINE__ + 4
|
|
149
|
-
)
|
|
150
|
-
group = RSpec::Core::ExampleGroup.describe('group') do
|
|
151
|
-
it "does something" do
|
|
152
|
-
pending {}
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
example = group.examples.first
|
|
156
|
-
example.run(group.new, double.as_null_object)
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
context "that fails" do
|
|
160
|
-
def run_example(*pending_args)
|
|
161
|
-
super(*pending_args) { raise ArgumentError.new }
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
context "when given no options" do
|
|
165
|
-
it "is listed as pending with the supplied message" do
|
|
166
|
-
expect(run_example("just because")).to be_pending_with("just because")
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
it "is listed as pending with the default message when no message is given" do
|
|
170
|
-
expect(run_example).to be_pending_with(RSpec::Core::Pending::NO_REASON_GIVEN)
|
|
171
|
-
end
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
context "when given a truthy :if option" do
|
|
175
|
-
it "is listed as pending with the supplied message" do
|
|
176
|
-
expect(run_example("just because", :if => true)).to be_pending_with("just because")
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
it "is listed as pending with the default message when no message is given" do
|
|
180
|
-
expect(run_example(:if => true)).to be_pending_with(RSpec::Core::Pending::NO_REASON_GIVEN)
|
|
181
|
-
end
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
context "when given a falsey :if option" do
|
|
185
|
-
it "runs the example and fails" do
|
|
186
|
-
expect(run_example( :if => false)).to fail_with(ArgumentError)
|
|
187
|
-
expect(run_example("just because", :if => false)).to fail_with(ArgumentError)
|
|
188
|
-
end
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
context "when given a truthy :unless option" do
|
|
192
|
-
it "runs the example and fails" do
|
|
193
|
-
expect(run_example( :unless => true)).to fail_with(ArgumentError)
|
|
194
|
-
expect(run_example("just because", :unless => true)).to fail_with(ArgumentError)
|
|
195
|
-
end
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
context "when given a falsey :unless option" do
|
|
199
|
-
it "is listed as pending with the supplied message" do
|
|
200
|
-
expect(run_example("just because", :unless => false)).to be_pending_with("just because")
|
|
201
|
-
end
|
|
202
|
-
|
|
203
|
-
it "is listed as pending with the default message when no message is given" do
|
|
204
|
-
expect(run_example(:unless => false)).to be_pending_with(RSpec::Core::Pending::NO_REASON_GIVEN)
|
|
205
|
-
end
|
|
206
|
-
end
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
context "that fails due to a failed message expectation" do
|
|
210
|
-
def run_example(*pending_args)
|
|
211
|
-
super(*pending_args) { "foo".should_receive(:bar) }
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
it "passes" do
|
|
215
|
-
expect(run_example("just because")).to be_pending
|
|
216
|
-
end
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
context "that passes" do
|
|
220
|
-
def run_example(*pending_args)
|
|
221
|
-
super(*pending_args) { expect(3).to eq(3) }
|
|
222
|
-
end
|
|
223
|
-
|
|
224
|
-
context "when given no options" do
|
|
225
|
-
it "fails with a PendingExampleFixedError" do
|
|
226
|
-
expect(run_example("just because")).to fail_with(RSpec::Core::Pending::PendingExampleFixedError)
|
|
227
|
-
expect(run_example).to fail_with(RSpec::Core::Pending::PendingExampleFixedError)
|
|
228
|
-
end
|
|
229
|
-
end
|
|
230
|
-
|
|
231
|
-
context "when given a truthy :if option" do
|
|
232
|
-
it "fails with a PendingExampleFixedError" do
|
|
233
|
-
expect(run_example("just because", :if => true)).to fail_with(RSpec::Core::Pending::PendingExampleFixedError)
|
|
234
|
-
expect(run_example( :if => true)).to fail_with(RSpec::Core::Pending::PendingExampleFixedError)
|
|
235
|
-
end
|
|
236
|
-
end
|
|
237
|
-
|
|
238
|
-
context "when given a falsey :if option" do
|
|
239
|
-
it "runs the example and it passes" do
|
|
240
|
-
expect(run_example( :if => false)).to pass
|
|
241
|
-
expect(run_example("just because", :if => false)).to pass
|
|
242
|
-
end
|
|
243
|
-
end
|
|
244
|
-
|
|
245
|
-
context "when given a truthy :unless option" do
|
|
246
|
-
it "runs the example and it passes" do
|
|
247
|
-
expect(run_example( :unless => true)).to pass
|
|
248
|
-
expect(run_example("just because", :unless => true)).to pass
|
|
249
|
-
end
|
|
250
|
-
end
|
|
251
|
-
|
|
252
|
-
context "when given a falsey :unless option" do
|
|
253
|
-
it "fails with a PendingExampleFixedError" do
|
|
254
|
-
expect(run_example("just because", :unless => false)).to fail_with(RSpec::Core::Pending::PendingExampleFixedError)
|
|
255
|
-
expect(run_example( :unless => false)).to fail_with(RSpec::Core::Pending::PendingExampleFixedError)
|
|
256
|
-
end
|
|
257
|
-
end
|
|
258
|
-
end
|
|
259
|
-
end
|
|
260
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe RSpec::Core::Pending do
|
|
4
|
-
describe 'PendingDeclaredInExample' do
|
|
5
|
-
before { allow_deprecation }
|
|
6
|
-
|
|
7
|
-
it 'is an alternate reference to SkipDeclaredInExample' do
|
|
8
|
-
expect(::RSpec::Core::Pending::PendingDeclaredInExample).to \
|
|
9
|
-
be(::RSpec::Core::Pending::SkipDeclaredInExample)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it 'prints a deprecation warning' do
|
|
13
|
-
expect_deprecation_with_call_site(
|
|
14
|
-
__FILE__,
|
|
15
|
-
__LINE__ + 3,
|
|
16
|
-
/PendingDeclaredInExample/
|
|
17
|
-
)
|
|
18
|
-
::RSpec::Core::Pending::PendingDeclaredInExample
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
specify 'the const_missing hook raises for other undefined constants' do
|
|
22
|
-
expect {
|
|
23
|
-
::RSpec::Core::Pending::SomeUndefinedConst
|
|
24
|
-
}.to raise_error(NameError, /uninitialized constant/)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|