rspec-core 2.99.2 → 3.0.0.beta1

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.
Files changed (165) hide show
  1. checksums.yaml +14 -6
  2. checksums.yaml.gz.sig +2 -0
  3. data.tar.gz.sig +0 -0
  4. data/Changelog.md +103 -191
  5. data/License.txt +1 -0
  6. data/README.md +4 -25
  7. data/features/Upgrade.md +2 -14
  8. data/features/command_line/dry_run.feature +29 -0
  9. data/features/command_line/example_name_option.feature +1 -1
  10. data/features/command_line/fail_fast.feature +26 -0
  11. data/features/command_line/format_option.feature +3 -3
  12. data/features/command_line/line_number_option.feature +16 -11
  13. data/features/command_line/order.feature +2 -3
  14. data/features/command_line/pattern_option.feature +3 -3
  15. data/features/command_line/randomization.feature +63 -0
  16. data/features/command_line/require_option.feature +2 -2
  17. data/features/command_line/ruby.feature +1 -1
  18. data/features/configuration/alias_example_to.feature +13 -22
  19. data/features/configuration/{backtrace_clean_patterns.feature → backtrace_exclusion_patterns.feature} +17 -14
  20. data/features/configuration/custom_settings.feature +11 -11
  21. data/features/configuration/overriding_global_ordering.feature +93 -0
  22. data/features/configuration/profile.feature +13 -13
  23. data/features/configuration/read_options_from_file.feature +7 -7
  24. data/features/example_groups/basic_structure.feature +1 -1
  25. data/features/example_groups/shared_context.feature +8 -8
  26. data/features/example_groups/shared_examples.feature +6 -14
  27. data/features/expectation_framework_integration/configure_expectation_framework.feature +27 -122
  28. data/features/filtering/exclusion_filters.feature +2 -5
  29. data/features/filtering/inclusion_filters.feature +1 -5
  30. data/features/formatters/json_formatter.feature +2 -2
  31. data/features/formatters/text_formatter.feature +4 -4
  32. data/features/helper_methods/arbitrary_methods.feature +2 -2
  33. data/features/helper_methods/let.feature +5 -5
  34. data/features/helper_methods/modules.feature +5 -8
  35. data/features/hooks/around_hooks.feature +2 -2
  36. data/features/hooks/before_and_after_hooks.feature +14 -14
  37. data/features/hooks/filtering.feature +12 -14
  38. data/features/metadata/described_class.feature +1 -1
  39. data/features/metadata/user_defined.feature +16 -29
  40. data/features/mock_framework_integration/use_flexmock.feature +1 -1
  41. data/features/mock_framework_integration/use_mocha.feature +1 -1
  42. data/features/mock_framework_integration/use_rr.feature +1 -1
  43. data/features/mock_framework_integration/use_rspec.feature +5 -5
  44. data/features/pending/pending_examples.feature +5 -5
  45. data/features/spec_files/arbitrary_file_suffix.feature +1 -1
  46. data/features/step_definitions/additional_cli_steps.rb +3 -3
  47. data/features/subject/explicit_subject.feature +8 -8
  48. data/features/subject/implicit_receiver.feature +29 -0
  49. data/features/subject/implicit_subject.feature +4 -4
  50. data/features/support/env.rb +10 -3
  51. data/features/support/require_expect_syntax_in_aruba_specs.rb +16 -0
  52. data/lib/rspec/core.rb +11 -48
  53. data/lib/rspec/core/backport_random.rb +302 -0
  54. data/lib/rspec/core/backtrace_formatter.rb +65 -0
  55. data/lib/rspec/core/command_line.rb +7 -18
  56. data/lib/rspec/core/configuration.rb +202 -507
  57. data/lib/rspec/core/configuration_options.rb +17 -30
  58. data/lib/rspec/core/example.rb +29 -39
  59. data/lib/rspec/core/example_group.rb +166 -259
  60. data/lib/rspec/core/filter_manager.rb +30 -47
  61. data/lib/rspec/core/flat_map.rb +17 -0
  62. data/lib/rspec/core/formatters.rb +0 -138
  63. data/lib/rspec/core/formatters/base_formatter.rb +46 -1
  64. data/lib/rspec/core/formatters/base_text_formatter.rb +38 -61
  65. data/lib/rspec/core/formatters/deprecation_formatter.rb +21 -52
  66. data/lib/rspec/core/formatters/helpers.rb +0 -28
  67. data/lib/rspec/core/formatters/html_formatter.rb +1 -1
  68. data/lib/rspec/core/formatters/json_formatter.rb +38 -9
  69. data/lib/rspec/core/formatters/snippet_extractor.rb +14 -5
  70. data/lib/rspec/core/hooks.rb +55 -39
  71. data/lib/rspec/core/memoized_helpers.rb +17 -167
  72. data/lib/rspec/core/metadata.rb +16 -64
  73. data/lib/rspec/core/option_parser.rb +30 -39
  74. data/lib/rspec/core/ordering.rb +154 -0
  75. data/lib/rspec/core/pending.rb +12 -69
  76. data/lib/rspec/core/project_initializer.rb +12 -10
  77. data/lib/rspec/core/rake_task.rb +5 -108
  78. data/lib/rspec/core/reporter.rb +15 -18
  79. data/lib/rspec/core/runner.rb +16 -30
  80. data/lib/rspec/core/shared_context.rb +3 -5
  81. data/lib/rspec/core/shared_example_group.rb +3 -51
  82. data/lib/rspec/core/shared_example_group/collection.rb +1 -19
  83. data/lib/rspec/core/version.rb +1 -1
  84. data/lib/rspec/core/warnings.rb +22 -0
  85. data/lib/rspec/core/world.rb +12 -8
  86. data/spec/command_line/order_spec.rb +20 -23
  87. data/spec/rspec/core/backtrace_formatter_spec.rb +216 -0
  88. data/spec/rspec/core/command_line_spec.rb +32 -48
  89. data/spec/rspec/core/configuration_options_spec.rb +19 -50
  90. data/spec/rspec/core/configuration_spec.rb +142 -713
  91. data/spec/rspec/core/drb_command_line_spec.rb +2 -0
  92. data/spec/rspec/core/dsl_spec.rb +0 -1
  93. data/spec/rspec/core/example_group_spec.rb +192 -223
  94. data/spec/rspec/core/example_spec.rb +40 -16
  95. data/spec/rspec/core/filter_manager_spec.rb +2 -2
  96. data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -41
  97. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +5 -123
  98. data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +2 -87
  99. data/spec/rspec/core/formatters/documentation_formatter_spec.rb +2 -3
  100. data/spec/rspec/core/formatters/{text_mate_formatted.html → html_formatted-1.8.7-jruby.html} +44 -25
  101. data/spec/rspec/core/formatters/html_formatted-1.8.7-rbx.html +477 -0
  102. data/spec/rspec/core/formatters/{html_formatted.html → html_formatted-1.8.7.html} +42 -25
  103. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +425 -0
  104. data/spec/rspec/core/formatters/html_formatted-1.9.3-jruby.html +416 -0
  105. data/spec/rspec/core/formatters/html_formatted-1.9.3-rbx.html +477 -0
  106. data/spec/rspec/core/formatters/html_formatted-1.9.3.html +419 -0
  107. data/spec/rspec/core/formatters/html_formatted-2.0.0.html +425 -0
  108. data/spec/rspec/core/formatters/html_formatter_spec.rb +21 -46
  109. data/spec/rspec/core/formatters/json_formatter_spec.rb +97 -8
  110. data/spec/rspec/core/hooks_filtering_spec.rb +5 -5
  111. data/spec/rspec/core/hooks_spec.rb +61 -47
  112. data/spec/rspec/core/memoized_helpers_spec.rb +20 -322
  113. data/spec/rspec/core/metadata_spec.rb +1 -24
  114. data/spec/rspec/core/option_parser_spec.rb +20 -62
  115. data/spec/rspec/core/ordering_spec.rb +102 -0
  116. data/spec/rspec/core/pending_example_spec.rb +0 -40
  117. data/spec/rspec/core/project_initializer_spec.rb +1 -25
  118. data/spec/rspec/core/rake_task_spec.rb +5 -72
  119. data/spec/rspec/core/random_spec.rb +47 -0
  120. data/spec/rspec/core/reporter_spec.rb +23 -48
  121. data/spec/rspec/core/runner_spec.rb +31 -39
  122. data/spec/rspec/core/shared_context_spec.rb +3 -15
  123. data/spec/rspec/core/shared_example_group/collection_spec.rb +4 -17
  124. data/spec/rspec/core/shared_example_group_spec.rb +12 -45
  125. data/spec/rspec/core/{deprecation_spec.rb → warnings_spec.rb} +3 -1
  126. data/spec/rspec/core_spec.rb +4 -21
  127. data/spec/spec_helper.rb +41 -5
  128. data/spec/support/helper_methods.rb +0 -29
  129. data/spec/support/sandboxed_mock_space.rb +0 -16
  130. data/spec/support/shared_example_groups.rb +7 -36
  131. data/spec/support/stderr_splitter.rb +36 -0
  132. metadata +163 -157
  133. metadata.gz.sig +1 -0
  134. data/exe/autospec +0 -13
  135. data/features/Autotest.md +0 -38
  136. data/features/configuration/treat_symbols_as_metadata_keys_with_true_values.feature +0 -52
  137. data/features/subject/attribute_of_subject.feature +0 -124
  138. data/features/subject/one_liner_syntax.feature +0 -71
  139. data/lib/autotest/discover.rb +0 -10
  140. data/lib/autotest/rspec2.rb +0 -77
  141. data/lib/rspec/core/backtrace_cleaner.rb +0 -46
  142. data/lib/rspec/core/backward_compatibility.rb +0 -55
  143. data/lib/rspec/core/caller_filter.rb +0 -60
  144. data/lib/rspec/core/deprecated_mutable_array_proxy.rb +0 -32
  145. data/lib/rspec/core/deprecation.rb +0 -26
  146. data/lib/rspec/core/extensions/instance_eval_with_args.rb +0 -44
  147. data/lib/rspec/core/extensions/kernel.rb +0 -9
  148. data/lib/rspec/core/extensions/module_eval_with_args.rb +0 -38
  149. data/lib/rspec/core/extensions/ordered.rb +0 -27
  150. data/lib/rspec/core/formatters/console_codes.rb +0 -42
  151. data/lib/rspec/core/formatters/text_mate_formatter.rb +0 -34
  152. data/lib/rspec/core/metadata_hash_builder.rb +0 -97
  153. data/lib/rspec/core/minitest_assertions_adapter.rb +0 -28
  154. data/lib/rspec/core/test_unit_assertions_adapter.rb +0 -30
  155. data/spec/autotest/discover_spec.rb +0 -49
  156. data/spec/autotest/failed_results_re_spec.rb +0 -45
  157. data/spec/autotest/rspec_spec.rb +0 -133
  158. data/spec/rspec/core/backtrace_cleaner_spec.rb +0 -68
  159. data/spec/rspec/core/caller_filter_spec.rb +0 -58
  160. data/spec/rspec/core/deprecations_spec.rb +0 -59
  161. data/spec/rspec/core/formatters/console_codes_spec.rb +0 -50
  162. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +0 -107
  163. data/spec/rspec/core/kernel_extensions_spec.rb +0 -9
  164. data/spec/rspec/core/pending_spec.rb +0 -27
  165. data/spec/support/silence_dsl_deprecations.rb +0 -32
@@ -0,0 +1,216 @@
1
+ require "spec_helper"
2
+
3
+ module RSpec::Core
4
+ 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
+ end
97
+
98
+ describe "#full_backtrace=true" do
99
+ it "sets full_backtrace true" do
100
+ formatter = make_backtrace_formatter([/discard/],[/keep/])
101
+ formatter.full_backtrace = true
102
+ expect(formatter.full_backtrace?).to be true
103
+ end
104
+
105
+ it "preserves exclusion and inclusion patterns" do
106
+ formatter = make_backtrace_formatter([/discard/],[/keep/])
107
+ formatter.full_backtrace = true
108
+ expect(formatter.exclusion_patterns).to eq [/discard/]
109
+ expect(formatter.inclusion_patterns).to eq [/keep/]
110
+ end
111
+
112
+ it "keeps all lines, even those that match exclusions" do
113
+ formatter = make_backtrace_formatter([/discard/],[/keep/])
114
+ formatter.full_backtrace = true
115
+ expect(formatter.exclude? "discard").to be false
116
+ end
117
+ end
118
+
119
+ describe "#full_backtrace=false (after it was true)" do
120
+ it "sets full_backtrace false" do
121
+ formatter = make_backtrace_formatter([/discard/],[/keep/])
122
+ formatter.full_backtrace = true
123
+ formatter.full_backtrace = false
124
+ expect(formatter.full_backtrace?).to be false
125
+ end
126
+
127
+ it "preserves exclusion and inclusion patterns" do
128
+ formatter = make_backtrace_formatter([/discard/],[/keep/])
129
+ formatter.full_backtrace = true
130
+ formatter.full_backtrace = false
131
+ expect(formatter.exclusion_patterns).to eq [/discard/]
132
+ expect(formatter.inclusion_patterns).to eq [/keep/]
133
+ end
134
+
135
+ it "excludes lines that match exclusions" do
136
+ formatter = make_backtrace_formatter([/discard/],[/keep/])
137
+ formatter.full_backtrace = true
138
+ formatter.full_backtrace = false
139
+ expect(formatter.exclude? "discard").to be true
140
+ end
141
+ end
142
+
143
+ describe "#backtrace_line" do
144
+ let(:formatter) { BacktraceFormatter.new }
145
+
146
+ it "trims current working directory" do
147
+ expect(formatter.__send__(:backtrace_line, File.expand_path(__FILE__))).to eq("./spec/rspec/core/backtrace_formatter_spec.rb")
148
+ end
149
+
150
+ it "preserves the original line" do
151
+ original_line = File.expand_path(__FILE__)
152
+ formatter.__send__(:backtrace_line, original_line)
153
+ expect(original_line).to eq(File.expand_path(__FILE__))
154
+ end
155
+
156
+ it "deals gracefully with a security error" do
157
+ safely do
158
+ formatter.__send__(:backtrace_line, __FILE__)
159
+ # on some rubies, this doesn't raise a SecurityError; this test just
160
+ # assures that if it *does* raise an error, the error is caught inside
161
+ end
162
+ end
163
+ end
164
+
165
+ context "with no patterns" do
166
+ it "keeps all lines" do
167
+ lines = ["/tmp/a_file", "some_random_text", "hello\330\271!"]
168
+ formatter = make_backtrace_formatter([], [])
169
+ expect(lines.all? {|line| formatter.exclude? line}).to be false
170
+ end
171
+
172
+ it "is considered a full backtrace" do
173
+ expect(make_backtrace_formatter([], []).full_backtrace?).to be true
174
+ end
175
+ end
176
+
177
+ context "with an exclusion pattern but no inclusion patterns" do
178
+ it "excludes lines that match the exclusion pattern" do
179
+ formatter = make_backtrace_formatter([/discard/],[])
180
+ expect(formatter.exclude? "discard me").to be true
181
+ end
182
+
183
+ it "keeps lines that do not match the exclusion pattern" do
184
+ formatter = make_backtrace_formatter([/discard/],[])
185
+ expect(formatter.exclude? "apple").to be false
186
+ end
187
+
188
+ it "is considered a partial backtrace" do
189
+ formatter = make_backtrace_formatter([/discard/],[])
190
+ expect(formatter.full_backtrace?).to be false
191
+ end
192
+ end
193
+
194
+ context "with an exclusion pattern and an inclusion pattern" do
195
+ it "excludes lines that match the exclusion pattern but not the inclusion pattern" do
196
+ formatter = make_backtrace_formatter([/discard/],[/keep/])
197
+ expect(formatter.exclude? "discard").to be true
198
+ end
199
+
200
+ it "keeps lines that match both patterns" do
201
+ formatter = make_backtrace_formatter([/discard/],[/keep/])
202
+ expect(formatter.exclude? "discard/keep").to be false
203
+ end
204
+
205
+ it "keeps lines that match neither pattern" do
206
+ formatter = make_backtrace_formatter([/discard/],[/keep/])
207
+ expect(formatter.exclude? "fish").to be false
208
+ end
209
+
210
+ it "is considered a partial backtrace" do
211
+ formatter = make_backtrace_formatter([/discard/],[/keep/])
212
+ expect(formatter.full_backtrace?).to be false
213
+ end
214
+ end
215
+ end
216
+ end
@@ -3,7 +3,7 @@ require "stringio"
3
3
  require 'tmpdir'
4
4
 
5
5
  module RSpec::Core
6
- describe Runner do
6
+ describe CommandLine do
7
7
 
8
8
  let(:out) { StringIO.new }
9
9
  let(:err) { StringIO.new }
@@ -13,22 +13,30 @@ module RSpec::Core
13
13
  before { config.stub :run_hook }
14
14
 
15
15
  it "configures streams before command line options" do
16
- config.stub(:reporter => double.as_null_object)
16
+ stdout = StringIO.new
17
17
  config.stub :load_spec_files
18
+ config.stub(:reporter => double.as_null_object)
19
+ config.output_stream = $stdout
18
20
 
19
21
  # this is necessary to ensure that color works correctly on windows
20
22
  config.should_receive(:error_stream=).ordered
21
23
  config.should_receive(:output_stream=).ordered
22
24
  config.should_receive(:force).at_least(:once).ordered
23
25
 
24
- runner = build_runner
25
- runner.run err, out
26
+ command_line = build_command_line
27
+ command_line.run err, stdout
28
+ end
29
+
30
+ it "assigns ConfigurationOptions built from Array of options to @options" do
31
+ config_options = ConfigurationOptions.new(%w[--color])
32
+ command_line = CommandLine.new(%w[--color])
33
+ expect(command_line.instance_eval { @options.options }).to eq(config_options.parse_options)
26
34
  end
27
35
 
28
36
  it "assigns submitted ConfigurationOptions to @options" do
29
37
  config_options = ConfigurationOptions.new(%w[--color])
30
- runner = Runner.new(config_options)
31
- expect(runner.instance_eval { @options }).to be(config_options)
38
+ command_line = CommandLine.new(config_options)
39
+ expect(command_line.instance_eval { @options }).to be(config_options)
32
40
  end
33
41
 
34
42
  describe "#run" do
@@ -36,18 +44,18 @@ module RSpec::Core
36
44
  include_context "spec files"
37
45
 
38
46
  it "returns 0 if spec passes" do
39
- runner = build_runner passing_spec_filename
40
- expect(runner.run(err, out)).to eq 0
47
+ command_line = build_command_line passing_spec_filename
48
+ expect(command_line.run(err, out)).to eq 0
41
49
  end
42
50
 
43
51
  it "returns 1 if spec fails" do
44
- runner = build_runner failing_spec_filename
45
- expect(runner.run(err, out)).to eq 1
52
+ command_line = build_command_line failing_spec_filename
53
+ expect(command_line.run(err, out)).to eq 1
46
54
  end
47
55
 
48
56
  it "returns 2 if spec fails and --failure-exit-code is 2" do
49
- runner = build_runner failing_spec_filename, "--failure-exit-code", "2"
50
- expect(runner.run(err, out)).to eq 2
57
+ command_line = build_command_line failing_spec_filename, "--failure-exit-code", "2"
58
+ expect(command_line.run(err, out)).to eq 2
51
59
  end
52
60
  end
53
61
 
@@ -56,22 +64,22 @@ module RSpec::Core
56
64
 
57
65
  it "runs before suite hooks" do
58
66
  config.should_receive(:run_hook).with(:before, :suite)
59
- runner = build_runner
60
- runner.run err, out
67
+ command_line = build_command_line
68
+ command_line.run err, out
61
69
  end
62
70
 
63
71
  it "runs after suite hooks" do
64
72
  config.should_receive(:run_hook).with(:after, :suite)
65
- runner = build_runner
66
- runner.run err, out
73
+ command_line = build_command_line
74
+ command_line.run err, out
67
75
  end
68
76
 
69
77
  it "runs after suite hooks even after an error" do
70
78
  config.should_receive(:run_hook).with(:before, :suite).and_raise "this error"
71
79
  config.should_receive(:run_hook).with(:after , :suite)
72
80
  expect do
73
- runner = build_runner
74
- runner.run err, out
81
+ command_line = build_command_line
82
+ command_line.run err, out
75
83
  end.to raise_error
76
84
  end
77
85
  end
@@ -80,18 +88,18 @@ module RSpec::Core
80
88
  describe "#run with custom output" do
81
89
  before { config.stub :files_to_run => [] }
82
90
 
83
- let(:output_file) { File.new("#{Dir.tmpdir}/runner_spec_output.txt", 'w') }
91
+ let(:output_file) { File.new("#{Dir.tmpdir}/command_line_spec_output.txt", 'w') }
84
92
 
85
93
  it "doesn't override output_stream" do
86
94
  config.output_stream = output_file
87
- runner = build_runner
88
- runner.run err, out
89
- expect(runner.instance_eval { @configuration.output_stream }).to eq output_file
95
+ command_line = build_command_line
96
+ command_line.run err, nil
97
+ expect(command_line.instance_eval { @configuration.output_stream }).to eq output_file
90
98
  end
91
99
  end
92
100
 
93
- def build_runner *args
94
- Runner.new build_config_options(*args)
101
+ def build_command_line *args
102
+ CommandLine.new build_config_options(*args)
95
103
  end
96
104
 
97
105
  def build_config_options *args
@@ -100,28 +108,4 @@ module RSpec::Core
100
108
  options
101
109
  end
102
110
  end
103
-
104
- describe CommandLine do
105
- it 'is a subclass of `Runner` so that it inherits the same behavior' do
106
- expect(CommandLine.superclass).to be(Runner)
107
- end
108
-
109
- it 'prints a deprecation when instantiated' do
110
- expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /RSpec::Core::CommandLine/)
111
- CommandLine.new(ConfigurationOptions.new([]))
112
- end
113
-
114
- context "when given an array as the first arg" do
115
- it 'parses it into configuration options' do
116
- cl = CommandLine.new(%w[ --require foo ])
117
- options = cl.instance_eval { @options }
118
- expect(options.options).to include(:requires => ['foo'])
119
- end
120
-
121
- it 'issues a deprecation about the array arg' do
122
- expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /array/)
123
- CommandLine.new(%w[ --require foo ])
124
- end
125
- end
126
- end
127
111
  end
@@ -7,9 +7,8 @@ describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolat
7
7
 
8
8
  it "warns when HOME env var is not set", :unless => (RUBY_PLATFORM == 'java') do
9
9
  without_env_vars 'HOME' do
10
- coo = RSpec::Core::ConfigurationOptions.new([])
11
- coo.should_receive(:warn)
12
- coo.parse_options
10
+ expect_warning_with_call_site(__FILE__, __LINE__ + 1)
11
+ RSpec::Core::ConfigurationOptions.new([]).parse_options
13
12
  end
14
13
  end
15
14
 
@@ -75,7 +74,7 @@ describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolat
75
74
  expect(config.exclusion_filter).to have_key(:slow)
76
75
  end
77
76
 
78
- it "forces color" do
77
+ it "forces color_enabled" do
79
78
  opts = config_options_object(*%w[--color])
80
79
  config = RSpec::Core::Configuration.new
81
80
  config.should_receive(:force).with(:color => true)
@@ -92,7 +91,7 @@ describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolat
92
91
  ["--drb-port", "37", :drb_port, 37]
93
92
  ].each do |cli_option, cli_value, config_key, config_value|
94
93
  it "forces #{config_key}" do
95
- opts = config_options_object(*[cli_option, cli_value].compact)
94
+ opts = config_options_object(cli_option, cli_value)
96
95
  config = RSpec::Core::Configuration.new
97
96
  config.should_receive(:force) do |pair|
98
97
  expect(pair.keys.first).to eq(config_key)
@@ -102,13 +101,6 @@ describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolat
102
101
  end
103
102
  end
104
103
 
105
- it "sets debug directly" do
106
- opts = config_options_object("--debug")
107
- config = RSpec::Core::Configuration.new
108
- config.should_receive(:debug=).with(:cli)
109
- opts.configure(config)
110
- end
111
-
112
104
  it "merges --require specified by multiple configuration sources" do
113
105
  with_env_vars 'SPEC_OPTS' => "--require file_from_env" do
114
106
  opts = config_options_object(*%w[--require file_from_opts])
@@ -222,13 +214,6 @@ describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolat
222
214
  end
223
215
  end
224
216
 
225
- describe "--debug, -d" do
226
- it "sets :debug => true" do
227
- expect(parse_options("--debug")).to include(:debug => :cli)
228
- expect(parse_options("-d")).to include(:debug => :cli)
229
- end
230
- end
231
-
232
217
  describe "--fail-fast" do
233
218
  it "defaults to false" do
234
219
  expect(parse_options[:fail_fast]).to be_falsey
@@ -237,6 +222,10 @@ describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolat
237
222
  it "sets fail_fast on config" do
238
223
  expect(parse_options("--fail-fast")[:fail_fast]).to be_truthy
239
224
  end
225
+
226
+ it "sets fail_fast on config" do
227
+ expect(parse_options("--no-fail-fast")[:fail_fast]).to be_falsey
228
+ end
240
229
  end
241
230
 
242
231
  describe "--failure-exit-code" do
@@ -251,6 +240,16 @@ describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolat
251
240
  end
252
241
  end
253
242
 
243
+ describe "--dry-run" do
244
+ it "defaults to false" do
245
+ expect(parse_options[:dry_run]).to be_falsey
246
+ end
247
+
248
+ it "sets dry_run on config" do
249
+ expect(parse_options("--dry-run")[:dry_run]).to be_truthy
250
+ end
251
+ end
252
+
254
253
  describe "--options" do
255
254
  it "sets :custom_options_file" do
256
255
  expect(parse_options(*%w[-O my.opts])).to include(:custom_options_file => "my.opts")
@@ -259,38 +258,9 @@ describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolat
259
258
  end
260
259
 
261
260
  describe "--drb, -X" do
262
- context "combined with --debug" do
263
- it "turns off the debugger if --drb is specified first" do
264
- expect(config_options_object("--drb", "--debug").drb_argv).not_to include("--debug")
265
- expect(config_options_object("--drb", "-d" ).drb_argv).not_to include("--debug")
266
- expect(config_options_object("-X", "--debug").drb_argv).not_to include("--debug")
267
- expect(config_options_object("-X", "-d" ).drb_argv).not_to include("--debug")
268
- end
269
-
270
- it "turns off the debugger option if --drb is specified later" do
271
- expect(config_options_object("--debug", "--drb").drb_argv).not_to include("--debug")
272
- expect(config_options_object("-d", "--drb").drb_argv).not_to include("--debug")
273
- expect(config_options_object("--debug", "-X" ).drb_argv).not_to include("--debug")
274
- expect(config_options_object("-d", "-X" ).drb_argv).not_to include("--debug")
275
- end
276
-
277
- it "turns off the debugger option if --drb is specified in the options file" do
278
- File.open("./.rspec", "w") {|f| f << "--drb"}
279
- expect(config_options_object("--debug").drb_argv).not_to include("--debug")
280
- expect(config_options_object("-d" ).drb_argv).not_to include("--debug")
281
- end
282
-
283
- it "turns off the debugger option if --debug is specified in the options file" do
284
- File.open("./.rspec", "w") {|f| f << "--debug"}
285
- expect(config_options_object("--drb").drb_argv).not_to include("--debug")
286
- expect(config_options_object("-X" ).drb_argv).not_to include("--debug")
287
- end
288
- end
289
-
290
261
  it "does not send --drb back to the parser after parsing options" do
291
262
  expect(config_options_object("--drb", "--color").drb_argv).not_to include("--drb")
292
263
  end
293
-
294
264
  end
295
265
 
296
266
  describe "--no-drb" do
@@ -352,11 +322,10 @@ describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolat
352
322
  File.open("./.rspec", "w") {|f| f << "--line 37"}
353
323
  File.open("./.rspec-local", "w") {|f| f << "--format global"}
354
324
  File.open(File.expand_path("~/.rspec"), "w") {|f| f << "--color"}
355
- with_env_vars 'SPEC_OPTS' => "--debug --example 'foo bar'" do
325
+ with_env_vars 'SPEC_OPTS' => "--example 'foo bar'" do
356
326
  options = parse_options("--drb")
357
327
  expect(options[:color]).to be_truthy
358
328
  expect(options[:line_numbers]).to eq(["37"])
359
- expect(options[:debug]).to be_truthy
360
329
  expect(options[:full_description]).to eq([/foo\ bar/])
361
330
  expect(options[:drb]).to be_truthy
362
331
  expect(options[:formatters]).to eq([['global']])