rspec-core 3.5.2 → 3.6.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 (45) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/Changelog.md +89 -2
  4. data/lib/rspec/core/bisect/server.rb +6 -1
  5. data/lib/rspec/core/configuration.rb +110 -26
  6. data/lib/rspec/core/configuration_options.rb +2 -0
  7. data/lib/rspec/core/drb.rb +2 -0
  8. data/lib/rspec/core/example.rb +14 -10
  9. data/lib/rspec/core/example_group.rb +16 -6
  10. data/lib/rspec/core/formatters/base_text_formatter.rb +3 -5
  11. data/lib/rspec/core/formatters/console_codes.rb +7 -4
  12. data/lib/rspec/core/formatters/documentation_formatter.rb +2 -1
  13. data/lib/rspec/core/formatters/exception_presenter.rb +10 -4
  14. data/lib/rspec/core/formatters/html_formatter.rb +4 -2
  15. data/lib/rspec/core/formatters/html_snippet_extractor.rb +2 -0
  16. data/lib/rspec/core/formatters/json_formatter.rb +7 -2
  17. data/lib/rspec/core/formatters/progress_formatter.rb +1 -0
  18. data/lib/rspec/core/formatters/protocol.rb +26 -25
  19. data/lib/rspec/core/formatters/snippet_extractor.rb +1 -3
  20. data/lib/rspec/core/{source → formatters}/syntax_highlighter.rb +21 -1
  21. data/lib/rspec/core/formatters.rb +15 -5
  22. data/lib/rspec/core/hooks.rb +1 -8
  23. data/lib/rspec/core/invocations.rb +22 -4
  24. data/lib/rspec/core/memoized_helpers.rb +3 -0
  25. data/lib/rspec/core/metadata.rb +1 -0
  26. data/lib/rspec/core/metadata_filter.rb +29 -17
  27. data/lib/rspec/core/notifications.rb +20 -5
  28. data/lib/rspec/core/option_parser.rb +32 -12
  29. data/lib/rspec/core/output_wrapper.rb +29 -0
  30. data/lib/rspec/core/project_initializer/.rspec +0 -1
  31. data/lib/rspec/core/project_initializer/spec/spec_helper.rb +1 -4
  32. data/lib/rspec/core/reporter.rb +33 -9
  33. data/lib/rspec/core/runner.rb +10 -3
  34. data/lib/rspec/core/set.rb +5 -0
  35. data/lib/rspec/core/shared_example_group.rb +39 -15
  36. data/lib/rspec/core/version.rb +1 -1
  37. data/lib/rspec/core/world.rb +23 -5
  38. data/lib/rspec/core.rb +2 -1
  39. data.tar.gz.sig +3 -4
  40. metadata +8 -11
  41. metadata.gz.sig +0 -0
  42. data/lib/rspec/core/source/location.rb +0 -13
  43. data/lib/rspec/core/source/node.rb +0 -93
  44. data/lib/rspec/core/source/token.rb +0 -87
  45. data/lib/rspec/core/source.rb +0 -86
@@ -1,87 +0,0 @@
1
- RSpec::Support.require_rspec_core "source/location"
2
-
3
- module RSpec
4
- module Core
5
- class Source
6
- # @private
7
- # A wrapper for Ripper token which is generated with `Ripper.lex`.
8
- class Token
9
- CLOSING_TYPES_BY_OPENING_TYPE = {
10
- :on_lbracket => :on_rbracket,
11
- :on_lparen => :on_rparen,
12
- :on_lbrace => :on_rbrace,
13
- :on_heredoc_beg => :on_heredoc_end
14
- }.freeze
15
-
16
- CLOSING_KEYWORDS_BY_OPENING_KEYWORD = {
17
- 'def' => 'end',
18
- 'do' => 'end',
19
- }.freeze
20
-
21
- attr_reader :token
22
-
23
- def self.tokens_from_ripper_tokens(ripper_tokens)
24
- ripper_tokens.map { |ripper_token| new(ripper_token) }.freeze
25
- end
26
-
27
- def initialize(ripper_token)
28
- @token = ripper_token.freeze
29
- end
30
-
31
- def location
32
- @location ||= Location.new(*token[0])
33
- end
34
-
35
- def type
36
- token[1]
37
- end
38
-
39
- def string
40
- token[2]
41
- end
42
-
43
- def ==(other)
44
- token == other.token
45
- end
46
-
47
- alias_method :eql?, :==
48
-
49
- def inspect
50
- "#<#{self.class} #{type} #{string.inspect}>"
51
- end
52
-
53
- def keyword?
54
- type == :on_kw
55
- end
56
-
57
- def opening?
58
- opening_delimiter? || opening_keyword?
59
- end
60
-
61
- def closed_by?(other)
62
- closed_by_delimiter?(other) || closed_by_keyword?(other)
63
- end
64
-
65
- private
66
-
67
- def opening_delimiter?
68
- CLOSING_TYPES_BY_OPENING_TYPE.key?(type)
69
- end
70
-
71
- def opening_keyword?
72
- return false unless keyword?
73
- CLOSING_KEYWORDS_BY_OPENING_KEYWORD.key?(string)
74
- end
75
-
76
- def closed_by_delimiter?(other)
77
- other.type == CLOSING_TYPES_BY_OPENING_TYPE[type]
78
- end
79
-
80
- def closed_by_keyword?(other)
81
- return false unless other.keyword?
82
- other.string == CLOSING_KEYWORDS_BY_OPENING_KEYWORD[string]
83
- end
84
- end
85
- end
86
- end
87
- end
@@ -1,86 +0,0 @@
1
- RSpec::Support.require_rspec_support "encoded_string"
2
- RSpec::Support.require_rspec_core 'source/node'
3
- RSpec::Support.require_rspec_core 'source/syntax_highlighter'
4
- RSpec::Support.require_rspec_core 'source/token'
5
-
6
- module RSpec
7
- module Core
8
- # @private
9
- # Represents a Ruby source file and provides access to AST and tokens.
10
- class Source
11
- attr_reader :source, :path
12
-
13
- def self.from_file(path)
14
- source = File.read(path)
15
- new(source, path)
16
- end
17
-
18
- if String.method_defined?(:encoding)
19
- def initialize(source_string, path=nil)
20
- @source = RSpec::Support::EncodedString.new(source_string, Encoding.default_external)
21
- @path = path ? File.expand_path(path) : '(string)'
22
- end
23
- else # for 1.8.7
24
- # :nocov:
25
- def initialize(source_string, path=nil)
26
- @source = RSpec::Support::EncodedString.new(source_string)
27
- @path = path ? File.expand_path(path) : '(string)'
28
- end
29
- # :nocov:
30
- end
31
-
32
- def lines
33
- @lines ||= source.split("\n")
34
- end
35
-
36
- def ast
37
- @ast ||= begin
38
- require 'ripper'
39
- sexp = Ripper.sexp(source)
40
- raise SyntaxError unless sexp
41
- Node.new(sexp)
42
- end
43
- end
44
-
45
- def tokens
46
- @tokens ||= begin
47
- require 'ripper'
48
- tokens = Ripper.lex(source)
49
- Token.tokens_from_ripper_tokens(tokens)
50
- end
51
- end
52
-
53
- def nodes_by_line_number
54
- @nodes_by_line_number ||= begin
55
- nodes_by_line_number = ast.select(&:location).group_by { |node| node.location.line }
56
- Hash.new { |hash, key| hash[key] = [] }.merge(nodes_by_line_number)
57
- end
58
- end
59
-
60
- def tokens_by_line_number
61
- @tokens_by_line_number ||= begin
62
- nodes_by_line_number = tokens.group_by { |token| token.location.line }
63
- Hash.new { |hash, key| hash[key] = [] }.merge(nodes_by_line_number)
64
- end
65
- end
66
-
67
- def inspect
68
- "#<#{self.class} #{path}>"
69
- end
70
-
71
- # @private
72
- class Cache
73
- attr_reader :syntax_highlighter
74
-
75
- def initialize(configuration)
76
- @sources_by_path = {}
77
- @syntax_highlighter = SyntaxHighlighter.new(configuration)
78
- end
79
-
80
- def source_from_file(path)
81
- @sources_by_path[path] ||= Source.from_file(path)
82
- end
83
- end
84
- end
85
- end
86
- end