rspec-core 3.0.0.beta2 → 3.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.yardopts +1 -0
- data/Changelog.md +297 -57
- data/README.md +16 -13
- data/lib/rspec/core.rb +55 -84
- data/lib/rspec/core/backport_random.rb +35 -3
- data/lib/rspec/core/backtrace_formatter.rb +4 -13
- data/lib/rspec/core/configuration.rb +330 -114
- data/lib/rspec/core/configuration_options.rb +38 -22
- data/lib/rspec/core/drb.rb +111 -0
- data/lib/rspec/core/dsl.rb +8 -2
- data/lib/rspec/core/example.rb +203 -94
- data/lib/rspec/core/example_group.rb +344 -316
- data/lib/rspec/core/filter_manager.rb +135 -90
- data/lib/rspec/core/flat_map.rb +1 -0
- data/lib/rspec/core/formatters.rb +50 -14
- data/lib/rspec/core/formatters/base_formatter.rb +32 -138
- data/lib/rspec/core/formatters/base_text_formatter.rb +32 -253
- data/lib/rspec/core/formatters/console_codes.rb +65 -0
- data/lib/rspec/core/formatters/deprecation_formatter.rb +24 -15
- data/lib/rspec/core/formatters/documentation_formatter.rb +7 -10
- data/lib/rspec/core/formatters/helpers.rb +15 -9
- data/lib/rspec/core/formatters/html_formatter.rb +17 -16
- data/lib/rspec/core/formatters/html_printer.rb +1 -0
- data/lib/rspec/core/formatters/json_formatter.rb +18 -20
- data/lib/rspec/core/formatters/profile_formatter.rb +67 -0
- data/lib/rspec/core/formatters/progress_formatter.rb +6 -7
- data/lib/rspec/core/formatters/snippet_extractor.rb +8 -6
- data/lib/rspec/core/hooks.rb +131 -125
- data/lib/rspec/core/memoized_helpers.rb +31 -26
- data/lib/rspec/core/metadata.rb +277 -184
- data/lib/rspec/core/metadata_filter.rb +86 -0
- data/lib/rspec/core/minitest_assertions_adapter.rb +28 -0
- data/lib/rspec/core/mocking_adapters/flexmock.rb +1 -1
- data/lib/rspec/core/mocking_adapters/mocha.rb +1 -1
- data/lib/rspec/core/mocking_adapters/null.rb +1 -1
- data/lib/rspec/core/mocking_adapters/rr.rb +2 -1
- data/lib/rspec/core/mocking_adapters/rspec.rb +1 -1
- data/lib/rspec/core/notifications.rb +435 -24
- data/lib/rspec/core/option_parser.rb +16 -25
- data/lib/rspec/core/ordering.rb +3 -1
- data/lib/rspec/core/pending.rb +57 -33
- data/lib/rspec/core/project_initializer.rb +2 -0
- data/lib/rspec/core/project_initializer/spec_helper.rb +5 -4
- data/lib/rspec/core/rake_task.rb +45 -20
- data/lib/rspec/core/reporter.rb +50 -22
- data/lib/rspec/core/ruby_project.rb +1 -0
- data/lib/rspec/core/runner.rb +93 -39
- data/lib/rspec/core/shared_context.rb +7 -5
- data/lib/rspec/core/shared_example_group.rb +85 -77
- data/lib/rspec/core/test_unit_assertions_adapter.rb +30 -0
- data/lib/rspec/core/version.rb +3 -1
- data/lib/rspec/core/warnings.rb +35 -17
- data/lib/rspec/core/world.rb +57 -5
- metadata +56 -369
- metadata.gz.sig +3 -3
- data/features/README.md +0 -13
- data/features/Upgrade.md +0 -352
- data/features/command_line/README.md +0 -25
- data/features/command_line/dry_run.feature +0 -29
- data/features/command_line/example_name_option.feature +0 -97
- data/features/command_line/exit_status.feature +0 -82
- data/features/command_line/fail_fast.feature +0 -26
- data/features/command_line/format_option.feature +0 -75
- data/features/command_line/init.feature +0 -57
- data/features/command_line/line_number_appended_to_path.feature +0 -140
- data/features/command_line/line_number_option.feature +0 -58
- data/features/command_line/order.feature +0 -25
- data/features/command_line/pattern_option.feature +0 -49
- data/features/command_line/rake_task.feature +0 -122
- data/features/command_line/randomization.feature +0 -63
- data/features/command_line/require_option.feature +0 -43
- data/features/command_line/ruby.feature +0 -23
- data/features/command_line/tag.feature +0 -98
- data/features/command_line/warnings_option.feature +0 -29
- data/features/configuration/alias_example_to.feature +0 -39
- data/features/configuration/backtrace_exclusion_patterns.feature +0 -105
- data/features/configuration/custom_settings.feature +0 -84
- data/features/configuration/default_path.feature +0 -38
- data/features/configuration/deprecation_stream.feature +0 -58
- data/features/configuration/enable_global_dsl.feature +0 -54
- data/features/configuration/fail_fast.feature +0 -77
- data/features/configuration/failure_exit_code.feature +0 -36
- data/features/configuration/order_and_seed.feature +0 -3
- data/features/configuration/output_stream.feature +0 -24
- data/features/configuration/overriding_global_ordering.feature +0 -93
- data/features/configuration/pattern.feature +0 -38
- data/features/configuration/profile.feature +0 -220
- data/features/configuration/read_options_from_file.feature +0 -90
- data/features/configuration/run_all_when_everything_filtered.feature +0 -76
- data/features/example_groups/aliasing.feature +0 -48
- data/features/example_groups/basic_structure.feature +0 -55
- data/features/example_groups/shared_context.feature +0 -74
- data/features/example_groups/shared_examples.feature +0 -286
- data/features/expectation_framework_integration/configure_expectation_framework.feature +0 -102
- data/features/filtering/exclusion_filters.feature +0 -135
- data/features/filtering/if_and_unless.feature +0 -138
- data/features/filtering/inclusion_filters.feature +0 -101
- data/features/formatters/configurable_colors.feature +0 -31
- data/features/formatters/custom_formatter.feature +0 -68
- data/features/formatters/json_formatter.feature +0 -30
- data/features/formatters/regression_tests.feature +0 -95
- data/features/formatters/text_formatter.feature +0 -46
- data/features/helper_methods/arbitrary_methods.feature +0 -40
- data/features/helper_methods/let.feature +0 -50
- data/features/helper_methods/modules.feature +0 -146
- data/features/hooks/around_hooks.feature +0 -344
- data/features/hooks/before_and_after_hooks.feature +0 -427
- data/features/hooks/filtering.feature +0 -232
- data/features/metadata/current_example.feature +0 -56
- data/features/metadata/described_class.feature +0 -17
- data/features/metadata/user_defined.feature +0 -100
- data/features/mock_framework_integration/use_any_framework.feature +0 -106
- data/features/mock_framework_integration/use_flexmock.feature +0 -94
- data/features/mock_framework_integration/use_mocha.feature +0 -95
- data/features/mock_framework_integration/use_rr.feature +0 -96
- data/features/mock_framework_integration/use_rspec.feature +0 -95
- data/features/pending_and_skipped_examples/README.md +0 -3
- data/features/pending_and_skipped_examples/pending_examples.feature +0 -118
- data/features/pending_and_skipped_examples/skipped_examples.feature +0 -106
- data/features/spec_files/arbitrary_file_suffix.feature +0 -13
- data/features/step_definitions/additional_cli_steps.rb +0 -83
- data/features/subject/explicit_subject.feature +0 -101
- data/features/subject/implicit_subject.feature +0 -63
- data/features/subject/one_liner_syntax.feature +0 -71
- data/features/support/env.rb +0 -21
- data/features/support/require_expect_syntax_in_aruba_specs.rb +0 -16
- data/features/support/rubinius.rb +0 -6
- data/lib/rspec/core/command_line.rb +0 -35
- data/lib/rspec/core/drb_command_line.rb +0 -26
- data/lib/rspec/core/drb_options.rb +0 -87
- data/lib/rspec/core/formatters/legacy_formatter.rb +0 -227
- data/lib/rspec/core/shared_example_group/collection.rb +0 -27
- data/spec/command_line/order_spec.rb +0 -211
- data/spec/rspec/core/backtrace_formatter_spec.rb +0 -230
- data/spec/rspec/core/command_line_spec.rb +0 -112
- data/spec/rspec/core/command_line_spec_output.txt +0 -0
- data/spec/rspec/core/configuration_options_spec.rb +0 -409
- data/spec/rspec/core/configuration_spec.rb +0 -1479
- data/spec/rspec/core/drb_command_line_spec.rb +0 -102
- data/spec/rspec/core/drb_options_spec.rb +0 -193
- data/spec/rspec/core/dsl_spec.rb +0 -88
- data/spec/rspec/core/example_group_spec.rb +0 -1533
- data/spec/rspec/core/example_spec.rb +0 -642
- data/spec/rspec/core/filter_manager_spec.rb +0 -229
- data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -64
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +0 -303
- data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +0 -208
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +0 -75
- data/spec/rspec/core/formatters/helpers_spec.rb +0 -104
- data/spec/rspec/core/formatters/html_formatted-2.1.0.html +0 -392
- data/spec/rspec/core/formatters/html_formatted.html +0 -397
- data/spec/rspec/core/formatters/html_formatter_spec.rb +0 -122
- data/spec/rspec/core/formatters/json_formatter_spec.rb +0 -206
- data/spec/rspec/core/formatters/legacy_formatter_spec.rb +0 -137
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -43
- data/spec/rspec/core/formatters/snippet_extractor_spec.rb +0 -26
- data/spec/rspec/core/formatters_spec.rb +0 -120
- data/spec/rspec/core/hooks_filtering_spec.rb +0 -227
- data/spec/rspec/core/hooks_spec.rb +0 -294
- data/spec/rspec/core/memoized_helpers_spec.rb +0 -495
- data/spec/rspec/core/metadata_spec.rb +0 -491
- data/spec/rspec/core/option_parser_spec.rb +0 -262
- data/spec/rspec/core/ordering_spec.rb +0 -102
- data/spec/rspec/core/pending_example_spec.rb +0 -117
- data/spec/rspec/core/pending_spec.rb +0 -8
- data/spec/rspec/core/project_initializer_spec.rb +0 -73
- data/spec/rspec/core/rake_task_spec.rb +0 -146
- data/spec/rspec/core/random_spec.rb +0 -47
- data/spec/rspec/core/reporter_spec.rb +0 -155
- data/spec/rspec/core/resources/a_bar.rb +0 -0
- data/spec/rspec/core/resources/a_foo.rb +0 -0
- data/spec/rspec/core/resources/a_spec.rb +0 -1
- data/spec/rspec/core/resources/custom_example_group_runner.rb +0 -14
- data/spec/rspec/core/resources/formatter_specs.rb +0 -58
- data/spec/rspec/core/resources/utf8_encoded.rb +0 -8
- data/spec/rspec/core/rspec_matchers_spec.rb +0 -45
- data/spec/rspec/core/ruby_project_spec.rb +0 -26
- data/spec/rspec/core/runner_spec.rb +0 -151
- data/spec/rspec/core/shared_context_spec.rb +0 -102
- data/spec/rspec/core/shared_example_group/collection_spec.rb +0 -57
- data/spec/rspec/core/shared_example_group_spec.rb +0 -114
- data/spec/rspec/core/warnings_spec.rb +0 -29
- data/spec/rspec/core/world_spec.rb +0 -142
- data/spec/rspec/core_spec.rb +0 -91
- data/spec/spec_helper.rb +0 -160
- data/spec/support/config_options_helper.rb +0 -13
- data/spec/support/formatter_support.rb +0 -83
- data/spec/support/helper_methods.rb +0 -26
- data/spec/support/isolate_load_path_mutation.rb +0 -5
- data/spec/support/isolated_directory.rb +0 -10
- data/spec/support/isolated_home_directory.rb +0 -16
- data/spec/support/legacy_formatter_using_sub_classing_example.rb +0 -87
- data/spec/support/matchers.rb +0 -85
- data/spec/support/mathn_integration_support.rb +0 -12
- data/spec/support/old_style_formatter_example.rb +0 -69
- data/spec/support/shared_example_groups.rb +0 -13
- data/spec/support/spec_files.rb +0 -44
- data/spec/support/stderr_splitter.rb +0 -36
@@ -1,230 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
module RSpec::Core
|
4
|
-
RSpec.describe BacktraceFormatter do
|
5
|
-
def make_backtrace_formatter(exclusion_patterns=nil, inclusion_patterns=nil)
|
6
|
-
BacktraceFormatter.new.tap do |bc|
|
7
|
-
bc.exclusion_patterns = exclusion_patterns if exclusion_patterns
|
8
|
-
bc.inclusion_patterns = inclusion_patterns if inclusion_patterns
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "defaults" do
|
13
|
-
it "excludes rspec files" do
|
14
|
-
expect(make_backtrace_formatter.exclude?("lib/rspec/core.rb")).to be true
|
15
|
-
expect(make_backtrace_formatter.exclude?("lib/rspec/core/foo.rb")).to be true
|
16
|
-
expect(make_backtrace_formatter.exclude?("lib/rspec/expectations/foo.rb")).to be true
|
17
|
-
expect(make_backtrace_formatter.exclude?("lib/rspec/matchers/foo.rb")).to be true
|
18
|
-
expect(make_backtrace_formatter.exclude?("lib/rspec/mocks/foo.rb")).to be true
|
19
|
-
end
|
20
|
-
|
21
|
-
it "excludes java files (for JRuby)" do
|
22
|
-
expect(make_backtrace_formatter.exclude?("org/jruby/RubyArray.java:2336")).to be true
|
23
|
-
end
|
24
|
-
|
25
|
-
it "excludes files within installed gems" do
|
26
|
-
expect(make_backtrace_formatter.exclude?('ruby-1.8.7-p334/gems/mygem-2.3.0/lib/mygem.rb')).to be true
|
27
|
-
end
|
28
|
-
|
29
|
-
it "includes files in projects containing 'gems' in the name" do
|
30
|
-
expect(make_backtrace_formatter.exclude?('code/my-gems-plugin/lib/plugin.rb')).to be false
|
31
|
-
end
|
32
|
-
|
33
|
-
it "includes something in the current working directory" do
|
34
|
-
expect(make_backtrace_formatter.exclude?("#{Dir.getwd}/arbitrary")).to be false
|
35
|
-
end
|
36
|
-
|
37
|
-
it "includes something in the current working directory even with a matching exclusion pattern" do
|
38
|
-
formatter = make_backtrace_formatter([/foo/])
|
39
|
-
expect(formatter.exclude? "#{Dir.getwd}/foo").to be false
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe "#format_backtrace" do
|
44
|
-
it "excludes lines from rspec libs by default", :unless => RSpec.windows_os? do
|
45
|
-
backtrace = [
|
46
|
-
"/path/to/rspec-expectations/lib/rspec/expectations/foo.rb:37",
|
47
|
-
"/path/to/rspec-expectations/lib/rspec/matchers/foo.rb:37",
|
48
|
-
"./my_spec.rb:5",
|
49
|
-
"/path/to/rspec-mocks/lib/rspec/mocks/foo.rb:37",
|
50
|
-
"/path/to/rspec-core/lib/rspec/core/foo.rb:37"
|
51
|
-
]
|
52
|
-
|
53
|
-
expect(BacktraceFormatter.new.format_backtrace(backtrace)).to eq(["./my_spec.rb:5"])
|
54
|
-
end
|
55
|
-
|
56
|
-
it "excludes lines from rspec libs by default", :if => RSpec.windows_os? do
|
57
|
-
backtrace = [
|
58
|
-
"\\path\\to\\rspec-expectations\\lib\\rspec\\expectations\\foo.rb:37",
|
59
|
-
"\\path\\to\\rspec-expectations\\lib\\rspec\\matchers\\foo.rb:37",
|
60
|
-
".\\my_spec.rb:5",
|
61
|
-
"\\path\\to\\rspec-mocks\\lib\\rspec\\mocks\\foo.rb:37",
|
62
|
-
"\\path\\to\\rspec-core\\lib\\rspec\\core\\foo.rb:37"
|
63
|
-
]
|
64
|
-
|
65
|
-
expect(BacktraceFormatter.new.format_backtrace(backtrace)).to eq([".\\my_spec.rb:5"])
|
66
|
-
end
|
67
|
-
|
68
|
-
it "excludes lines that come before at_exit autorun hook" do
|
69
|
-
backtrace = [
|
70
|
-
"./spec/my_spec.rb:7",
|
71
|
-
"./spec/my_spec.rb:5",
|
72
|
-
RSpec::Core::Runner::AT_EXIT_HOOK_BACKTRACE_LINE,
|
73
|
-
"./spec/my_spec.rb:3"
|
74
|
-
]
|
75
|
-
expect(BacktraceFormatter.new.format_backtrace(backtrace)).to eq(["./spec/my_spec.rb:7", "./spec/my_spec.rb:5"])
|
76
|
-
end
|
77
|
-
|
78
|
-
context "when every line is filtered out" do
|
79
|
-
let(:backtrace) do
|
80
|
-
[
|
81
|
-
"/path/to/rspec-expectations/lib/rspec/expectations/foo.rb:37",
|
82
|
-
"/path/to/rspec-expectations/lib/rspec/matchers/foo.rb:37",
|
83
|
-
"/path/to/rspec-mocks/lib/rspec/mocks/foo.rb:37",
|
84
|
-
"/path/to/rspec-core/lib/rspec/core/foo.rb:37"
|
85
|
-
]
|
86
|
-
end
|
87
|
-
|
88
|
-
it "includes full backtrace" do
|
89
|
-
expect(BacktraceFormatter.new.format_backtrace(backtrace).take(4)).to eq backtrace
|
90
|
-
end
|
91
|
-
|
92
|
-
it "adds a message explaining everything was filtered" do
|
93
|
-
expect(BacktraceFormatter.new.format_backtrace(backtrace).drop(4).join).to match(/Showing full backtrace/)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
context "when rspec is installed in the current working directory" do
|
98
|
-
it "excludes lines from rspec libs by default", :unless => RSpec.windows_os? do
|
99
|
-
backtrace = [
|
100
|
-
"#{Dir.getwd}/.bundle/path/to/rspec-expectations/lib/rspec/expectations/foo.rb:37",
|
101
|
-
"#{Dir.getwd}/.bundle/path/to/rspec-expectations/lib/rspec/matchers/foo.rb:37",
|
102
|
-
"#{Dir.getwd}/my_spec.rb:5",
|
103
|
-
"#{Dir.getwd}/.bundle/path/to/rspec-mocks/lib/rspec/mocks/foo.rb:37",
|
104
|
-
"#{Dir.getwd}/.bundle/path/to/rspec-core/lib/rspec/core/foo.rb:37"
|
105
|
-
]
|
106
|
-
|
107
|
-
expect(BacktraceFormatter.new.format_backtrace(backtrace)).to eq(["./my_spec.rb:5"])
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
describe "#full_backtrace=true" do
|
113
|
-
it "sets full_backtrace true" do
|
114
|
-
formatter = make_backtrace_formatter([/discard/],[/keep/])
|
115
|
-
formatter.full_backtrace = true
|
116
|
-
expect(formatter.full_backtrace?).to be true
|
117
|
-
end
|
118
|
-
|
119
|
-
it "preserves exclusion and inclusion patterns" do
|
120
|
-
formatter = make_backtrace_formatter([/discard/],[/keep/])
|
121
|
-
formatter.full_backtrace = true
|
122
|
-
expect(formatter.exclusion_patterns).to eq [/discard/]
|
123
|
-
expect(formatter.inclusion_patterns).to eq [/keep/]
|
124
|
-
end
|
125
|
-
|
126
|
-
it "keeps all lines, even those that match exclusions" do
|
127
|
-
formatter = make_backtrace_formatter([/discard/],[/keep/])
|
128
|
-
formatter.full_backtrace = true
|
129
|
-
expect(formatter.exclude? "discard").to be false
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
describe "#full_backtrace=false (after it was true)" do
|
134
|
-
it "sets full_backtrace false" do
|
135
|
-
formatter = make_backtrace_formatter([/discard/],[/keep/])
|
136
|
-
formatter.full_backtrace = true
|
137
|
-
formatter.full_backtrace = false
|
138
|
-
expect(formatter.full_backtrace?).to be false
|
139
|
-
end
|
140
|
-
|
141
|
-
it "preserves exclusion and inclusion patterns" do
|
142
|
-
formatter = make_backtrace_formatter([/discard/],[/keep/])
|
143
|
-
formatter.full_backtrace = true
|
144
|
-
formatter.full_backtrace = false
|
145
|
-
expect(formatter.exclusion_patterns).to eq [/discard/]
|
146
|
-
expect(formatter.inclusion_patterns).to eq [/keep/]
|
147
|
-
end
|
148
|
-
|
149
|
-
it "excludes lines that match exclusions" do
|
150
|
-
formatter = make_backtrace_formatter([/discard/],[/keep/])
|
151
|
-
formatter.full_backtrace = true
|
152
|
-
formatter.full_backtrace = false
|
153
|
-
expect(formatter.exclude? "discard").to be true
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
describe "#backtrace_line" do
|
158
|
-
let(:formatter) { BacktraceFormatter.new }
|
159
|
-
|
160
|
-
it "trims current working directory" do
|
161
|
-
expect(formatter.__send__(:backtrace_line, File.expand_path(__FILE__))).to eq("./spec/rspec/core/backtrace_formatter_spec.rb")
|
162
|
-
end
|
163
|
-
|
164
|
-
it "preserves the original line" do
|
165
|
-
original_line = File.expand_path(__FILE__)
|
166
|
-
formatter.__send__(:backtrace_line, original_line)
|
167
|
-
expect(original_line).to eq(File.expand_path(__FILE__))
|
168
|
-
end
|
169
|
-
|
170
|
-
it "deals gracefully with a security error" do
|
171
|
-
safely do
|
172
|
-
formatter.__send__(:backtrace_line, __FILE__)
|
173
|
-
# on some rubies, this doesn't raise a SecurityError; this test just
|
174
|
-
# assures that if it *does* raise an error, the error is caught inside
|
175
|
-
end
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
context "with no patterns" do
|
180
|
-
it "keeps all lines" do
|
181
|
-
lines = ["/tmp/a_file", "some_random_text", "hello\330\271!"]
|
182
|
-
formatter = make_backtrace_formatter([], [])
|
183
|
-
expect(lines.all? {|line| formatter.exclude? line}).to be false
|
184
|
-
end
|
185
|
-
|
186
|
-
it "is considered a full backtrace" do
|
187
|
-
expect(make_backtrace_formatter([], []).full_backtrace?).to be true
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
context "with an exclusion pattern but no inclusion patterns" do
|
192
|
-
it "excludes lines that match the exclusion pattern" do
|
193
|
-
formatter = make_backtrace_formatter([/discard/],[])
|
194
|
-
expect(formatter.exclude? "discard me").to be true
|
195
|
-
end
|
196
|
-
|
197
|
-
it "keeps lines that do not match the exclusion pattern" do
|
198
|
-
formatter = make_backtrace_formatter([/discard/],[])
|
199
|
-
expect(formatter.exclude? "apple").to be false
|
200
|
-
end
|
201
|
-
|
202
|
-
it "is considered a partial backtrace" do
|
203
|
-
formatter = make_backtrace_formatter([/discard/],[])
|
204
|
-
expect(formatter.full_backtrace?).to be false
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
context "with an exclusion pattern and an inclusion pattern" do
|
209
|
-
it "excludes lines that match the exclusion pattern but not the inclusion pattern" do
|
210
|
-
formatter = make_backtrace_formatter([/discard/],[/keep/])
|
211
|
-
expect(formatter.exclude? "discard").to be true
|
212
|
-
end
|
213
|
-
|
214
|
-
it "keeps lines that match both patterns" do
|
215
|
-
formatter = make_backtrace_formatter([/discard/],[/keep/])
|
216
|
-
expect(formatter.exclude? "discard/keep").to be false
|
217
|
-
end
|
218
|
-
|
219
|
-
it "keeps lines that match neither pattern" do
|
220
|
-
formatter = make_backtrace_formatter([/discard/],[/keep/])
|
221
|
-
expect(formatter.exclude? "fish").to be false
|
222
|
-
end
|
223
|
-
|
224
|
-
it "is considered a partial backtrace" do
|
225
|
-
formatter = make_backtrace_formatter([/discard/],[/keep/])
|
226
|
-
expect(formatter.full_backtrace?).to be false
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
230
|
-
end
|
@@ -1,112 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "stringio"
|
3
|
-
require 'tmpdir'
|
4
|
-
|
5
|
-
module RSpec::Core
|
6
|
-
RSpec.describe CommandLine do
|
7
|
-
|
8
|
-
let(:out) { StringIO.new }
|
9
|
-
let(:err) { StringIO.new }
|
10
|
-
let(:config) { RSpec::configuration }
|
11
|
-
let(:world) { RSpec::world }
|
12
|
-
|
13
|
-
before do
|
14
|
-
allow(config.hooks).to receive(:run)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "configures streams before command line options" do
|
18
|
-
allow(RSpec).to receive(:deprecate) # remove this and should_receive when ordered
|
19
|
-
stdout = StringIO.new
|
20
|
-
allow(config).to receive(:load_spec_files)
|
21
|
-
allow(config).to receive(:reporter).and_return(double.as_null_object)
|
22
|
-
config.output_stream = $stdout
|
23
|
-
|
24
|
-
# this is necessary to ensure that color works correctly on windows
|
25
|
-
expect(config).to receive(:error_stream=).ordered
|
26
|
-
expect(config).to receive(:output_stream=).ordered
|
27
|
-
expect(config).to receive(:force).at_least(:once).ordered
|
28
|
-
|
29
|
-
command_line = build_command_line
|
30
|
-
command_line.run err, stdout
|
31
|
-
end
|
32
|
-
|
33
|
-
it "assigns ConfigurationOptions built from Array of options to @options" do
|
34
|
-
config_options = ConfigurationOptions.new(%w[--color])
|
35
|
-
command_line = CommandLine.new(%w[--color])
|
36
|
-
expect(command_line.instance_eval { @options.options }).to eq(config_options.options)
|
37
|
-
end
|
38
|
-
|
39
|
-
it "assigns submitted ConfigurationOptions to @options" do
|
40
|
-
config_options = ConfigurationOptions.new(%w[--color])
|
41
|
-
command_line = CommandLine.new(config_options)
|
42
|
-
expect(command_line.instance_eval { @options }).to be(config_options)
|
43
|
-
end
|
44
|
-
|
45
|
-
describe "#run" do
|
46
|
-
context "running files" do
|
47
|
-
include_context "spec files"
|
48
|
-
|
49
|
-
it "returns 0 if spec passes" do
|
50
|
-
command_line = build_command_line passing_spec_filename
|
51
|
-
expect(command_line.run(err, out)).to eq 0
|
52
|
-
end
|
53
|
-
|
54
|
-
it "returns 1 if spec fails" do
|
55
|
-
command_line = build_command_line failing_spec_filename
|
56
|
-
expect(command_line.run(err, out)).to eq 1
|
57
|
-
end
|
58
|
-
|
59
|
-
it "returns 2 if spec fails and --failure-exit-code is 2" do
|
60
|
-
command_line = build_command_line failing_spec_filename, "--failure-exit-code", "2"
|
61
|
-
expect(command_line.run(err, out)).to eq 2
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
context "running hooks" do
|
66
|
-
before { allow(config).to receive :load_spec_files }
|
67
|
-
|
68
|
-
it "runs before suite hooks" do
|
69
|
-
expect(config.hooks).to receive(:run).with(:before, :suite)
|
70
|
-
command_line = build_command_line
|
71
|
-
command_line.run err, out
|
72
|
-
end
|
73
|
-
|
74
|
-
it "runs after suite hooks" do
|
75
|
-
expect(config.hooks).to receive(:run).with(:after, :suite)
|
76
|
-
command_line = build_command_line
|
77
|
-
command_line.run err, out
|
78
|
-
end
|
79
|
-
|
80
|
-
it "runs after suite hooks even after an error" do
|
81
|
-
expect(config.hooks).to receive(:run).with(:before, :suite).and_raise "this error"
|
82
|
-
expect(config.hooks).to receive(:run).with(:after , :suite)
|
83
|
-
expect do
|
84
|
-
command_line = build_command_line
|
85
|
-
command_line.run err, out
|
86
|
-
end.to raise_error
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
describe "#run with custom output" do
|
92
|
-
before { allow(config).to receive_messages :files_to_run => [] }
|
93
|
-
|
94
|
-
let(:output_file) { File.new("#{Dir.tmpdir}/command_line_spec_output.txt", 'w') }
|
95
|
-
|
96
|
-
it "doesn't override output_stream" do
|
97
|
-
config.output_stream = output_file
|
98
|
-
command_line = build_command_line
|
99
|
-
command_line.run err, nil
|
100
|
-
expect(command_line.instance_eval { @configuration.output_stream }).to eq output_file
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
def build_command_line *args
|
105
|
-
CommandLine.new build_config_options(*args)
|
106
|
-
end
|
107
|
-
|
108
|
-
def build_config_options *args
|
109
|
-
ConfigurationOptions.new args
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
File without changes
|
@@ -1,409 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ostruct'
|
3
|
-
require 'rspec/core/drb_options'
|
4
|
-
|
5
|
-
RSpec.describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolated_home => true do
|
6
|
-
include ConfigOptionsHelper
|
7
|
-
|
8
|
-
it "warns when HOME env var is not set", :unless => (RUBY_PLATFORM == 'java') do
|
9
|
-
without_env_vars 'HOME' do
|
10
|
-
expect_warning_with_call_site(__FILE__, __LINE__ + 1)
|
11
|
-
RSpec::Core::ConfigurationOptions.new([]).options
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
it "does not mutate the provided args array" do
|
16
|
-
args = ['-e', 'some spec']
|
17
|
-
RSpec::Core::ConfigurationOptions.new(args).options
|
18
|
-
expect(args).to eq(['-e', 'some spec'])
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "#configure" do
|
22
|
-
let(:config) { RSpec::Core::Configuration.new }
|
23
|
-
|
24
|
-
it "sends libs before requires" do
|
25
|
-
opts = config_options_object(*%w[--require a/path -I a/lib])
|
26
|
-
config = double("config").as_null_object
|
27
|
-
expect(config).to receive(:libs=).ordered
|
28
|
-
expect(config).to receive(:requires=).ordered
|
29
|
-
opts.configure(config)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "loads requires before loading specs" do
|
33
|
-
opts = config_options_object(*%w[-rspec_helper])
|
34
|
-
config = RSpec::Core::Configuration.new
|
35
|
-
expect(config).to receive(:requires=).ordered
|
36
|
-
expect(config).to receive(:get_files_to_run).ordered
|
37
|
-
opts.configure(config)
|
38
|
-
config.files_to_run
|
39
|
-
end
|
40
|
-
|
41
|
-
it "sets up load path and requires before formatter" do
|
42
|
-
opts = config_options_object(*%w[--require a/path -f a/formatter])
|
43
|
-
config = double("config").as_null_object
|
44
|
-
expect(config).to receive(:requires=).ordered
|
45
|
-
expect(config).to receive(:add_formatter).ordered
|
46
|
-
opts.configure(config)
|
47
|
-
end
|
48
|
-
|
49
|
-
it "sets default_path before loading specs" do
|
50
|
-
opts = config_options_object(*%w[--default_path spec])
|
51
|
-
config = RSpec::Core::Configuration.new
|
52
|
-
expect(config).to receive(:force).with(:default_path => 'spec').ordered
|
53
|
-
expect(config).to receive(:get_files_to_run).ordered
|
54
|
-
opts.configure(config)
|
55
|
-
config.files_to_run
|
56
|
-
end
|
57
|
-
|
58
|
-
it "sets `files_or_directories_to_run` before `requires` so users can check `files_to_run` in a spec_helper loaded by `--require`" do
|
59
|
-
opts = config_options_object(*%w[--require spec_helper])
|
60
|
-
config = RSpec::Core::Configuration.new
|
61
|
-
expect(config).to receive(:files_or_directories_to_run=).ordered
|
62
|
-
expect(config).to receive(:requires=).ordered
|
63
|
-
opts.configure(config)
|
64
|
-
end
|
65
|
-
|
66
|
-
it "sets default_path before `files_or_directories_to_run` since it relies on it" do
|
67
|
-
opts = config_options_object(*%w[--default_path spec])
|
68
|
-
config = RSpec::Core::Configuration.new
|
69
|
-
expect(config).to receive(:force).with(:default_path => 'spec').ordered
|
70
|
-
expect(config).to receive(:files_or_directories_to_run=).ordered
|
71
|
-
opts.configure(config)
|
72
|
-
end
|
73
|
-
|
74
|
-
it "sets pattern before loading specs" do
|
75
|
-
opts = config_options_object(*%w[--pattern **/*.spec])
|
76
|
-
config = RSpec::Core::Configuration.new
|
77
|
-
expect(config).to receive(:force).with(:pattern => '**/*.spec').ordered
|
78
|
-
expect(config).to receive(:get_files_to_run).ordered
|
79
|
-
opts.configure(config)
|
80
|
-
config.files_to_run
|
81
|
-
end
|
82
|
-
|
83
|
-
it "assigns inclusion_filter" do
|
84
|
-
opts = config_options_object(*%w[--tag awesome])
|
85
|
-
opts.configure(config)
|
86
|
-
expect(config.inclusion_filter).to have_key(:awesome)
|
87
|
-
end
|
88
|
-
|
89
|
-
it "merges the :exclusion_filter option with the default exclusion_filter" do
|
90
|
-
opts = config_options_object(*%w[--tag ~slow])
|
91
|
-
opts.configure(config)
|
92
|
-
expect(config.exclusion_filter).to have_key(:slow)
|
93
|
-
end
|
94
|
-
|
95
|
-
it "forces color_enabled" do
|
96
|
-
opts = config_options_object(*%w[--color])
|
97
|
-
config = RSpec::Core::Configuration.new
|
98
|
-
expect(config).to receive(:force).with(:color => true)
|
99
|
-
opts.configure(config)
|
100
|
-
end
|
101
|
-
|
102
|
-
[
|
103
|
-
["--failure-exit-code", "3", :failure_exit_code, 3 ],
|
104
|
-
["--pattern", "foo/bar", :pattern, "foo/bar"],
|
105
|
-
["--failure-exit-code", "37", :failure_exit_code, 37],
|
106
|
-
["--default_path", "behavior", :default_path, "behavior"],
|
107
|
-
["--order", "rand", :order, "rand"],
|
108
|
-
["--seed", "37", :order, "rand:37"],
|
109
|
-
["--drb-port", "37", :drb_port, 37]
|
110
|
-
].each do |cli_option, cli_value, config_key, config_value|
|
111
|
-
it "forces #{config_key}" do
|
112
|
-
opts = config_options_object(cli_option, cli_value)
|
113
|
-
config = RSpec::Core::Configuration.new
|
114
|
-
expect(config).to receive(:force) do |pair|
|
115
|
-
expect(pair.keys.first).to eq(config_key)
|
116
|
-
expect(pair.values.first).to eq(config_value)
|
117
|
-
end
|
118
|
-
opts.configure(config)
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
it "merges --require specified by multiple configuration sources" do
|
123
|
-
with_env_vars 'SPEC_OPTS' => "--require file_from_env" do
|
124
|
-
opts = config_options_object(*%w[--require file_from_opts])
|
125
|
-
expect(config).to receive(:require).with("file_from_opts")
|
126
|
-
expect(config).to receive(:require).with("file_from_env")
|
127
|
-
opts.configure(config)
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
it "merges --I specified by multiple configuration sources" do
|
132
|
-
with_env_vars 'SPEC_OPTS' => "-I dir_from_env" do
|
133
|
-
opts = config_options_object(*%w[-I dir_from_opts])
|
134
|
-
expect(config).to receive(:libs=).with(["dir_from_opts", "dir_from_env"])
|
135
|
-
opts.configure(config)
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
describe "-c, --color, and --colour" do
|
141
|
-
it "sets :color => true" do
|
142
|
-
expect(parse_options('-c')).to include(:color => true)
|
143
|
-
expect(parse_options('--color')).to include(:color => true)
|
144
|
-
expect(parse_options('--colour')).to include(:color => true)
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
describe "--no-color" do
|
149
|
-
it "sets :color => false" do
|
150
|
-
expect(parse_options('--no-color')).to include(:color => false)
|
151
|
-
end
|
152
|
-
|
153
|
-
it "overrides previous :color => true" do
|
154
|
-
expect(parse_options('--color', '--no-color')).to include(:color => false)
|
155
|
-
end
|
156
|
-
|
157
|
-
it "gets overriden by a subsequent :color => true" do
|
158
|
-
expect(parse_options('--no-color', '--color')).to include(:color => true)
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
describe "-I" do
|
163
|
-
example "adds to :libs" do
|
164
|
-
expect(parse_options('-I', 'a_dir')).to include(:libs => ['a_dir'])
|
165
|
-
end
|
166
|
-
example "can be used more than once" do
|
167
|
-
expect(parse_options('-I', 'dir_1', '-I', 'dir_2')).to include(:libs => ['dir_1','dir_2'])
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
describe '--require' do
|
172
|
-
example "requires files" do
|
173
|
-
expect(parse_options('--require', 'a/path')).to include(:requires => ['a/path'])
|
174
|
-
end
|
175
|
-
example "can be used more than once" do
|
176
|
-
expect(parse_options('--require', 'path/1', '--require', 'path/2')).to include(:requires => ['path/1','path/2'])
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
describe "--format, -f" do
|
181
|
-
it "sets :formatter" do
|
182
|
-
[['--format', 'd'], ['-f', 'd'], '-fd'].each do |args|
|
183
|
-
expect(parse_options(*args)).to include(:formatters => [['d']])
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
example "can accept a class name" do
|
188
|
-
expect(parse_options('-fSome::Formatter::Class')).to include(:formatters => [['Some::Formatter::Class']])
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
describe "--profile, -p" do
|
193
|
-
it "sets :profile_examples" do
|
194
|
-
expect(parse_options('-p')).to include(:profile_examples => true)
|
195
|
-
expect(parse_options('--profile')).to include(:profile_examples => true)
|
196
|
-
expect(parse_options('-p', '4')).to include(:profile_examples => 4)
|
197
|
-
expect(parse_options('--profile', '3')).to include(:profile_examples => 3)
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
describe "--no-profile" do
|
202
|
-
it "sets :profile_examples to false" do
|
203
|
-
expect(parse_options('--no-profile')).to include(:profile_examples => false)
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
describe '--line_number' do
|
208
|
-
it "sets :line_number" do
|
209
|
-
expect(parse_options('-l','3')).to include(:line_numbers => ['3'])
|
210
|
-
expect(parse_options('--line_number','3')).to include(:line_numbers => ['3'])
|
211
|
-
end
|
212
|
-
|
213
|
-
it "can be specified multiple times" do
|
214
|
-
expect(parse_options('-l','3', '-l', '6')).to include(:line_numbers => ['3', '6'])
|
215
|
-
expect(parse_options('--line_number','3', '--line_number', '6')).to include(:line_numbers => ['3', '6'])
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
describe "--example" do
|
220
|
-
it "sets :full_description" do
|
221
|
-
expect(parse_options('--example','foo')).to include(:full_description => [/foo/])
|
222
|
-
expect(parse_options('-e','bar')).to include(:full_description => [/bar/])
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
describe "--backtrace, -b" do
|
227
|
-
it "sets full_backtrace on config" do
|
228
|
-
expect(parse_options("--backtrace")).to include(:full_backtrace => true)
|
229
|
-
expect(parse_options("-b")).to include(:full_backtrace => true)
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
describe "--fail-fast" do
|
234
|
-
it "defaults to false" do
|
235
|
-
expect(parse_options[:fail_fast]).to be_falsey
|
236
|
-
end
|
237
|
-
|
238
|
-
it "sets fail_fast on config" do
|
239
|
-
expect(parse_options("--fail-fast")[:fail_fast]).to be_truthy
|
240
|
-
end
|
241
|
-
|
242
|
-
it "sets fail_fast on config" do
|
243
|
-
expect(parse_options("--no-fail-fast")[:fail_fast]).to be_falsey
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
describe "--failure-exit-code" do
|
248
|
-
it "sets :failure_exit_code" do
|
249
|
-
expect(parse_options('--failure-exit-code', '0')).to include(:failure_exit_code => 0)
|
250
|
-
expect(parse_options('--failure-exit-code', '1')).to include(:failure_exit_code => 1)
|
251
|
-
expect(parse_options('--failure-exit-code', '2')).to include(:failure_exit_code => 2)
|
252
|
-
end
|
253
|
-
|
254
|
-
it "overrides previous :failure_exit_code" do
|
255
|
-
expect(parse_options('--failure-exit-code', '2', '--failure-exit-code', '3')).to include(:failure_exit_code => 3)
|
256
|
-
end
|
257
|
-
end
|
258
|
-
|
259
|
-
describe "--dry-run" do
|
260
|
-
it "defaults to false" do
|
261
|
-
expect(parse_options[:dry_run]).to be_falsey
|
262
|
-
end
|
263
|
-
|
264
|
-
it "sets dry_run on config" do
|
265
|
-
expect(parse_options("--dry-run")[:dry_run]).to be_truthy
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
describe "--options" do
|
270
|
-
it "sets :custom_options_file" do
|
271
|
-
expect(parse_options(*%w[-O my.opts])).to include(:custom_options_file => "my.opts")
|
272
|
-
expect(parse_options(*%w[--options my.opts])).to include(:custom_options_file => "my.opts")
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
|
-
describe "--drb, -X" do
|
277
|
-
it "does not send --drb back to the parser after parsing options" do
|
278
|
-
expect(config_options_object("--drb", "--color").drb_argv).not_to include("--drb")
|
279
|
-
end
|
280
|
-
end
|
281
|
-
|
282
|
-
describe "--no-drb" do
|
283
|
-
it "disables drb" do
|
284
|
-
expect(parse_options("--no-drb")).to include(:drb => false)
|
285
|
-
end
|
286
|
-
|
287
|
-
it "overrides a previous drb => true" do
|
288
|
-
expect(parse_options("--drb", "--no-drb")).to include(:drb => false)
|
289
|
-
end
|
290
|
-
|
291
|
-
it "gets overriden by a subsquent drb => true" do
|
292
|
-
expect(parse_options("--no-drb", "--drb")).to include(:drb => true)
|
293
|
-
end
|
294
|
-
end
|
295
|
-
|
296
|
-
|
297
|
-
describe "files_or_directories_to_run" do
|
298
|
-
it "parses files from '-c file.rb dir/file.rb'" do
|
299
|
-
expect(parse_options("-c", "file.rb", "dir/file.rb")).to include(
|
300
|
-
:files_or_directories_to_run => ["file.rb", "dir/file.rb"]
|
301
|
-
)
|
302
|
-
end
|
303
|
-
|
304
|
-
it "parses dir from 'dir'" do
|
305
|
-
expect(parse_options("dir")).to include(:files_or_directories_to_run => ["dir"])
|
306
|
-
end
|
307
|
-
|
308
|
-
it "parses dir and files from 'spec/file1_spec.rb, spec/file2_spec.rb'" do
|
309
|
-
expect(parse_options("dir", "spec/file1_spec.rb", "spec/file2_spec.rb")).to include(
|
310
|
-
:files_or_directories_to_run => ["dir", "spec/file1_spec.rb", "spec/file2_spec.rb"]
|
311
|
-
)
|
312
|
-
end
|
313
|
-
|
314
|
-
it "parses file names that look like options line-number and default-path" do
|
315
|
-
expect(parse_options("spec/default_path_spec.rb", "spec/line_number_spec.rb")).to include(
|
316
|
-
:files_or_directories_to_run => ["spec/default_path_spec.rb", "spec/line_number_spec.rb"]
|
317
|
-
)
|
318
|
-
end
|
319
|
-
|
320
|
-
it "provides no files or directories if spec directory does not exist" do
|
321
|
-
allow(FileTest).to receive(:directory?).with("spec").and_return false
|
322
|
-
expect(parse_options()).to include(:files_or_directories_to_run => [])
|
323
|
-
end
|
324
|
-
end
|
325
|
-
|
326
|
-
describe "default_path" do
|
327
|
-
it "gets set before files_or_directories_to_run" do
|
328
|
-
config = RSpec::Core::Configuration.new
|
329
|
-
expect(config).to receive(:force).with(:default_path => 'foo').ordered
|
330
|
-
expect(config).to receive(:get_files_to_run).ordered
|
331
|
-
opts = config_options_object("--default_path", "foo")
|
332
|
-
opts.configure(config)
|
333
|
-
config.files_to_run
|
334
|
-
end
|
335
|
-
end
|
336
|
-
|
337
|
-
describe "#filter_manager" do
|
338
|
-
it "returns the same object as RSpec::configuration.filter_manager" do
|
339
|
-
expect(config_options_object.filter_manager).to be(RSpec::configuration.filter_manager)
|
340
|
-
end
|
341
|
-
end
|
342
|
-
|
343
|
-
describe "sources: ~/.rspec, ./.rspec, ./.rspec-local, custom, CLI, and SPEC_OPTS" do
|
344
|
-
it "merges global, local, SPEC_OPTS, and CLI" do
|
345
|
-
File.open("./.rspec", "w") {|f| f << "--line 37"}
|
346
|
-
File.open("./.rspec-local", "w") {|f| f << "--format global"}
|
347
|
-
File.open(File.expand_path("~/.rspec"), "w") {|f| f << "--color"}
|
348
|
-
with_env_vars 'SPEC_OPTS' => "--example 'foo bar'" do
|
349
|
-
options = parse_options("--drb")
|
350
|
-
expect(options[:color]).to be_truthy
|
351
|
-
expect(options[:line_numbers]).to eq(["37"])
|
352
|
-
expect(options[:full_description]).to eq([/foo\ bar/])
|
353
|
-
expect(options[:drb]).to be_truthy
|
354
|
-
expect(options[:formatters]).to eq([['global']])
|
355
|
-
end
|
356
|
-
end
|
357
|
-
|
358
|
-
it "prefers SPEC_OPTS over CLI" do
|
359
|
-
with_env_vars 'SPEC_OPTS' => "--format spec_opts" do
|
360
|
-
expect(parse_options("--format", "cli")[:formatters]).to eq([['spec_opts']])
|
361
|
-
end
|
362
|
-
end
|
363
|
-
|
364
|
-
it "prefers CLI over file options" do
|
365
|
-
File.open("./.rspec", "w") {|f| f << "--format project"}
|
366
|
-
File.open(File.expand_path("~/.rspec"), "w") {|f| f << "--format global"}
|
367
|
-
expect(parse_options("--format", "cli")[:formatters]).to eq([['cli']])
|
368
|
-
end
|
369
|
-
|
370
|
-
it "prefers project file options over global file options" do
|
371
|
-
File.open("./.rspec", "w") {|f| f << "--format project"}
|
372
|
-
File.open(File.expand_path("~/.rspec"), "w") {|f| f << "--format global"}
|
373
|
-
expect(parse_options[:formatters]).to eq([['project']])
|
374
|
-
end
|
375
|
-
|
376
|
-
it "prefers local file options over project file options" do
|
377
|
-
File.open("./.rspec-local", "w") {|f| f << "--format local"}
|
378
|
-
File.open("./.rspec", "w") {|f| f << "--format global"}
|
379
|
-
expect(parse_options[:formatters]).to eq([['local']])
|
380
|
-
end
|
381
|
-
|
382
|
-
it "parses options file correctly if erb code has trimming options" do
|
383
|
-
File.open("./.rspec", "w") do |f|
|
384
|
-
f << "<% if true -%>\n"
|
385
|
-
f << "--format local\n"
|
386
|
-
f << "<%- end %>\n"
|
387
|
-
end
|
388
|
-
|
389
|
-
expect(parse_options[:formatters]).to eq([['local']])
|
390
|
-
end
|
391
|
-
|
392
|
-
context "with custom options file" do
|
393
|
-
it "ignores project and global options files" do
|
394
|
-
File.open("./.rspec", "w") {|f| f << "--format project"}
|
395
|
-
File.open(File.expand_path("~/.rspec"), "w") {|f| f << "--format global"}
|
396
|
-
File.open("./custom.opts", "w") {|f| f << "--color"}
|
397
|
-
options = parse_options("-O", "./custom.opts")
|
398
|
-
expect(options[:format]).to be_nil
|
399
|
-
expect(options[:color]).to be_truthy
|
400
|
-
end
|
401
|
-
|
402
|
-
it "parses -e 'full spec description'" do
|
403
|
-
File.open("./custom.opts", "w") {|f| f << "-e 'The quick brown fox jumps over the lazy dog'"}
|
404
|
-
options = parse_options("-O", "./custom.opts")
|
405
|
-
expect(options[:full_description]).to eq([/The\ quick\ brown\ fox\ jumps\ over\ the\ lazy\ dog/])
|
406
|
-
end
|
407
|
-
end
|
408
|
-
end
|
409
|
-
end
|