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.
Files changed (216) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.sig +0 -0
  3. data/.yardopts +1 -0
  4. data/Changelog.md +339 -1
  5. data/License.txt +1 -0
  6. data/README.md +19 -37
  7. data/exe/rspec +2 -23
  8. data/lib/rspec/core/backport_random.rb +336 -0
  9. data/lib/rspec/core/backtrace_formatter.rb +70 -0
  10. data/lib/rspec/core/configuration.rb +479 -577
  11. data/lib/rspec/core/configuration_options.rb +71 -54
  12. data/lib/rspec/core/drb.rb +111 -0
  13. data/lib/rspec/core/dsl.rb +86 -18
  14. data/lib/rspec/core/example.rb +267 -119
  15. data/lib/rspec/core/example_group.rb +381 -393
  16. data/lib/rspec/core/filter_manager.rb +133 -114
  17. data/lib/rspec/core/flat_map.rb +18 -0
  18. data/lib/rspec/core/formatters/base_formatter.rb +51 -125
  19. data/lib/rspec/core/formatters/base_text_formatter.rb +34 -286
  20. data/lib/rspec/core/formatters/console_codes.rb +24 -1
  21. data/lib/rspec/core/formatters/deprecation_formatter.rb +25 -26
  22. data/lib/rspec/core/formatters/documentation_formatter.rb +27 -25
  23. data/lib/rspec/core/formatters/helpers.rb +14 -36
  24. data/lib/rspec/core/formatters/html_formatter.rb +58 -65
  25. data/lib/rspec/core/formatters/html_printer.rb +12 -18
  26. data/lib/rspec/core/formatters/json_formatter.rb +54 -31
  27. data/lib/rspec/core/formatters/profile_formatter.rb +67 -0
  28. data/lib/rspec/core/formatters/progress_formatter.rb +11 -15
  29. data/lib/rspec/core/formatters/snippet_extractor.rb +22 -11
  30. data/lib/rspec/core/formatters.rb +90 -43
  31. data/lib/rspec/core/hooks.rb +325 -270
  32. data/lib/rspec/core/memoized_helpers.rb +45 -156
  33. data/lib/rspec/core/metadata.rb +284 -236
  34. data/lib/rspec/core/metadata_filter.rb +86 -0
  35. data/lib/rspec/core/mocking_adapters/flexmock.rb +29 -0
  36. data/lib/rspec/core/{mocking/with_mocha.rb → mocking_adapters/mocha.rb} +19 -16
  37. data/lib/rspec/core/mocking_adapters/null.rb +12 -0
  38. data/lib/rspec/core/mocking_adapters/rr.rb +29 -0
  39. data/lib/rspec/core/mocking_adapters/rspec.rb +30 -0
  40. data/lib/rspec/core/notifications.rb +511 -0
  41. data/lib/rspec/core/option_parser.rb +49 -74
  42. data/lib/rspec/core/ordering.rb +156 -0
  43. data/lib/rspec/core/pending.rb +94 -96
  44. data/lib/rspec/core/project_initializer/.rspec +3 -0
  45. data/lib/rspec/core/project_initializer/spec/spec_helper.rb +78 -0
  46. data/lib/rspec/core/project_initializer.rb +24 -64
  47. data/lib/rspec/core/rake_task.rb +44 -130
  48. data/lib/rspec/core/reporter.rb +76 -59
  49. data/lib/rspec/core/ruby_project.rb +2 -1
  50. data/lib/rspec/core/runner.rb +117 -52
  51. data/lib/rspec/core/shared_context.rb +10 -10
  52. data/lib/rspec/core/shared_example_group.rb +108 -121
  53. data/lib/rspec/core/version.rb +3 -1
  54. data/lib/rspec/core/warnings.rb +40 -0
  55. data/lib/rspec/core/world.rb +66 -10
  56. data/lib/rspec/core.rb +64 -104
  57. data.tar.gz.sig +3 -0
  58. metadata +75 -322
  59. metadata.gz.sig +1 -0
  60. data/exe/autospec +0 -13
  61. data/features/Autotest.md +0 -38
  62. data/features/README.md +0 -17
  63. data/features/Upgrade.md +0 -364
  64. data/features/command_line/README.md +0 -28
  65. data/features/command_line/example_name_option.feature +0 -97
  66. data/features/command_line/exit_status.feature +0 -82
  67. data/features/command_line/format_option.feature +0 -75
  68. data/features/command_line/init.feature +0 -18
  69. data/features/command_line/line_number_appended_to_path.feature +0 -140
  70. data/features/command_line/line_number_option.feature +0 -53
  71. data/features/command_line/order.feature +0 -26
  72. data/features/command_line/pattern_option.feature +0 -49
  73. data/features/command_line/rake_task.feature +0 -122
  74. data/features/command_line/require_option.feature +0 -43
  75. data/features/command_line/ruby.feature +0 -22
  76. data/features/command_line/tag.feature +0 -98
  77. data/features/command_line/warnings_option.feature +0 -29
  78. data/features/configuration/alias_example_to.feature +0 -48
  79. data/features/configuration/backtrace_clean_patterns.feature +0 -102
  80. data/features/configuration/custom_settings.feature +0 -84
  81. data/features/configuration/default_path.feature +0 -38
  82. data/features/configuration/deprecation_stream.feature +0 -58
  83. data/features/configuration/fail_fast.feature +0 -77
  84. data/features/configuration/failure_exit_code.feature +0 -36
  85. data/features/configuration/order_and_seed.feature +0 -3
  86. data/features/configuration/output_stream.feature +0 -24
  87. data/features/configuration/pattern.feature +0 -38
  88. data/features/configuration/profile.feature +0 -220
  89. data/features/configuration/read_options_from_file.feature +0 -90
  90. data/features/configuration/run_all_when_everything_filtered.feature +0 -76
  91. data/features/configuration/show_failures_in_pending_blocks.feature +0 -61
  92. data/features/configuration/treat_symbols_as_metadata_keys_with_true_values.feature +0 -52
  93. data/features/example_groups/basic_structure.feature +0 -55
  94. data/features/example_groups/shared_context.feature +0 -74
  95. data/features/example_groups/shared_examples.feature +0 -294
  96. data/features/expectation_framework_integration/configure_expectation_framework.feature +0 -197
  97. data/features/filtering/exclusion_filters.feature +0 -138
  98. data/features/filtering/if_and_unless.feature +0 -168
  99. data/features/filtering/inclusion_filters.feature +0 -105
  100. data/features/formatters/configurable_colors.feature +0 -31
  101. data/features/formatters/custom_formatter.feature +0 -36
  102. data/features/formatters/json_formatter.feature +0 -30
  103. data/features/formatters/text_formatter.feature +0 -46
  104. data/features/helper_methods/arbitrary_methods.feature +0 -40
  105. data/features/helper_methods/let.feature +0 -50
  106. data/features/helper_methods/modules.feature +0 -149
  107. data/features/hooks/around_hooks.feature +0 -343
  108. data/features/hooks/before_and_after_hooks.feature +0 -427
  109. data/features/hooks/filtering.feature +0 -234
  110. data/features/metadata/current_example.feature +0 -56
  111. data/features/metadata/described_class.feature +0 -17
  112. data/features/metadata/user_defined.feature +0 -113
  113. data/features/mock_framework_integration/use_any_framework.feature +0 -106
  114. data/features/mock_framework_integration/use_flexmock.feature +0 -96
  115. data/features/mock_framework_integration/use_mocha.feature +0 -97
  116. data/features/mock_framework_integration/use_rr.feature +0 -98
  117. data/features/mock_framework_integration/use_rspec.feature +0 -97
  118. data/features/pending/pending_examples.feature +0 -229
  119. data/features/spec_files/arbitrary_file_suffix.feature +0 -13
  120. data/features/step_definitions/additional_cli_steps.rb +0 -49
  121. data/features/subject/attribute_of_subject.feature +0 -124
  122. data/features/subject/explicit_subject.feature +0 -101
  123. data/features/subject/implicit_subject.feature +0 -63
  124. data/features/subject/one_liner_syntax.feature +0 -71
  125. data/features/support/env.rb +0 -14
  126. data/features/support/rubinius.rb +0 -6
  127. data/lib/autotest/discover.rb +0 -10
  128. data/lib/autotest/rspec2.rb +0 -77
  129. data/lib/rspec/core/backtrace_cleaner.rb +0 -46
  130. data/lib/rspec/core/backward_compatibility.rb +0 -55
  131. data/lib/rspec/core/caller_filter.rb +0 -60
  132. data/lib/rspec/core/command_line.rb +0 -47
  133. data/lib/rspec/core/deprecated_mutable_array_proxy.rb +0 -32
  134. data/lib/rspec/core/deprecation.rb +0 -26
  135. data/lib/rspec/core/drb_command_line.rb +0 -26
  136. data/lib/rspec/core/drb_options.rb +0 -87
  137. data/lib/rspec/core/extensions/instance_eval_with_args.rb +0 -44
  138. data/lib/rspec/core/extensions/kernel.rb +0 -9
  139. data/lib/rspec/core/extensions/module_eval_with_args.rb +0 -38
  140. data/lib/rspec/core/extensions/ordered.rb +0 -27
  141. data/lib/rspec/core/formatters/text_mate_formatter.rb +0 -34
  142. data/lib/rspec/core/metadata_hash_builder.rb +0 -97
  143. data/lib/rspec/core/mocking/with_absolutely_nothing.rb +0 -11
  144. data/lib/rspec/core/mocking/with_flexmock.rb +0 -27
  145. data/lib/rspec/core/mocking/with_rr.rb +0 -27
  146. data/lib/rspec/core/mocking/with_rspec.rb +0 -27
  147. data/lib/rspec/core/shared_example_group/collection.rb +0 -45
  148. data/spec/autotest/discover_spec.rb +0 -49
  149. data/spec/autotest/failed_results_re_spec.rb +0 -45
  150. data/spec/autotest/rspec_spec.rb +0 -133
  151. data/spec/command_line/order_spec.rb +0 -204
  152. data/spec/rspec/core/backtrace_cleaner_spec.rb +0 -68
  153. data/spec/rspec/core/caller_filter_spec.rb +0 -58
  154. data/spec/rspec/core/command_line_spec.rb +0 -127
  155. data/spec/rspec/core/command_line_spec_output.txt +0 -0
  156. data/spec/rspec/core/configuration_options_spec.rb +0 -417
  157. data/spec/rspec/core/configuration_spec.rb +0 -2072
  158. data/spec/rspec/core/deprecation_spec.rb +0 -27
  159. data/spec/rspec/core/deprecations_spec.rb +0 -59
  160. data/spec/rspec/core/drb_command_line_spec.rb +0 -102
  161. data/spec/rspec/core/drb_options_spec.rb +0 -193
  162. data/spec/rspec/core/dsl_spec.rb +0 -25
  163. data/spec/rspec/core/example_group_spec.rb +0 -1337
  164. data/spec/rspec/core/example_spec.rb +0 -502
  165. data/spec/rspec/core/filter_manager_spec.rb +0 -246
  166. data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -108
  167. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +0 -524
  168. data/spec/rspec/core/formatters/console_codes_spec.rb +0 -50
  169. data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +0 -263
  170. data/spec/rspec/core/formatters/documentation_formatter_spec.rb +0 -89
  171. data/spec/rspec/core/formatters/helpers_spec.rb +0 -104
  172. data/spec/rspec/core/formatters/html_formatted.html +0 -397
  173. data/spec/rspec/core/formatters/html_formatter_spec.rb +0 -131
  174. data/spec/rspec/core/formatters/json_formatter_spec.rb +0 -115
  175. data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -30
  176. data/spec/rspec/core/formatters/snippet_extractor_spec.rb +0 -26
  177. data/spec/rspec/core/formatters/text_mate_formatted.html +0 -397
  178. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +0 -107
  179. data/spec/rspec/core/hooks_filtering_spec.rb +0 -227
  180. data/spec/rspec/core/hooks_spec.rb +0 -269
  181. data/spec/rspec/core/kernel_extensions_spec.rb +0 -9
  182. data/spec/rspec/core/memoized_helpers_spec.rb +0 -776
  183. data/spec/rspec/core/metadata_spec.rb +0 -514
  184. data/spec/rspec/core/option_parser_spec.rb +0 -297
  185. data/spec/rspec/core/pending_example_spec.rb +0 -260
  186. data/spec/rspec/core/pending_spec.rb +0 -27
  187. data/spec/rspec/core/project_initializer_spec.rb +0 -130
  188. data/spec/rspec/core/rake_task_spec.rb +0 -202
  189. data/spec/rspec/core/reporter_spec.rb +0 -167
  190. data/spec/rspec/core/resources/a_bar.rb +0 -0
  191. data/spec/rspec/core/resources/a_foo.rb +0 -0
  192. data/spec/rspec/core/resources/a_spec.rb +0 -1
  193. data/spec/rspec/core/resources/custom_example_group_runner.rb +0 -14
  194. data/spec/rspec/core/resources/formatter_specs.rb +0 -60
  195. data/spec/rspec/core/resources/utf8_encoded.rb +0 -8
  196. data/spec/rspec/core/rspec_matchers_spec.rb +0 -45
  197. data/spec/rspec/core/ruby_project_spec.rb +0 -26
  198. data/spec/rspec/core/runner_spec.rb +0 -82
  199. data/spec/rspec/core/shared_context_spec.rb +0 -114
  200. data/spec/rspec/core/shared_example_group/collection_spec.rb +0 -70
  201. data/spec/rspec/core/shared_example_group_spec.rb +0 -138
  202. data/spec/rspec/core/world_spec.rb +0 -142
  203. data/spec/rspec/core_spec.rb +0 -108
  204. data/spec/spec_helper.rb +0 -135
  205. data/spec/support/config_options_helper.rb +0 -15
  206. data/spec/support/helper_methods.rb +0 -55
  207. data/spec/support/in_sub_process.rb +0 -37
  208. data/spec/support/isolate_load_path_mutation.rb +0 -6
  209. data/spec/support/isolated_directory.rb +0 -10
  210. data/spec/support/isolated_home_directory.rb +0 -16
  211. data/spec/support/matchers.rb +0 -65
  212. data/spec/support/mathn_integration_support.rb +0 -12
  213. data/spec/support/sandboxed_mock_space.rb +0 -116
  214. data/spec/support/shared_example_groups.rb +0 -42
  215. data/spec/support/silence_dsl_deprecations.rb +0 -32
  216. data/spec/support/spec_files.rb +0 -44
@@ -1,77 +0,0 @@
1
- begin
2
- require 'rspec/autotest'
3
- rescue LoadError
4
- require 'autotest'
5
-
6
- # Derived from the `Autotest` class, extends the `autotest` command to work
7
- # with RSpec.
8
- #
9
- # @note this will be extracted to a separate gem when we release rspec-3.
10
- class Autotest::Rspec2 < Autotest
11
-
12
- RSPEC_EXECUTABLE = File.expand_path('../../../exe/rspec', __FILE__)
13
-
14
- def initialize
15
- super()
16
- clear_mappings
17
- setup_rspec_project_mappings
18
-
19
- # Example for Ruby 1.8: http://rubular.com/r/AOXNVDrZpx
20
- # Example for Ruby 1.9: http://rubular.com/r/85ag5AZ2jP
21
- self.failed_results_re = /^\s*\d+\).*\n\s+(?:\e\[\d*m)?Failure.*(\n(?:\e\[\d*m)?\s+#\s(.*)?:\d+(?::.*)?(?:\e\[\d*m)?)+$/m
22
- self.completed_re = /\n(?:\e\[\d*m)?\d* examples?/m
23
- end
24
-
25
- # Adds conventional spec-to-file mappings to Autotest configuation.
26
- def setup_rspec_project_mappings
27
- add_mapping(%r%^spec/.*_spec\.rb$%) { |filename, _|
28
- filename
29
- }
30
- add_mapping(%r%^lib/(.*)\.rb$%) { |_, m|
31
- ["spec/#{m[1]}_spec.rb"]
32
- }
33
- add_mapping(%r%^spec/(spec_helper|shared/.*)\.rb$%) {
34
- files_matching %r%^spec/.*_spec\.rb$%
35
- }
36
- end
37
-
38
- # Overrides Autotest's implementation to read rspec output
39
- def consolidate_failures(failed)
40
- filters = new_hash_of_arrays
41
- failed.each do |spec, trace|
42
- if trace =~ /(.*spec\.rb)/
43
- filters[$1] << spec
44
- end
45
- end
46
- return filters
47
- end
48
-
49
- # Overrides Autotest's implementation to generate the rspec command to run
50
- def make_test_cmd(files_to_test)
51
- files_to_test.empty? ? '' :
52
- %|#{prefix}"#{ruby}"#{suffix} -S "#{RSPEC_EXECUTABLE}" --tty #{normalize(files_to_test).keys.flatten.map { |f| %|"#{f}"|}.join(' ')}|
53
- end
54
-
55
- # Generates a map of filenames to Arrays for Autotest
56
- def normalize(files_to_test)
57
- files_to_test.keys.inject({}) do |result, filename|
58
- result.merge!(File.expand_path(filename) => [])
59
- end
60
- end
61
-
62
- private
63
-
64
- def suffix
65
- using_bundler? ? "" : defined?(:Gem) ? " -rrubygems" : ""
66
- end
67
-
68
- def using_bundler?
69
- prefix =~ /bundle exec/
70
- end
71
-
72
- def gemfile?
73
- File.exist?('./Gemfile')
74
- end
75
- end
76
- Autotest.add_hook(:ran_command) { warn "\n\e[31mrspec-core's built in autotest support is deprecated and will be removed in RSpec 3. Please switch to the rspec-autotest gem.\e[0m" }
77
- end
@@ -1,46 +0,0 @@
1
- module RSpec
2
- module Core
3
- class BacktraceCleaner
4
-
5
- DEFAULT_EXCLUSION_PATTERNS = [
6
- /\/lib\d*\/ruby\//,
7
- /org\/jruby\//,
8
- /bin\//,
9
- %r|/gems/|,
10
- /spec\/spec_helper\.rb/,
11
- /lib\/rspec\/(core|expectations|matchers|mocks)/
12
- ]
13
-
14
- attr_accessor :inclusion_patterns
15
- attr_accessor :exclusion_patterns
16
-
17
- def initialize(inclusion_patterns=nil, exclusion_patterns=DEFAULT_EXCLUSION_PATTERNS.dup)
18
- @exclusion_patterns = exclusion_patterns
19
-
20
- if inclusion_patterns.nil?
21
- @inclusion_patterns = (matches_an_exclusion_pattern? Dir.getwd) ? [Regexp.new(Dir.getwd)] : []
22
- else
23
- @inclusion_patterns = inclusion_patterns
24
- end
25
- end
26
-
27
- def exclude?(line)
28
- @inclusion_patterns.none? {|p| line =~ p} and matches_an_exclusion_pattern?(line)
29
- end
30
-
31
- def full_backtrace=(true_or_false)
32
- @exclusion_patterns = true_or_false ? [] : DEFAULT_EXCLUSION_PATTERNS.dup
33
- end
34
-
35
- def full_backtrace?
36
- @exclusion_patterns.empty?
37
- end
38
-
39
- private
40
-
41
- def matches_an_exclusion_pattern?(line)
42
- @exclusion_patterns.any? {|p| line =~ p}
43
- end
44
- end
45
- end
46
- end
@@ -1,55 +0,0 @@
1
- module RSpec
2
- module Core
3
- # @private
4
- module ConstMissing
5
- # Used to print deprecation warnings for Rspec and Spec constants (use
6
- # RSpec instead)
7
- def const_missing(name)
8
- case name
9
- when :Rspec, :Spec
10
- RSpec.deprecate(name.to_s, :replacement => "RSpec")
11
- RSpec
12
- else
13
- begin
14
- super
15
- rescue Exception => e
16
- e.backtrace.reject! {|l| l =~ Regexp.compile(__FILE__) }
17
- raise e
18
- end
19
- end
20
- end
21
- end
22
- end
23
-
24
- module Runner
25
- # @deprecated use RSpec.configure instead.
26
- def self.configure(&block)
27
- RSpec.deprecate("Spec::Runner.configure", :replacement => "RSpec.configure")
28
- RSpec.configure(&block)
29
- end
30
- end
31
-
32
- # @private
33
- module Rake
34
- # Used to print deprecation warnings for Rake::SpecTask constant (use
35
- # RSpec::Core::RakeTask instead)
36
- def self.const_missing(name)
37
- case name
38
- when :SpecTask
39
- RSpec.deprecate("Spec::Rake::SpecTask", :replacement => "RSpec::Core::RakeTask")
40
- require 'rspec/core/rake_task'
41
- RSpec::Core::RakeTask
42
- else
43
- begin
44
- super
45
- rescue Exception => e
46
- e.backtrace.reject! {|l| l =~ Regexp.compile(__FILE__) }
47
- raise e
48
- end
49
- end
50
- end
51
-
52
- end
53
- end
54
-
55
- Object.extend(RSpec::Core::ConstMissing)
@@ -1,60 +0,0 @@
1
- module RSpec
2
- # Consistent implementation for "cleaning" the caller method to strip out
3
- # non-rspec lines. This enables errors to be reported at the call site in
4
- # the code using the library, which is far more useful than the particular
5
- # internal method that raised an error.
6
-
7
- unless defined?(CallerFilter)
8
-
9
- class CallerFilter
10
-
11
- RSPEC_LIBS = %w[
12
- core
13
- mocks
14
- expectations
15
- matchers
16
- rails
17
- ]
18
-
19
- ADDITIONAL_TOP_LEVEL_FILES = %w[ autorun ]
20
-
21
- LIB_REGEX = %r{/lib/rspec/(#{(RSPEC_LIBS + ADDITIONAL_TOP_LEVEL_FILES).join('|')})(\.rb|/)}
22
-
23
- if RUBY_VERSION >= '2.0.0'
24
- def self.first_non_rspec_line
25
- # `caller` is an expensive method that scales linearly with the size of
26
- # the stack. The performance hit for fetching it in chunks is small,
27
- # and since the target line is probably near the top of the stack, the
28
- # overall improvement of a chunked search like this is significant.
29
- #
30
- # See benchmarks/caller.rb for measurements.
31
-
32
- # Initial value here is mostly arbitrary, but is chosen to give good
33
- # performance on the common case of creating a double.
34
- increment = 5
35
- i = 1
36
- line = nil
37
-
38
- while !line
39
- stack = caller(i, increment)
40
- return nil unless stack
41
-
42
- line = stack.find { |l| l !~ LIB_REGEX }
43
-
44
- i += increment
45
- increment *= 2 # The choice of two here is arbitrary.
46
- end
47
-
48
- line
49
- end
50
- else
51
- # Earlier rubies do not support the two argument form of `caller`. This
52
- # fallback is logically the same, but slower.
53
- def self.first_non_rspec_line
54
- caller.find { |line| line !~ LIB_REGEX }
55
- end
56
- end
57
- end
58
-
59
- end
60
- end
@@ -1,47 +0,0 @@
1
- module RSpec
2
- module Core
3
- class Runner
4
- def initialize(options, configuration=RSpec::configuration, world=RSpec::world)
5
- @options = options
6
- @configuration = configuration
7
- @world = world
8
- end
9
-
10
- # Configures and runs a suite
11
- #
12
- # @param [IO] err
13
- # @param [IO] out
14
- def run(err, out)
15
- @configuration.error_stream = err
16
- @configuration.output_stream = out if @configuration.output_stream == $stdout
17
- @options.configure(@configuration)
18
- @configuration.load_spec_files
19
- @world.announce_filters
20
-
21
- @configuration.reporter.report(@world.example_count, @configuration.send(:_randomize?) ? @configuration.seed : nil) do |reporter|
22
- begin
23
- @configuration.run_hook(:before, :suite)
24
- @world.example_groups.ordered.map {|g| g.run(reporter)}.all? ? 0 : @configuration.failure_exit_code
25
- ensure
26
- @configuration.run_hook(:after, :suite)
27
- end
28
- end
29
- end
30
- end
31
-
32
- class CommandLine < Runner
33
- def initialize(options, configuration=RSpec.configuration, world=RSpec.world)
34
- if Array === options
35
- RSpec.deprecate("Instantiating a `RSpec::Core::CommandLine` with an array of options",
36
- :replacement => "Instantiate a `RSpec::Core::Runner` with a `RSpec::Core::ConfigurationOptions` instance")
37
- options = ConfigurationOptions.new(options)
38
- options.parse_options
39
- else
40
- RSpec.deprecate("`RSpec::Core::CommandLine`", :replacement => "`RSpec::Core::Runner`")
41
- end
42
-
43
- super
44
- end
45
- end
46
- end
47
- end
@@ -1,32 +0,0 @@
1
- module RSpec
2
- module Core
3
- class DeprecatedMutableArrayProxy
4
-
5
- def initialize(array)
6
- @array = array
7
- end
8
-
9
- mutated_methods =
10
- [
11
- :<<, :[]=, :clear, :collect!, :compact!, :concat, :delete,
12
- :delete_at, :delete_if, :fill, :flatten!, :keep_if, :map!,
13
- :pop, :push, :reject!, :replace, :reverse!, :rotate!,
14
- :select!, :shift, :shuffle!, :slice!, :sort!, :sort_by!,
15
- :uniq!, :unshift
16
- ]
17
- array_methods = Array.instance_methods.map(&:to_sym)
18
-
19
- (array_methods & mutated_methods).each do |name|
20
- define_method(name) do |*args, &block|
21
- RSpec.deprecate "Mutating the `RSpec.configuration.formatters` array"
22
- @array.__send__ name, *args, &block
23
- end
24
- end
25
-
26
- (array_methods - mutated_methods).each do |name|
27
- define_method(name) { |*args, &block| @array.__send__ name, *args, &block }
28
- end
29
-
30
- end
31
- end
32
- end
@@ -1,26 +0,0 @@
1
- module RSpec
2
- module Core
3
- module Deprecation
4
- # @private
5
- #
6
- # Used internally to print deprecation warnings
7
- def deprecate(deprecated, data = {})
8
- RSpec.configuration.reporter.deprecation(
9
- {
10
- :deprecated => deprecated,
11
- :call_site => CallerFilter.first_non_rspec_line
12
- }.merge(data)
13
- )
14
- end
15
-
16
- # @private
17
- #
18
- # Used internally to print deprecation warnings
19
- def warn_deprecation(message)
20
- RSpec.configuration.reporter.deprecation :message => message
21
- end
22
- end
23
- end
24
-
25
- extend(Core::Deprecation)
26
- end
@@ -1,26 +0,0 @@
1
- require 'drb/drb'
2
- require 'rspec/core/drb_options'
3
-
4
- module RSpec
5
- module Core
6
- class DRbCommandLine
7
- def initialize(options)
8
- @options = options
9
- end
10
-
11
- def drb_port
12
- @options.options[:drb_port] || ENV['RSPEC_DRB'] || 8989
13
- end
14
-
15
- def run(err, out)
16
- begin
17
- DRb.start_service("druby://localhost:0")
18
- rescue SocketError, Errno::EADDRNOTAVAIL
19
- DRb.start_service("druby://:0")
20
- end
21
- spec_server = DRbObject.new_with_uri("druby://127.0.0.1:#{drb_port}")
22
- spec_server.run(@options.drb_argv, err, out)
23
- end
24
- end
25
- end
26
- end
@@ -1,87 +0,0 @@
1
- # Builds command line arguments to pass to the rspec command over DRb
2
-
3
- module RSpec::Core
4
- # @private
5
- class DrbOptions
6
- def initialize(submitted_options, filter_manager)
7
- @submitted_options = submitted_options
8
- @filter_manager = filter_manager
9
- end
10
-
11
- def options
12
- argv = []
13
- argv << "--color" if @submitted_options[:color]
14
- argv << "--profile" if @submitted_options[:profile_examples]
15
- argv << "--backtrace" if @submitted_options[:full_backtrace]
16
- argv << "--tty" if @submitted_options[:tty]
17
- argv << "--fail-fast" if @submitted_options[:fail_fast]
18
- argv << "--options" << @submitted_options[:custom_options_file] if @submitted_options[:custom_options_file]
19
- argv << "--order" << @submitted_options[:order] if @submitted_options[:order]
20
-
21
- add_failure_exit_code(argv)
22
- add_full_description(argv)
23
- add_line_numbers(argv)
24
- add_filter(argv, :inclusion, @filter_manager.inclusions)
25
- add_filter(argv, :exclusion, @filter_manager.exclusions)
26
- add_formatters(argv)
27
- add_libs(argv)
28
- add_requires(argv)
29
-
30
- argv + @submitted_options[:files_or_directories_to_run]
31
- end
32
-
33
- def add_failure_exit_code(argv)
34
- if @submitted_options[:failure_exit_code]
35
- argv << "--failure-exit-code" << @submitted_options[:failure_exit_code].to_s
36
- end
37
- end
38
-
39
- def add_full_description(argv)
40
- if @submitted_options[:full_description]
41
- # The argument to --example is regexp-escaped before being stuffed
42
- # into a regexp when received for the first time (see OptionParser).
43
- # Hence, merely grabbing the source of this regexp will retain the
44
- # backslashes, so we must remove them.
45
- @submitted_options[:full_description].each do |description|
46
- argv << "--example" << description.source.delete('\\')
47
- end
48
- end
49
- end
50
-
51
- def add_line_numbers(argv)
52
- if @submitted_options[:line_numbers]
53
- argv.push(*@submitted_options[:line_numbers].inject([]){|a,l| a << "--line_number" << l})
54
- end
55
- end
56
-
57
- CONDITIONAL_FILTERS = [:if, :unless]
58
-
59
- def add_filter(argv, name, hash)
60
- hash.each_pair do |k, v|
61
- next if CONDITIONAL_FILTERS.include?(k)
62
- tag = name == :inclusion ? k.to_s : "~#{k}"
63
- tag << ":#{v}" if v.is_a?(String)
64
- argv << "--tag" << tag
65
- end unless hash.empty?
66
- end
67
-
68
- def add_formatters(argv)
69
- @submitted_options[:formatters].each do |pair|
70
- argv << "--format" << pair[0]
71
- argv << "--out" << pair[1] if pair[1]
72
- end if @submitted_options[:formatters]
73
- end
74
-
75
- def add_libs(argv)
76
- @submitted_options[:libs].each do |path|
77
- argv << "-I" << path
78
- end if @submitted_options[:libs]
79
- end
80
-
81
- def add_requires(argv)
82
- @submitted_options[:requires].each do |path|
83
- argv << "--require" << path
84
- end if @submitted_options[:requires]
85
- end
86
- end
87
- end
@@ -1,44 +0,0 @@
1
- module RSpec
2
- module Core
3
- module Extensions
4
- # @private
5
- module InstanceEvalWithArgs
6
- # @private
7
- #
8
- # Used internally to support `instance_exec` in Ruby 1.8.6.
9
- #
10
- # based on Bounded Spec InstanceExec (Mauricio Fernandez)
11
- # http://eigenclass.org/hiki/bounded+space+instance_exec
12
- # - uses singleton_class instead of global InstanceExecHelper module
13
- # - this keeps it scoped to classes/modules that include this module
14
- # - only necessary for ruby 1.8.6
15
- def instance_eval_with_args(*args, &block)
16
- return instance_exec(*args, &block) if respond_to?(:instance_exec)
17
-
18
- # If there are no args and the block doesn't expect any, there's no
19
- # need to fake instance_exec with our hack below.
20
- # Notes:
21
- # * lambda { }.arity # => -1
22
- # * lambda { || }.arity # => 0
23
- # * lambda { |*a| }.arity # -1
24
- return instance_eval(&block) if block.arity < 1 && args.size.zero?
25
-
26
- singleton_class = (class << self; self; end)
27
- begin
28
- orig_critical, Thread.critical = Thread.critical, true
29
- n = 0
30
- n += 1 while respond_to?(method_name="__instance_exec#{n}")
31
- singleton_class.module_eval{ define_method(method_name, &block) }
32
- ensure
33
- Thread.critical = orig_critical
34
- end
35
- begin
36
- return send(method_name, *args)
37
- ensure
38
- singleton_class.module_eval{ remove_method(method_name) } rescue nil
39
- end
40
- end
41
- end
42
- end
43
- end
44
- end
@@ -1,9 +0,0 @@
1
- module Kernel
2
- unless defined?(debugger)
3
- # If not already defined by ruby-debug, this implementation prints helpful
4
- # message to STDERR when ruby-debug is not loaded.
5
- def debugger(*args)
6
- (RSpec.configuration.error_stream || $stderr).puts "\n***** debugger statement ignored, use -d or --debug option to enable debugging\n#{caller(0)[1]}"
7
- end
8
- end
9
- end
@@ -1,38 +0,0 @@
1
- module RSpec
2
- module Core
3
- module Extensions
4
- # @private
5
- module ModuleEvalWithArgs
6
- include InstanceEvalWithArgs
7
-
8
- # @private
9
- #
10
- # Used internally to support `module_exec` in Ruby 1.8.6.
11
- def module_eval_with_args(*args, &block)
12
- # ruby > 1.8.6
13
- return module_exec(*args, &block) if respond_to?(:module_exec)
14
-
15
- # If there are no args and the block doesn't expect any, there's no
16
- # need to fake module_exec with our hack below.
17
- # Notes:
18
- # * lambda { }.arity # => -1
19
- # * lambda { || }.arity # => 0
20
- # * lambda { |*a| }.arity # => -1
21
- return module_eval(&block) if block.arity < 1 && args.size.zero?
22
-
23
- orig_singleton_methods = singleton_methods
24
- instance_eval_with_args(*args, &block)
25
-
26
- # The only difference between instance_eval and module_eval is static method defs.
27
- # * `def foo` in instance_eval defines a singleton method on the instance
28
- # * `def foo` in class/module_eval defines an instance method for the class/module
29
- # Here we deal with this difference by defining an instance method for
30
- # each new singleton method.
31
- # This has the side effect of duplicating methods (all new class methods will
32
- # become instance methods and vice versa), but I don't see a way around it...
33
- (singleton_methods - orig_singleton_methods).each { |m| define_method(m, &method(m)) }
34
- end
35
- end
36
- end
37
- end
38
- end
@@ -1,27 +0,0 @@
1
- module RSpec
2
- module Core
3
- # @private
4
- module Extensions
5
- # @private
6
- # Used to extend lists of examples and groups to support ordering
7
- # strategies like randomization.
8
- module Ordered
9
- # @private
10
- module ExampleGroups
11
- # @private
12
- def ordered
13
- RSpec.configuration.group_ordering_block.call(self)
14
- end
15
- end
16
-
17
- # @private
18
- module Examples
19
- # @private
20
- def ordered
21
- RSpec.configuration.example_ordering_block.call(self)
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,34 +0,0 @@
1
- require 'cgi'
2
- require 'rspec/core/formatters/html_formatter'
3
-
4
- module RSpec
5
- module Core
6
- module Formatters
7
- # Formats backtraces so they're clickable by TextMate
8
- class TextMateFormatter < HtmlFormatter
9
- def backtrace_line(line, skip_textmate_conversion=false)
10
- if skip_textmate_conversion
11
- super(line)
12
- else
13
- format_backtrace_line_for_textmate(super(line))
14
- end
15
- end
16
-
17
- def format_backtrace_line_for_textmate(line)
18
- return nil unless line
19
- CGI.escapeHTML(line).sub(/([^:]*\.e?rb):(\d*)/) do
20
- "<a href=\"txmt://open?url=file://#{File.expand_path($1)}&amp;line=#{$2}\">#{$1}:#{$2}</a> "
21
- end
22
- end
23
-
24
- def extra_failure_content(exception)
25
- require 'rspec/core/formatters/snippet_extractor'
26
- backtrace = exception.backtrace.map {|line| backtrace_line(line, :skip_textmate_conversion)}
27
- backtrace.compact!
28
- @snippet_extractor ||= SnippetExtractor.new
29
- " <pre class=\"ruby\"><code>#{@snippet_extractor.snippet(backtrace)}</code></pre>"
30
- end
31
- end
32
- end
33
- end
34
- end