rspec-core 3.6.0.beta2 → 3.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/Changelog.md +48 -0
- data/lib/rspec/core.rb +1 -1
- data/lib/rspec/core/configuration.rb +34 -9
- data/lib/rspec/core/configuration_options.rb +2 -0
- data/lib/rspec/core/drb.rb +1 -1
- data/lib/rspec/core/example.rb +11 -7
- data/lib/rspec/core/example_group.rb +3 -2
- data/lib/rspec/core/formatters.rb +14 -4
- data/lib/rspec/core/formatters/base_formatter.rb +1 -1
- data/lib/rspec/core/formatters/base_text_formatter.rb +3 -4
- data/lib/rspec/core/formatters/deprecation_formatter.rb +6 -8
- data/lib/rspec/core/formatters/documentation_formatter.rb +1 -1
- data/lib/rspec/core/formatters/exception_presenter.rb +3 -2
- data/lib/rspec/core/formatters/html_printer.rb +3 -1
- data/lib/rspec/core/formatters/html_snippet_extractor.rb +4 -2
- data/lib/rspec/core/formatters/json_formatter.rb +9 -3
- data/lib/rspec/core/formatters/protocol.rb +3 -2
- data/lib/rspec/core/formatters/snippet_extractor.rb +1 -3
- data/lib/rspec/core/{source → formatters}/syntax_highlighter.rb +1 -1
- data/lib/rspec/core/hooks.rb +3 -1
- data/lib/rspec/core/memoized_helpers.rb +3 -0
- data/lib/rspec/core/metadata_filter.rb +17 -0
- data/lib/rspec/core/notifications.rb +20 -13
- data/lib/rspec/core/option_parser.rb +1 -1
- data/lib/rspec/core/output_wrapper.rb +29 -0
- data/lib/rspec/core/project_initializer/spec/spec_helper.rb +0 -3
- data/lib/rspec/core/reporter.rb +17 -8
- data/lib/rspec/core/set.rb +5 -0
- data/lib/rspec/core/shared_example_group.rb +0 -5
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +13 -5
- metadata +14 -17
- metadata.gz.sig +0 -0
- data/lib/rspec/core/source.rb +0 -86
- data/lib/rspec/core/source/location.rb +0 -13
- data/lib/rspec/core/source/node.rb +0 -93
- data/lib/rspec/core/source/token.rb +0 -87
metadata.gz.sig
CHANGED
Binary file
|
data/lib/rspec/core/source.rb
DELETED
@@ -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
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module RSpec
|
2
|
-
module Core
|
3
|
-
class Source
|
4
|
-
# @private
|
5
|
-
# Represents a source location of node or token.
|
6
|
-
Location = Struct.new(:line, :column) do
|
7
|
-
def self.location?(array)
|
8
|
-
array.is_a?(Array) && array.size == 2 && array.all? { |e| e.is_a?(Integer) }
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,93 +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 AST node which is generated with `Ripper.sexp`.
|
8
|
-
class Node
|
9
|
-
include Enumerable
|
10
|
-
|
11
|
-
attr_reader :sexp, :parent
|
12
|
-
|
13
|
-
def self.sexp?(array)
|
14
|
-
array.is_a?(Array) && array.first.is_a?(Symbol)
|
15
|
-
end
|
16
|
-
|
17
|
-
def initialize(ripper_sexp, parent=nil)
|
18
|
-
@sexp = ripper_sexp.freeze
|
19
|
-
@parent = parent
|
20
|
-
end
|
21
|
-
|
22
|
-
def type
|
23
|
-
sexp[0]
|
24
|
-
end
|
25
|
-
|
26
|
-
def args
|
27
|
-
@args ||= raw_args.map do |raw_arg|
|
28
|
-
if Node.sexp?(raw_arg)
|
29
|
-
Node.new(raw_arg, self)
|
30
|
-
elsif Location.location?(raw_arg)
|
31
|
-
Location.new(*raw_arg)
|
32
|
-
elsif raw_arg.is_a?(Array)
|
33
|
-
GroupNode.new(raw_arg, self)
|
34
|
-
else
|
35
|
-
raw_arg
|
36
|
-
end
|
37
|
-
end.freeze
|
38
|
-
end
|
39
|
-
|
40
|
-
def children
|
41
|
-
@children ||= args.select { |arg| arg.is_a?(Node) }.freeze
|
42
|
-
end
|
43
|
-
|
44
|
-
def location
|
45
|
-
@location ||= args.find { |arg| arg.is_a?(Location) }
|
46
|
-
end
|
47
|
-
|
48
|
-
def each(&block)
|
49
|
-
return to_enum(__method__) unless block_given?
|
50
|
-
|
51
|
-
yield self
|
52
|
-
|
53
|
-
children.each do |child|
|
54
|
-
child.each(&block)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def each_ancestor
|
59
|
-
return to_enum(__method__) unless block_given?
|
60
|
-
|
61
|
-
current_node = self
|
62
|
-
|
63
|
-
while (current_node = current_node.parent)
|
64
|
-
yield current_node
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def inspect
|
69
|
-
"#<#{self.class} #{type}>"
|
70
|
-
end
|
71
|
-
|
72
|
-
private
|
73
|
-
|
74
|
-
def raw_args
|
75
|
-
sexp[1..-1] || []
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# @private
|
80
|
-
class GroupNode < Node
|
81
|
-
def type
|
82
|
-
:group
|
83
|
-
end
|
84
|
-
|
85
|
-
private
|
86
|
-
|
87
|
-
def raw_args
|
88
|
-
sexp
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
@@ -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
|