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,246 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
module RSpec::Core
|
|
4
|
-
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 "does nothing when :#{filter} previously set" do
|
|
47
|
-
filter_manager = FilterManager.new
|
|
48
|
-
filter_manager.include filter => "a_value"
|
|
49
|
-
filter_manager.include :foo => :bar
|
|
50
|
-
expect(filter_manager.inclusions).to eq(filter => "a_value")
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
describe "##{name}!" do
|
|
58
|
-
it "replaces existing #{type}" do
|
|
59
|
-
filter_manager = FilterManager.new
|
|
60
|
-
filter_manager.exclusions.clear # defaults
|
|
61
|
-
filter_manager.send name, :foo => 1, :bar => 2
|
|
62
|
-
filter_manager.send "#{name}!", :foo => 3
|
|
63
|
-
expect(filter_manager.send(type)).to eq(:foo => 3)
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
it "deletes matching opposites" do
|
|
67
|
-
filter_manager = FilterManager.new
|
|
68
|
-
filter_manager.exclusions.clear # defaults
|
|
69
|
-
filter_manager.send opposite(name), :foo => 1
|
|
70
|
-
filter_manager.send "#{name}!", :foo => 2
|
|
71
|
-
expect(filter_manager.send(type)).to eq(:foo => 2)
|
|
72
|
-
expect(filter_manager.send(opposite(type))).to be_empty
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
describe "##{name}_with_low_priority" do
|
|
77
|
-
it "ignores new #{type} if same key exists" do
|
|
78
|
-
filter_manager = FilterManager.new
|
|
79
|
-
filter_manager.exclusions.clear # defaults
|
|
80
|
-
filter_manager.send name, :foo => 1
|
|
81
|
-
filter_manager.send "#{name}_with_low_priority", :foo => 2
|
|
82
|
-
expect(filter_manager.send(type)).to eq(:foo => 1)
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
it "ignores new #{type} if same key exists in opposite" do
|
|
86
|
-
filter_manager = FilterManager.new
|
|
87
|
-
filter_manager.exclusions.clear # defaults
|
|
88
|
-
filter_manager.send opposite(name), :foo => 1
|
|
89
|
-
filter_manager.send "#{name}_with_low_priority", :foo => 1
|
|
90
|
-
expect(filter_manager.send(type)).to be_empty
|
|
91
|
-
expect(filter_manager.send(opposite(type))).to eq(:foo => 1)
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
it "keeps new #{type} if same key exists in opposite but values are different" do
|
|
95
|
-
filter_manager = FilterManager.new
|
|
96
|
-
filter_manager.exclusions.clear # defaults
|
|
97
|
-
filter_manager.send opposite(name), :foo => 1
|
|
98
|
-
filter_manager.send "#{name}_with_low_priority", :foo => 2
|
|
99
|
-
expect(filter_manager.send(type)).to eq(:foo => 2)
|
|
100
|
-
expect(filter_manager.send(opposite(type))).to eq(:foo => 1)
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
describe "#prune" do
|
|
106
|
-
def filterable_object_with(args = {})
|
|
107
|
-
object = double('a filterable object')
|
|
108
|
-
object.stub(:any_apply?) { |f| Metadata.new(args).any_apply?(f) }
|
|
109
|
-
object
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
it "includes objects with tags matching inclusions" do
|
|
113
|
-
included = filterable_object_with({:foo => :bar})
|
|
114
|
-
excluded = filterable_object_with
|
|
115
|
-
filter_manager = FilterManager.new
|
|
116
|
-
filter_manager.include :foo => :bar
|
|
117
|
-
expect(filter_manager.prune([included, excluded])).to eq([included])
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
it "excludes objects with tags matching exclusions" do
|
|
121
|
-
included = filterable_object_with
|
|
122
|
-
excluded = filterable_object_with({:foo => :bar})
|
|
123
|
-
filter_manager = FilterManager.new
|
|
124
|
-
filter_manager.exclude :foo => :bar
|
|
125
|
-
expect(filter_manager.prune([included, excluded])).to eq([included])
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
it "prefers exclusion when matches previously set inclusion" do
|
|
129
|
-
included = filterable_object_with
|
|
130
|
-
excluded = filterable_object_with({:foo => :bar})
|
|
131
|
-
filter_manager = FilterManager.new
|
|
132
|
-
filter_manager.include :foo => :bar
|
|
133
|
-
filter_manager.exclude :foo => :bar
|
|
134
|
-
expect(filter_manager.prune([included, excluded])).to eq([included])
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
it "prefers inclusion when matches previously set exclusion" do
|
|
138
|
-
included = filterable_object_with({:foo => :bar})
|
|
139
|
-
excluded = filterable_object_with
|
|
140
|
-
filter_manager = FilterManager.new
|
|
141
|
-
filter_manager.exclude :foo => :bar
|
|
142
|
-
filter_manager.include :foo => :bar
|
|
143
|
-
expect(filter_manager.prune([included, excluded])).to eq([included])
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
it "prefers previously set inclusion when exclusion matches but has lower priority" do
|
|
147
|
-
included = filterable_object_with({:foo => :bar})
|
|
148
|
-
excluded = filterable_object_with
|
|
149
|
-
filter_manager = FilterManager.new
|
|
150
|
-
filter_manager.include :foo => :bar
|
|
151
|
-
filter_manager.exclude_with_low_priority :foo => :bar
|
|
152
|
-
expect(filter_manager.prune([included, excluded])).to eq([included])
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
it "prefers previously set exclusion when inclusion matches but has lower priority" do
|
|
156
|
-
included = filterable_object_with
|
|
157
|
-
excluded = filterable_object_with({:foo => :bar})
|
|
158
|
-
filter_manager = FilterManager.new
|
|
159
|
-
filter_manager.exclude :foo => :bar
|
|
160
|
-
filter_manager.include_with_low_priority :foo => :bar
|
|
161
|
-
expect(filter_manager.prune([included, excluded])).to eq([included])
|
|
162
|
-
end
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
describe "#inclusions#description" do
|
|
166
|
-
it 'cleans up the description' do
|
|
167
|
-
project_dir = File.expand_path('.')
|
|
168
|
-
expect(lambda { }.inspect).to include(project_dir) unless defined?(JRUBY_VERSION) && JRUBY_VERSION =~ /\A1\.7/
|
|
169
|
-
expect(lambda { }.inspect).to include(' (lambda)') if RUBY_VERSION > '1.9'
|
|
170
|
-
expect(lambda { }.inspect).to include('0x')
|
|
171
|
-
|
|
172
|
-
filter_manager = FilterManager.new
|
|
173
|
-
filter_manager.include :foo => lambda { }
|
|
174
|
-
|
|
175
|
-
expect(filter_manager.inclusions.description).not_to include(project_dir)
|
|
176
|
-
expect(filter_manager.inclusions.description).not_to include(' (lambda)')
|
|
177
|
-
expect(filter_manager.inclusions.description).not_to include('0x')
|
|
178
|
-
end
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
describe "#exclusions#description" do
|
|
182
|
-
it 'cleans up the description' do
|
|
183
|
-
project_dir = File.expand_path('.')
|
|
184
|
-
expect(lambda { }.inspect).to include(project_dir) unless defined?(JRUBY_VERSION) && JRUBY_VERSION =~ /\A1\.7/
|
|
185
|
-
expect(lambda { }.inspect).to include(' (lambda)') if RUBY_VERSION > '1.9'
|
|
186
|
-
expect(lambda { }.inspect).to include('0x')
|
|
187
|
-
|
|
188
|
-
filter_manager = FilterManager.new
|
|
189
|
-
filter_manager.exclude :foo => lambda { }
|
|
190
|
-
|
|
191
|
-
expect(filter_manager.exclusions.description).not_to include(project_dir)
|
|
192
|
-
expect(filter_manager.exclusions.description).not_to include(' (lambda)')
|
|
193
|
-
expect(filter_manager.exclusions.description).not_to include('0x')
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
it 'returns `{}` when it only contains the default filters' do
|
|
197
|
-
filter_manager = FilterManager.new
|
|
198
|
-
expect(filter_manager.exclusions.description).to eq({}.inspect)
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
it 'includes other filters' do
|
|
202
|
-
filter_manager = FilterManager.new
|
|
203
|
-
filter_manager.exclude :foo => :bar
|
|
204
|
-
expect(filter_manager.exclusions.description).to eq({ :foo => :bar }.inspect)
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
it 'deprecates an overridden :if filter' do
|
|
208
|
-
expect(RSpec).to receive(:deprecate).with(/exclude\(:if/)
|
|
209
|
-
filter_manager = FilterManager.new
|
|
210
|
-
filter_manager.exclude :if => :custom_filter
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
it 'deprecates an :if filter overridden with low priority' do
|
|
214
|
-
expect(RSpec).to receive(:deprecate).with(/exclude\(:if/)
|
|
215
|
-
filter_manager = FilterManager.new
|
|
216
|
-
filter_manager.exclude_with_low_priority :if => :custom_filter
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
it 'deprecates an overridden :unless filter' do
|
|
220
|
-
expect(RSpec).to receive(:deprecate).with(/exclude\(:unless/)
|
|
221
|
-
filter_manager = FilterManager.new
|
|
222
|
-
filter_manager.exclude :unless => :custom_filter
|
|
223
|
-
end
|
|
224
|
-
|
|
225
|
-
it 'deprecates an :unless filter overridden with low priority' do
|
|
226
|
-
expect(RSpec).to receive(:deprecate).with(/exclude\(:unless/)
|
|
227
|
-
filter_manager = FilterManager.new
|
|
228
|
-
filter_manager.exclude_with_low_priority :unless => :custom_filter
|
|
229
|
-
end
|
|
230
|
-
|
|
231
|
-
it 'includes an overriden :if filter' do
|
|
232
|
-
allow(RSpec).to receive(:deprecate)
|
|
233
|
-
filter_manager = FilterManager.new
|
|
234
|
-
filter_manager.exclude :if => :custom_filter
|
|
235
|
-
expect(filter_manager.exclusions.description).to eq({ :if => :custom_filter }.inspect)
|
|
236
|
-
end
|
|
237
|
-
|
|
238
|
-
it 'includes an overriden :unless filter' do
|
|
239
|
-
allow(RSpec).to receive(:deprecate)
|
|
240
|
-
filter_manager = FilterManager.new
|
|
241
|
-
filter_manager.exclude :unless => :custom_filter
|
|
242
|
-
expect(filter_manager.exclusions.description).to eq({ :unless => :custom_filter }.inspect)
|
|
243
|
-
end
|
|
244
|
-
end
|
|
245
|
-
end
|
|
246
|
-
end
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'rspec/core/formatters/base_formatter'
|
|
3
|
-
|
|
4
|
-
describe RSpec::Core::Formatters::BaseFormatter do
|
|
5
|
-
|
|
6
|
-
let(:output) { StringIO.new }
|
|
7
|
-
let(:formatter) { RSpec::Core::Formatters::BaseFormatter.new(output) }
|
|
8
|
-
|
|
9
|
-
describe "backtrace_line" do
|
|
10
|
-
it "trims current working directory" do
|
|
11
|
-
expect(formatter.__send__(:backtrace_line, File.expand_path(__FILE__))).to eq("./spec/rspec/core/formatters/base_formatter_spec.rb")
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it "leaves the original line intact" do
|
|
15
|
-
original_line = File.expand_path(__FILE__)
|
|
16
|
-
formatter.__send__(:backtrace_line, original_line)
|
|
17
|
-
expect(original_line).to eq(File.expand_path(__FILE__))
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it "deals gracefully with a security error" do
|
|
21
|
-
safely do
|
|
22
|
-
formatter.__send__(:backtrace_line, __FILE__)
|
|
23
|
-
# on some rubies, this doesn't raise a SecurityError; this test just
|
|
24
|
-
# assures that if it *does* raise an error, the error is caught inside
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
describe "read_failed_line" do
|
|
30
|
-
it "deals gracefully with a heterogeneous language stack trace" do
|
|
31
|
-
exception = double(:Exception, :backtrace => [
|
|
32
|
-
"at Object.prototypeMethod (foo:331:18)",
|
|
33
|
-
"at Array.forEach (native)",
|
|
34
|
-
"at a_named_javascript_function (/some/javascript/file.js:39:5)",
|
|
35
|
-
"/some/line/of/ruby.rb:14"
|
|
36
|
-
])
|
|
37
|
-
example = double(:Example, :file_path => __FILE__)
|
|
38
|
-
expect {
|
|
39
|
-
formatter.send(:read_failed_line, exception, example)
|
|
40
|
-
}.not_to raise_error
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it "deals gracefully with a security error" do
|
|
44
|
-
exception = double(:Exception, :backtrace => [ "#{__FILE__}:#{__LINE__}"])
|
|
45
|
-
example = double(:Example, :file_path => __FILE__)
|
|
46
|
-
safely do
|
|
47
|
-
expect {
|
|
48
|
-
formatter.send(:read_failed_line, exception, example)
|
|
49
|
-
}.not_to raise_error
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
context "when ruby reports a bogus line number in the stack trace" do
|
|
54
|
-
it "reports the filename and that it was unable to find the matching line" do
|
|
55
|
-
exception = double(:Exception, :backtrace => [ "#{__FILE__}:10000000" ])
|
|
56
|
-
example = double(:Example, :file_path => __FILE__)
|
|
57
|
-
|
|
58
|
-
msg = formatter.send(:read_failed_line, exception, example)
|
|
59
|
-
expect(msg).to include("Unable to find matching line")
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
context "when String alias to_int to_i" do
|
|
64
|
-
before do
|
|
65
|
-
String.class_eval do
|
|
66
|
-
alias :to_int :to_i
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
after do
|
|
71
|
-
String.class_eval do
|
|
72
|
-
undef to_int
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
it "doesn't hang when file exists" do
|
|
77
|
-
pending("This issue still exists on JRuby, but should be resolved shortly: https://github.com/rspec/rspec-core/issues/295", :if => RUBY_PLATFORM == 'java')
|
|
78
|
-
exception = double(:Exception, :backtrace => [ "#{__FILE__}:#{__LINE__}"])
|
|
79
|
-
|
|
80
|
-
example = double(:Example, :file_path => __FILE__)
|
|
81
|
-
expect(formatter.send(:read_failed_line, exception, example)).to eql(
|
|
82
|
-
%Q{ exception = double(:Exception, :backtrace => [ "\#{__FILE__}:\#{__LINE__}"])\n})
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
describe "#format_backtrace" do
|
|
89
|
-
let(:rspec_expectations_dir) { "/path/to/rspec-expectations/lib" }
|
|
90
|
-
let(:rspec_core_dir) { "/path/to/rspec-core/lib" }
|
|
91
|
-
let(:backtrace) do
|
|
92
|
-
[
|
|
93
|
-
"#{rspec_expectations_dir}/rspec/matchers/operator_matcher.rb:51:in `eval_match'",
|
|
94
|
-
"#{rspec_expectations_dir}/rspec/matchers/operator_matcher.rb:29:in `=='",
|
|
95
|
-
"./my_spec.rb:5",
|
|
96
|
-
"#{rspec_core_dir}/rspec/core/example.rb:52:in `run'",
|
|
97
|
-
"#{rspec_core_dir}/rspec/core/runner.rb:37:in `run'",
|
|
98
|
-
RSpec::Core::Runner::AT_EXIT_HOOK_BACKTRACE_LINE,
|
|
99
|
-
"./my_spec.rb:3"
|
|
100
|
-
]
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
it "removes lines from rspec and lines that come before the invocation of the at_exit autorun hook" do
|
|
104
|
-
expect(formatter.format_backtrace(backtrace, double.as_null_object)).to eq(["./my_spec.rb:5"])
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
end
|