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,229 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module RSpec::Core
|
4
|
-
RSpec.describe FilterManager do
|
5
|
-
def opposite(name)
|
6
|
-
name =~ /^in/ ? name.sub(/^(in)/,'ex') : name.sub(/^(ex)/,'in')
|
7
|
-
end
|
8
|
-
|
9
|
-
%w[include inclusions exclude exclusions].each_slice(2) do |name, type|
|
10
|
-
describe "##{name}" do
|
11
|
-
it "merges #{type}" do
|
12
|
-
filter_manager = FilterManager.new
|
13
|
-
filter_manager.exclusions.clear # defaults
|
14
|
-
filter_manager.send name, :foo => :bar
|
15
|
-
filter_manager.send name, :baz => :bam
|
16
|
-
expect(filter_manager.send(type)).to eq(:foo => :bar, :baz => :bam)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "overrides previous #{type} with (via merge)" do
|
20
|
-
filter_manager = FilterManager.new
|
21
|
-
filter_manager.exclusions.clear # defaults
|
22
|
-
filter_manager.send name, :foo => 1
|
23
|
-
filter_manager.send name, :foo => 2
|
24
|
-
expect(filter_manager.send(type)).to eq(:foo => 2)
|
25
|
-
end
|
26
|
-
|
27
|
-
it "deletes matching opposites" do
|
28
|
-
filter_manager = FilterManager.new
|
29
|
-
filter_manager.exclusions.clear # defaults
|
30
|
-
filter_manager.send opposite(name), :foo => 1
|
31
|
-
filter_manager.send name, :foo => 2
|
32
|
-
expect(filter_manager.send(type)).to eq(:foo => 2)
|
33
|
-
expect(filter_manager.send(opposite(type))).to be_empty
|
34
|
-
end
|
35
|
-
|
36
|
-
if name == "include"
|
37
|
-
[:locations, :line_numbers, :full_description].each do |filter|
|
38
|
-
context "with :#{filter}" do
|
39
|
-
it "clears previous inclusions" do
|
40
|
-
filter_manager = FilterManager.new
|
41
|
-
filter_manager.include :foo => :bar
|
42
|
-
filter_manager.include filter => "value"
|
43
|
-
expect(filter_manager.inclusions).to eq({filter => "value"})
|
44
|
-
end
|
45
|
-
|
46
|
-
it "clears previous exclusion" do
|
47
|
-
filter_manager = FilterManager.new
|
48
|
-
filter_manager.include :foo => :bar
|
49
|
-
filter_manager.include filter => "value"
|
50
|
-
expect(filter_manager.exclusions).to be_empty
|
51
|
-
end
|
52
|
-
|
53
|
-
it "does nothing when :#{filter} previously set" do
|
54
|
-
filter_manager = FilterManager.new
|
55
|
-
filter_manager.include filter => "a_value"
|
56
|
-
filter_manager.include :foo => :bar
|
57
|
-
expect(filter_manager.inclusions).to eq(filter => "a_value")
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe "##{name}!" do
|
65
|
-
it "replaces existing #{type}" do
|
66
|
-
filter_manager = FilterManager.new
|
67
|
-
filter_manager.exclusions.clear # defaults
|
68
|
-
filter_manager.send name, :foo => 1, :bar => 2
|
69
|
-
filter_manager.send "#{name}!", :foo => 3
|
70
|
-
expect(filter_manager.send(type)).to eq(:foo => 3)
|
71
|
-
end
|
72
|
-
|
73
|
-
it "deletes matching opposites" do
|
74
|
-
filter_manager = FilterManager.new
|
75
|
-
filter_manager.exclusions.clear # defaults
|
76
|
-
filter_manager.send opposite(name), :foo => 1
|
77
|
-
filter_manager.send "#{name}!", :foo => 2
|
78
|
-
expect(filter_manager.send(type)).to eq(:foo => 2)
|
79
|
-
expect(filter_manager.send(opposite(type))).to be_empty
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe "##{name}_with_low_priority" do
|
84
|
-
it "ignores new #{type} if same key exists" do
|
85
|
-
filter_manager = FilterManager.new
|
86
|
-
filter_manager.exclusions.clear # defaults
|
87
|
-
filter_manager.send name, :foo => 1
|
88
|
-
filter_manager.send "#{name}_with_low_priority", :foo => 2
|
89
|
-
expect(filter_manager.send(type)).to eq(:foo => 1)
|
90
|
-
end
|
91
|
-
|
92
|
-
it "ignores new #{type} if same key exists in opposite" do
|
93
|
-
filter_manager = FilterManager.new
|
94
|
-
filter_manager.exclusions.clear # defaults
|
95
|
-
filter_manager.send opposite(name), :foo => 1
|
96
|
-
filter_manager.send "#{name}_with_low_priority", :foo => 1
|
97
|
-
expect(filter_manager.send(type)).to be_empty
|
98
|
-
expect(filter_manager.send(opposite(type))).to eq(:foo => 1)
|
99
|
-
end
|
100
|
-
|
101
|
-
it "keeps new #{type} if same key exists in opposite but values are different" do
|
102
|
-
filter_manager = FilterManager.new
|
103
|
-
filter_manager.exclusions.clear # defaults
|
104
|
-
filter_manager.send opposite(name), :foo => 1
|
105
|
-
filter_manager.send "#{name}_with_low_priority", :foo => 2
|
106
|
-
expect(filter_manager.send(type)).to eq(:foo => 2)
|
107
|
-
expect(filter_manager.send(opposite(type))).to eq(:foo => 1)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
describe "#prune" do
|
113
|
-
def filterable_object_with(args = {})
|
114
|
-
object = double('a filterable object')
|
115
|
-
allow(object).to receive(:any_apply?) { |f| Metadata.new(args).any_apply?(f) }
|
116
|
-
object
|
117
|
-
end
|
118
|
-
|
119
|
-
it "includes objects with tags matching inclusions" do
|
120
|
-
included = filterable_object_with({:foo => :bar})
|
121
|
-
excluded = filterable_object_with
|
122
|
-
filter_manager = FilterManager.new
|
123
|
-
filter_manager.include :foo => :bar
|
124
|
-
expect(filter_manager.prune([included, excluded])).to eq([included])
|
125
|
-
end
|
126
|
-
|
127
|
-
it "excludes objects with tags matching exclusions" do
|
128
|
-
included = filterable_object_with
|
129
|
-
excluded = filterable_object_with({:foo => :bar})
|
130
|
-
filter_manager = FilterManager.new
|
131
|
-
filter_manager.exclude :foo => :bar
|
132
|
-
expect(filter_manager.prune([included, excluded])).to eq([included])
|
133
|
-
end
|
134
|
-
|
135
|
-
it "prefers exclusion when matches previously set inclusion" do
|
136
|
-
included = filterable_object_with
|
137
|
-
excluded = filterable_object_with({:foo => :bar})
|
138
|
-
filter_manager = FilterManager.new
|
139
|
-
filter_manager.include :foo => :bar
|
140
|
-
filter_manager.exclude :foo => :bar
|
141
|
-
expect(filter_manager.prune([included, excluded])).to eq([included])
|
142
|
-
end
|
143
|
-
|
144
|
-
it "prefers inclusion when matches previously set exclusion" do
|
145
|
-
included = filterable_object_with({:foo => :bar})
|
146
|
-
excluded = filterable_object_with
|
147
|
-
filter_manager = FilterManager.new
|
148
|
-
filter_manager.exclude :foo => :bar
|
149
|
-
filter_manager.include :foo => :bar
|
150
|
-
expect(filter_manager.prune([included, excluded])).to eq([included])
|
151
|
-
end
|
152
|
-
|
153
|
-
it "prefers previously set inclusion when exclusion matches but has lower priority" do
|
154
|
-
included = filterable_object_with({:foo => :bar})
|
155
|
-
excluded = filterable_object_with
|
156
|
-
filter_manager = FilterManager.new
|
157
|
-
filter_manager.include :foo => :bar
|
158
|
-
filter_manager.exclude_with_low_priority :foo => :bar
|
159
|
-
expect(filter_manager.prune([included, excluded])).to eq([included])
|
160
|
-
end
|
161
|
-
|
162
|
-
it "prefers previously set exclusion when inclusion matches but has lower priority" do
|
163
|
-
included = filterable_object_with
|
164
|
-
excluded = filterable_object_with({:foo => :bar})
|
165
|
-
filter_manager = FilterManager.new
|
166
|
-
filter_manager.exclude :foo => :bar
|
167
|
-
filter_manager.include_with_low_priority :foo => :bar
|
168
|
-
expect(filter_manager.prune([included, excluded])).to eq([included])
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
describe "#inclusions#description" do
|
173
|
-
it 'cleans up the description' do
|
174
|
-
project_dir = File.expand_path('.')
|
175
|
-
expect(lambda { }.inspect).to include(project_dir)
|
176
|
-
expect(lambda { }.inspect).to include(' (lambda)') if RUBY_VERSION > '1.9'
|
177
|
-
expect(lambda { }.inspect).to include('0x')
|
178
|
-
|
179
|
-
filter_manager = FilterManager.new
|
180
|
-
filter_manager.include :foo => lambda { }
|
181
|
-
|
182
|
-
expect(filter_manager.inclusions.description).not_to include(project_dir)
|
183
|
-
expect(filter_manager.inclusions.description).not_to include(' (lambda)')
|
184
|
-
expect(filter_manager.inclusions.description).not_to include('0x')
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
describe "#exclusions#description" do
|
189
|
-
it 'cleans up the description' do
|
190
|
-
project_dir = File.expand_path('.')
|
191
|
-
expect(lambda { }.inspect).to include(project_dir)
|
192
|
-
expect(lambda { }.inspect).to include(' (lambda)') if RUBY_VERSION > '1.9'
|
193
|
-
expect(lambda { }.inspect).to include('0x')
|
194
|
-
|
195
|
-
filter_manager = FilterManager.new
|
196
|
-
filter_manager.exclude :foo => lambda { }
|
197
|
-
|
198
|
-
expect(filter_manager.exclusions.description).not_to include(project_dir)
|
199
|
-
expect(filter_manager.exclusions.description).not_to include(' (lambda)')
|
200
|
-
expect(filter_manager.exclusions.description).not_to include('0x')
|
201
|
-
end
|
202
|
-
|
203
|
-
it 'returns `{}` when it only contains the default filters' do
|
204
|
-
filter_manager = FilterManager.new
|
205
|
-
expect(filter_manager.exclusions.description).to eq({}.inspect)
|
206
|
-
end
|
207
|
-
|
208
|
-
it 'includes other filters' do
|
209
|
-
filter_manager = FilterManager.new
|
210
|
-
filter_manager.exclude :foo => :bar
|
211
|
-
expect(filter_manager.exclusions.description).to eq({ :foo => :bar }.inspect)
|
212
|
-
end
|
213
|
-
|
214
|
-
it 'includes an overriden :if filter' do
|
215
|
-
allow(RSpec).to receive(:deprecate)
|
216
|
-
filter_manager = FilterManager.new
|
217
|
-
filter_manager.exclude :if => :custom_filter
|
218
|
-
expect(filter_manager.exclusions.description).to eq({ :if => :custom_filter }.inspect)
|
219
|
-
end
|
220
|
-
|
221
|
-
it 'includes an overriden :unless filter' do
|
222
|
-
allow(RSpec).to receive(:deprecate)
|
223
|
-
filter_manager = FilterManager.new
|
224
|
-
filter_manager.exclude :unless => :custom_filter
|
225
|
-
expect(filter_manager.exclusions.description).to eq({ :unless => :custom_filter }.inspect)
|
226
|
-
end
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rspec/core/formatters/base_formatter'
|
3
|
-
|
4
|
-
RSpec.describe RSpec::Core::Formatters::BaseFormatter do
|
5
|
-
include FormatterSupport
|
6
|
-
|
7
|
-
describe "read_failed_line" do
|
8
|
-
it "deals gracefully with a heterogeneous language stack trace" do
|
9
|
-
exception = double(:Exception, :backtrace => [
|
10
|
-
"at Object.prototypeMethod (foo:331:18)",
|
11
|
-
"at Array.forEach (native)",
|
12
|
-
"at a_named_javascript_function (/some/javascript/file.js:39:5)",
|
13
|
-
"/some/line/of/ruby.rb:14"
|
14
|
-
])
|
15
|
-
example = double(:Example, :file_path => __FILE__)
|
16
|
-
expect {
|
17
|
-
formatter.send(:read_failed_line, exception, example)
|
18
|
-
}.not_to raise_error
|
19
|
-
end
|
20
|
-
|
21
|
-
it "deals gracefully with a security error" do
|
22
|
-
exception = double(:Exception, :backtrace => [ "#{__FILE__}:#{__LINE__}"])
|
23
|
-
example = double(:Example, :file_path => __FILE__)
|
24
|
-
safely do
|
25
|
-
expect {
|
26
|
-
formatter.send(:read_failed_line, exception, example)
|
27
|
-
}.not_to raise_error
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context "when ruby reports a bogus line number in the stack trace" do
|
32
|
-
it "reports the filename and that it was unable to find the matching line" do
|
33
|
-
exception = double(:Exception, :backtrace => [ "#{__FILE__}:10000000" ])
|
34
|
-
example = double(:Example, :file_path => __FILE__)
|
35
|
-
|
36
|
-
msg = formatter.send(:read_failed_line, exception, example)
|
37
|
-
expect(msg).to include("Unable to find matching line")
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context "when String alias to_int to_i" do
|
42
|
-
before do
|
43
|
-
String.class_eval do
|
44
|
-
alias :to_int :to_i
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
after do
|
49
|
-
String.class_eval do
|
50
|
-
undef to_int
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
it "doesn't hang when file exists" do
|
55
|
-
exception = double(:Exception, :backtrace => [ "#{__FILE__}:#{__LINE__}"])
|
56
|
-
|
57
|
-
example = double(:Example, :file_path => __FILE__)
|
58
|
-
expect(formatter.send(:read_failed_line, exception, example)).to eql(
|
59
|
-
%Q{ exception = double(:Exception, :backtrace => [ "\#{__FILE__}:\#{__LINE__}"])\n})
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,303 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rspec/core/formatters/base_text_formatter'
|
3
|
-
|
4
|
-
RSpec.describe RSpec::Core::Formatters::BaseTextFormatter do
|
5
|
-
include FormatterSupport
|
6
|
-
|
7
|
-
describe "#dump_summary" do
|
8
|
-
it "with 0s outputs pluralized (excluding pending)" do
|
9
|
-
send_notification :dump_summary, summary_notification(0, 0, 0, 0)
|
10
|
-
expect(output.string).to match("0 examples, 0 failures")
|
11
|
-
end
|
12
|
-
|
13
|
-
it "with 1s outputs singular (including pending)" do
|
14
|
-
send_notification :dump_summary, summary_notification(1, 1, 1, 1)
|
15
|
-
expect(output.string).to match("1 example, 1 failure, 1 pending")
|
16
|
-
end
|
17
|
-
|
18
|
-
it "with 2s outputs pluralized (including pending)" do
|
19
|
-
send_notification :dump_summary, summary_notification(2, 2, 2, 2)
|
20
|
-
expect(output.string).to match("2 examples, 2 failures, 2 pending")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "#dump_commands_to_rerun_failed_examples" do
|
25
|
-
it "includes command to re-run each failed example" do
|
26
|
-
group = RSpec::Core::ExampleGroup.describe("example group") do
|
27
|
-
it("fails") { fail }
|
28
|
-
end
|
29
|
-
line = __LINE__ - 2
|
30
|
-
group.run(reporter)
|
31
|
-
formatter.dump_commands_to_rerun_failed_examples
|
32
|
-
expect(output.string).to include("rspec #{RSpec::Core::Metadata::relative_path("#{__FILE__}:#{line}")} # example group fails")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "#dump_failures" do
|
37
|
-
let(:group) { RSpec::Core::ExampleGroup.describe("group name") }
|
38
|
-
|
39
|
-
before { allow(RSpec.configuration).to receive(:color_enabled?) { false } }
|
40
|
-
|
41
|
-
def run_all_and_dump_failures
|
42
|
-
group.run(reporter)
|
43
|
-
send_notification :dump_failures, null_notification
|
44
|
-
end
|
45
|
-
|
46
|
-
it "preserves formatting" do
|
47
|
-
group.example("example name") { expect("this").to eq("that") }
|
48
|
-
|
49
|
-
run_all_and_dump_failures
|
50
|
-
|
51
|
-
expect(output.string).to match(/group name example name/m)
|
52
|
-
expect(output.string).to match(/(\s+)expected: \"that\"\n\1 got: \"this\"/m)
|
53
|
-
end
|
54
|
-
|
55
|
-
context "with an exception without a message" do
|
56
|
-
it "does not throw NoMethodError" do
|
57
|
-
exception_without_message = Exception.new()
|
58
|
-
allow(exception_without_message).to receive(:message) { nil }
|
59
|
-
group.example("example name") { raise exception_without_message }
|
60
|
-
expect { run_all_and_dump_failures }.not_to raise_error
|
61
|
-
end
|
62
|
-
|
63
|
-
it "preserves ancestry" do
|
64
|
-
example = group.example("example name") { raise "something" }
|
65
|
-
run_all_and_dump_failures
|
66
|
-
expect(example.example_group.parent_groups.size).to eq 1
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context "with an exception that has an exception instance as its message" do
|
71
|
-
it "does not raise NoMethodError" do
|
72
|
-
gonzo_exception = RuntimeError.new
|
73
|
-
allow(gonzo_exception).to receive(:message) { gonzo_exception }
|
74
|
-
group.example("example name") { raise gonzo_exception }
|
75
|
-
expect { run_all_and_dump_failures }.not_to raise_error
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
context "with an instance of an anonymous exception class" do
|
80
|
-
it "substitutes '(anonymous error class)' for the missing class name" do
|
81
|
-
exception = Class.new(StandardError).new
|
82
|
-
group.example("example name") { raise exception }
|
83
|
-
run_all_and_dump_failures
|
84
|
-
expect(output.string).to include('(anonymous error class)')
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
context "with an exception class other than RSpec" do
|
89
|
-
it "does not show the error class" do
|
90
|
-
group.example("example name") { raise NameError.new('foo') }
|
91
|
-
run_all_and_dump_failures
|
92
|
-
expect(output.string).to match(/NameError/m)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
context "with a failed expectation (rspec-expectations)" do
|
97
|
-
it "does not show the error class" do
|
98
|
-
group.example("example name") { expect("this").to eq("that") }
|
99
|
-
run_all_and_dump_failures
|
100
|
-
expect(output.string).not_to match(/RSpec/m)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
context "with a failed message expectation (rspec-mocks)" do
|
105
|
-
it "does not show the error class" do
|
106
|
-
group.example("example name") { expect("this").to receive("that") }
|
107
|
-
run_all_and_dump_failures
|
108
|
-
expect(output.string).not_to match(/RSpec/m)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
context 'for #share_examples_for' do
|
113
|
-
it 'outputs the name and location' do
|
114
|
-
|
115
|
-
group.share_examples_for 'foo bar' do
|
116
|
-
it("example name") { expect("this").to eq("that") }
|
117
|
-
end
|
118
|
-
|
119
|
-
line = __LINE__.next
|
120
|
-
group.it_should_behave_like('foo bar')
|
121
|
-
|
122
|
-
run_all_and_dump_failures
|
123
|
-
|
124
|
-
expect(output.string).to include(
|
125
|
-
'Shared Example Group: "foo bar" called from ' +
|
126
|
-
"./spec/rspec/core/formatters/base_text_formatter_spec.rb:#{line}"
|
127
|
-
)
|
128
|
-
end
|
129
|
-
|
130
|
-
context 'that contains nested example groups' do
|
131
|
-
it 'outputs the name and location' do
|
132
|
-
group.share_examples_for 'foo bar' do
|
133
|
-
describe 'nested group' do
|
134
|
-
it("example name") { expect("this").to eq("that") }
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
line = __LINE__.next
|
139
|
-
group.it_should_behave_like('foo bar')
|
140
|
-
|
141
|
-
run_all_and_dump_failures
|
142
|
-
|
143
|
-
expect(output.string).to include(
|
144
|
-
'Shared Example Group: "foo bar" called from ' +
|
145
|
-
"./spec/rspec/core/formatters/base_text_formatter_spec.rb:#{line}"
|
146
|
-
)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
describe "#dump_profile_slowest_examples", :slow do
|
153
|
-
example_line_number = nil
|
154
|
-
|
155
|
-
before do
|
156
|
-
group = RSpec::Core::ExampleGroup.describe("group") do
|
157
|
-
example("example") do |example|
|
158
|
-
# make it look slow without actually taking up precious time
|
159
|
-
example.clock = class_double(RSpec::Core::Time, :now => RSpec::Core::Time.now + 0.5)
|
160
|
-
end
|
161
|
-
example_line_number = __LINE__ - 4
|
162
|
-
end
|
163
|
-
group.run(reporter)
|
164
|
-
|
165
|
-
allow(formatter).to receive(:examples) { group.examples }
|
166
|
-
allow(RSpec.configuration).to receive(:profile_examples) { 10 }
|
167
|
-
end
|
168
|
-
|
169
|
-
it "names the example" do
|
170
|
-
formatter.dump_profile_slowest_examples
|
171
|
-
expect(output.string).to match(/group example/m)
|
172
|
-
end
|
173
|
-
|
174
|
-
it "prints the time" do
|
175
|
-
formatter.dump_profile_slowest_examples
|
176
|
-
expect(output.string).to match(/0(\.\d+)? seconds/)
|
177
|
-
end
|
178
|
-
|
179
|
-
it "prints the path" do
|
180
|
-
formatter.dump_profile_slowest_examples
|
181
|
-
filename = __FILE__.split(File::SEPARATOR).last
|
182
|
-
|
183
|
-
expect(output.string).to match(/#{filename}\:#{example_line_number}/)
|
184
|
-
end
|
185
|
-
|
186
|
-
it "prints the percentage taken from the total runtime" do
|
187
|
-
formatter.dump_profile_slowest_examples
|
188
|
-
expect(output.string).to match(/, 100.0% of total time\):/)
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
describe "#dump_profile_slowest_example_groups", :slow do
|
193
|
-
let(:group) do
|
194
|
-
RSpec::Core::ExampleGroup.describe("slow group") do
|
195
|
-
example("example") do |example|
|
196
|
-
# make it look slow without actually taking up precious time
|
197
|
-
example.clock = class_double(RSpec::Core::Time, :now => RSpec::Core::Time.now + 0.5)
|
198
|
-
end
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
before do
|
203
|
-
group.run(reporter)
|
204
|
-
allow(RSpec.configuration).to receive(:profile_examples) { 10 }
|
205
|
-
end
|
206
|
-
|
207
|
-
context "with one example group" do
|
208
|
-
before { allow(formatter).to receive(:examples) { group.examples } }
|
209
|
-
|
210
|
-
it "doesn't profile a single example group" do
|
211
|
-
formatter.dump_profile_slowest_example_groups
|
212
|
-
expect(output.string).not_to match(/slowest example groups/)
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
context "with multiple example groups" do
|
217
|
-
before do
|
218
|
-
group2 = RSpec::Core::ExampleGroup.describe("fast group") do
|
219
|
-
example("example 1") { }
|
220
|
-
example("example 2") { }
|
221
|
-
end
|
222
|
-
group2.run(reporter)
|
223
|
-
|
224
|
-
allow(formatter).to receive(:examples) { group.examples + group2.examples }
|
225
|
-
end
|
226
|
-
|
227
|
-
it "prints the slowest example groups" do
|
228
|
-
formatter.dump_profile_slowest_example_groups
|
229
|
-
expect(output.string).to match(/slowest example groups/)
|
230
|
-
end
|
231
|
-
|
232
|
-
it "prints the time" do
|
233
|
-
formatter.dump_profile_slowest_example_groups
|
234
|
-
expect(output.string).to match(/0(\.\d+)? seconds/)
|
235
|
-
end
|
236
|
-
|
237
|
-
it "ranks the example groups by average time" do
|
238
|
-
formatter.dump_profile_slowest_example_groups
|
239
|
-
expect(output.string).to match(/slow group(.*)fast group/m)
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
it "depends on parent_groups to get the top level example group" do
|
244
|
-
ex = ""
|
245
|
-
group.describe("group 2") do
|
246
|
-
describe "group 3" do
|
247
|
-
ex = example("nested example 1")
|
248
|
-
end
|
249
|
-
end
|
250
|
-
|
251
|
-
expect(ex.example_group.parent_groups.last).to eq(group)
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
describe "custom_colors" do
|
256
|
-
it "uses the custom success color" do
|
257
|
-
RSpec.configure do |config|
|
258
|
-
config.color_enabled = true
|
259
|
-
config.tty = true
|
260
|
-
config.success_color = :cyan
|
261
|
-
end
|
262
|
-
send_notification :dump_summary, summary_notification(0, 1, 0, 0)
|
263
|
-
expect(output.string).to include("\e[36m")
|
264
|
-
end
|
265
|
-
end
|
266
|
-
|
267
|
-
describe "#colorize" do
|
268
|
-
it "accepts a VT100 integer code and formats the text with it" do
|
269
|
-
expect(formatter.colorize('abc', 32)).to eq "\e[32mabc\e[0m"
|
270
|
-
end
|
271
|
-
|
272
|
-
it "accepts a symbol as a color parameter and translates it to the correct integer code, then formats the text with it" do
|
273
|
-
expect(formatter.colorize('abc', :green)).to eq "\e[32mabc\e[0m"
|
274
|
-
end
|
275
|
-
|
276
|
-
it "accepts a non-default color symbol as a parameter and translates it to the correct integer code, then formats the text with it" do
|
277
|
-
expect(formatter.colorize('abc', :cyan)).to eq "\e[36mabc\e[0m"
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
described_class::VT100_COLORS.each do |name, number|
|
282
|
-
next if name == :black
|
283
|
-
|
284
|
-
describe "##{name}" do
|
285
|
-
before do
|
286
|
-
allow(RSpec.configuration).to receive(:color_enabled?) { true }
|
287
|
-
allow(RSpec).to receive(:deprecate)
|
288
|
-
end
|
289
|
-
|
290
|
-
it "prints the text using the color code for #{name}" do
|
291
|
-
expect(formatter.send(name, "text")).to eq("\e[#{number}mtext\e[0m")
|
292
|
-
end
|
293
|
-
|
294
|
-
it "prints a deprecation warning" do
|
295
|
-
expect(RSpec).to receive(:deprecate) {|*args|
|
296
|
-
expect(args.first).to match(/#{name}/)
|
297
|
-
}
|
298
|
-
formatter.send(name, "text")
|
299
|
-
end
|
300
|
-
end
|
301
|
-
end
|
302
|
-
|
303
|
-
end
|