rspec-core 3.4.2 → 3.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e63ddb3b6ca4d7f6e9ff8840a31920d58c8381f
4
- data.tar.gz: 7be258c6e7b6bcab6570fc1a117511fe0c8070b2
3
+ metadata.gz: 203d6dff4306be78d671362a48e847eb74c1b115
4
+ data.tar.gz: 4faa8c73ef35b7a593162c6e338090b697799243
5
5
  SHA512:
6
- metadata.gz: 8c4c1ec05fdcc0a7693346e32d320d8031be2e270f8d5cfd369d791e2a733ab39a6e6f867354c70d4b8bbf8bc722a841174101a309b46083892f1ef24c8432d6
7
- data.tar.gz: 36af8dd8c5c4ffb1034f289dc6107e1e7c552cd6c74ca52c226a96e3279b8a00c3d2edc834b7d74bf1f5f311435f540d8d7c69389a00a3249efc1876a80b641b
6
+ metadata.gz: 2ed7871a3cdfd07530698efd71d9a96c85b1eef26a8253485a58071adf92a1165c9583d9c9c668a24b66d6f74a9be63b394e16174796324f4b03f7d6537a4a8d
7
+ data.tar.gz: 2219a50dc96580d34005d7c40a50025f0dc6e1b22fd8e8bf774f0d661f0b31585f69335f221678f800fb12d9b08bac142fe28b67336d4c2e1e89ff824c38ecef
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,20 @@
1
+ ### Development
2
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.4.3...3-4-maintenance)
3
+
4
+ ### 3.4.3 / 2016-02-19
5
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.4.2...3.4.3)
6
+
7
+ Bug Fixes:
8
+
9
+ * Prevent a `TypeError` from occuring when running via the rake task when
10
+ Ruby crashes. (Patrik Wenger, #2161)
11
+ * Only consider example and group declaration lines from a specific file
12
+ when applying line number filtering, instead of considering all
13
+ declaration lines from all spec files. (Myron Marston, #2170)
14
+ * Fix failure snippet extraction so that snippets that contain `do-end` style
15
+ block and end with `end`-only line can be extracted properly.
16
+ (Yuji Nakayama, #2173)
17
+
1
18
  ### 3.4.2 / 2016-01-26
2
19
  [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.4.1...v3.4.2)
3
20
 
@@ -347,7 +347,7 @@ module RSpec
347
347
  @descendant_filtered_examples = nil
348
348
  @_descendants = nil
349
349
  @parent_groups = nil
350
- @declaration_line_numbers = nil
350
+ @declaration_locations = nil
351
351
  end
352
352
 
353
353
  # Adds an example to the example group
@@ -599,10 +599,10 @@ module RSpec
599
599
  end
600
600
 
601
601
  # @private
602
- def self.declaration_line_numbers
603
- @declaration_line_numbers ||= [metadata[:line_number]] +
604
- examples.map { |e| e.metadata[:line_number] } +
605
- FlatMap.flat_map(children, &:declaration_line_numbers)
602
+ def self.declaration_locations
603
+ @declaration_locations ||= [Metadata.location_tuple_from(metadata)] +
604
+ examples.map { |e| Metadata.location_tuple_from(e.metadata) } +
605
+ FlatMap.flat_map(children, &:declaration_locations)
606
606
  end
607
607
 
608
608
  # @return [String] the unique id of this example group. Pass
@@ -92,9 +92,11 @@ module RSpec
92
92
 
93
93
  private
94
94
 
95
- def final_exception(exception)
96
- if exception.cause
97
- final_exception(exception.cause)
95
+ def final_exception(exception, previous=[])
96
+ cause = exception.cause
97
+ if cause && !previous.include?(cause)
98
+ previous << cause
99
+ final_exception(cause, previous)
98
100
  else
99
101
  exception
100
102
  end
@@ -23,13 +23,6 @@ module RSpec
23
23
  if RSpec::Support::RubyFeatures.ripper_supported?
24
24
  NoExpressionAtLineError = Class.new(StandardError)
25
25
 
26
- PAREN_TOKEN_TYPE_PAIRS = {
27
- :on_lbracket => :on_rbracket,
28
- :on_lparen => :on_rparen,
29
- :on_lbrace => :on_rbrace,
30
- :on_heredoc_beg => :on_heredoc_end
31
- }
32
-
33
26
  attr_reader :source, :beginning_line_number, :max_line_count
34
27
 
35
28
  def self.extract_expression_lines_at(file_path, beginning_line_number, max_line_count=nil)
@@ -64,29 +57,29 @@ module RSpec
64
57
  def line_range_of_expression
65
58
  @line_range_of_expression ||= begin
66
59
  line_range = line_range_of_location_nodes_in_expression
67
- initial_unclosed_parens = unclosed_paren_tokens_in_line_range(line_range)
68
- unclosed_parens = initial_unclosed_parens
60
+ initial_unclosed_tokens = unclosed_tokens_in_line_range(line_range)
61
+ unclosed_tokens = initial_unclosed_tokens
69
62
 
70
- until (initial_unclosed_parens & unclosed_parens).empty?
63
+ until (initial_unclosed_tokens & unclosed_tokens).empty?
71
64
  line_range = (line_range.begin)..(line_range.end + 1)
72
- unclosed_parens = unclosed_paren_tokens_in_line_range(line_range)
65
+ unclosed_tokens = unclosed_tokens_in_line_range(line_range)
73
66
  end
74
67
 
75
68
  line_range
76
69
  end
77
70
  end
78
71
 
79
- def unclosed_paren_tokens_in_line_range(line_range)
72
+ def unclosed_tokens_in_line_range(line_range)
80
73
  tokens = FlatMap.flat_map(line_range) do |line_number|
81
74
  source.tokens_by_line_number[line_number]
82
75
  end
83
76
 
84
77
  tokens.each_with_object([]) do |token, unclosed_tokens|
85
- if PAREN_TOKEN_TYPE_PAIRS.keys.include?(token.type)
78
+ if token.opening?
86
79
  unclosed_tokens << token
87
80
  else
88
81
  index = unclosed_tokens.rindex do |unclosed_token|
89
- PAREN_TOKEN_TYPE_PAIRS[unclosed_token.type] == token.type
82
+ unclosed_token.closed_by?(token)
90
83
  end
91
84
  unclosed_tokens.delete_at(index) if index
92
85
  end
@@ -106,6 +106,11 @@ module RSpec
106
106
  "#{metadata[:rerun_file_path]}[#{metadata[:scoped_id]}]"
107
107
  end
108
108
 
109
+ # @private
110
+ def self.location_tuple_from(metadata)
111
+ [metadata[:absolute_file_path], metadata[:line_number]]
112
+ end
113
+
109
114
  # @private
110
115
  # Used internally to populate metadata hashes with computed keys
111
116
  # managed by RSpec.
@@ -15,9 +15,9 @@ module RSpec
15
15
  # @private
16
16
  def filter_applies?(key, value, metadata)
17
17
  silence_metadata_example_group_deprecations do
18
- return location_filter_applies?(value, metadata) if key == :locations
19
- return id_filter_applies?(value, metadata) if key == :ids
20
- return filters_apply?(key, value, metadata) if Hash === value
18
+ return location_filter_applies?(value, metadata) if key == :locations
19
+ return id_filter_applies?(value, metadata) if key == :ids
20
+ return filters_apply?(key, value, metadata) if Hash === value
21
21
 
22
22
  return false unless metadata.key?(key)
23
23
  return true if TrueClass === value && !!metadata[key]
@@ -49,13 +49,14 @@ module RSpec
49
49
  end
50
50
 
51
51
  def location_filter_applies?(locations, metadata)
52
- line_numbers = example_group_declaration_lines(locations, metadata)
53
- line_number_filter_applies?(line_numbers, metadata)
54
- end
52
+ Metadata.ascend(metadata).any? do |meta|
53
+ file_path = meta[:absolute_file_path]
54
+ line_num = meta[:line_number]
55
55
 
56
- def line_number_filter_applies?(line_numbers, metadata)
57
- preceding_declaration_lines = line_numbers.map { |n| RSpec.world.preceding_declaration_line(n) }
58
- !(relevant_line_numbers(metadata) & preceding_declaration_lines).empty?
56
+ locations[file_path].any? do |filter_line_num|
57
+ line_num == RSpec.world.preceding_declaration_line(file_path, filter_line_num)
58
+ end
59
+ end
59
60
  end
60
61
 
61
62
  def proc_filter_applies?(key, proc, metadata)
@@ -66,16 +67,6 @@ module RSpec
66
67
  end
67
68
  end
68
69
 
69
- def relevant_line_numbers(metadata)
70
- Metadata.ascend(metadata).map { |meta| meta[:line_number] }
71
- end
72
-
73
- def example_group_declaration_lines(locations, metadata)
74
- FlatMap.flat_map(Metadata.ascend(metadata)) do |meta|
75
- locations[meta[:absolute_file_path]]
76
- end.uniq
77
- end
78
-
79
70
  def filters_apply?(key, value, metadata)
80
71
  subhash = metadata[key]
81
72
  return false unless Hash === subhash || HashImitatable === subhash
@@ -81,7 +81,7 @@ module RSpec
81
81
 
82
82
  return unless fail_on_error
83
83
  $stderr.puts "#{command} failed" if verbose
84
- exit $?.exitstatus
84
+ exit $?.exitstatus || 1
85
85
  end
86
86
 
87
87
  private
@@ -6,6 +6,17 @@ module RSpec
6
6
  # @private
7
7
  # A wrapper for Ripper token which is generated with `Ripper.lex`.
8
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
+ 'do' => 'end'
18
+ }.freeze
19
+
9
20
  attr_reader :token
10
21
 
11
22
  def self.tokens_from_ripper_tokens(ripper_tokens)
@@ -37,6 +48,38 @@ module RSpec
37
48
  def inspect
38
49
  "#<#{self.class} #{type} #{string.inspect}>"
39
50
  end
51
+
52
+ def keyword?
53
+ type == :on_kw
54
+ end
55
+
56
+ def opening?
57
+ opening_delimiter? || opening_keyword?
58
+ end
59
+
60
+ def closed_by?(other)
61
+ closed_by_delimiter?(other) || closed_by_keyword?(other)
62
+ end
63
+
64
+ private
65
+
66
+ def opening_delimiter?
67
+ CLOSING_TYPES_BY_OPENING_TYPE.key?(type)
68
+ end
69
+
70
+ def opening_keyword?
71
+ return false unless keyword?
72
+ CLOSING_KEYWORDS_BY_OPENING_KEYWORD.key?(string)
73
+ end
74
+
75
+ def closed_by_delimiter?(other)
76
+ other.type == CLOSING_TYPES_BY_OPENING_TYPE[type]
77
+ end
78
+
79
+ def closed_by_keyword?(other)
80
+ return false unless other.keyword?
81
+ other.string == CLOSING_KEYWORDS_BY_OPENING_KEYWORD[string]
82
+ end
40
83
  end
41
84
  end
42
85
  end
@@ -3,7 +3,7 @@ module RSpec
3
3
  # Version information for RSpec Core.
4
4
  module Version
5
5
  # Current version of RSpec Core, in semantic versioning format.
6
- STRING = '3.4.2'
6
+ STRING = '3.4.3'
7
7
  end
8
8
  end
9
9
  end
@@ -96,10 +96,12 @@ module RSpec
96
96
  # @api private
97
97
  #
98
98
  # Find line number of previous declaration.
99
- def preceding_declaration_line(filter_line)
100
- declaration_line_numbers.sort.inject(nil) do |highest_prior_declaration_line, line|
101
- line <= filter_line ? line : highest_prior_declaration_line
99
+ def preceding_declaration_line(absolute_file_name, filter_line)
100
+ line_numbers = descending_declaration_line_numbers_by_file.fetch(absolute_file_name) do
101
+ return nil
102
102
  end
103
+
104
+ line_numbers.find { |num| num <= filter_line }
103
105
  end
104
106
 
105
107
  # @private
@@ -179,8 +181,22 @@ module RSpec
179
181
 
180
182
  private
181
183
 
182
- def declaration_line_numbers
183
- @declaration_line_numbers ||= FlatMap.flat_map(example_groups, &:declaration_line_numbers)
184
+ def descending_declaration_line_numbers_by_file
185
+ @descending_declaration_line_numbers_by_file ||= begin
186
+ declaration_locations = FlatMap.flat_map(example_groups, &:declaration_locations)
187
+ hash_of_arrays = Hash.new { |h, k| h[k] = [] }
188
+
189
+ # TODO: change `inject` to `each_with_object` when we drop 1.8.7 support.
190
+ line_nums_by_file = declaration_locations.inject(hash_of_arrays) do |hash, (file_name, line_number)|
191
+ hash[file_name] << line_number
192
+ hash
193
+ end
194
+
195
+ line_nums_by_file.each_value do |list|
196
+ list.sort!
197
+ list.reverse!
198
+ end
199
+ end
184
200
  end
185
201
 
186
202
  def fail_if_config_and_cli_options_invalid
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.2
4
+ version: 3.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Baker
@@ -46,7 +46,7 @@ cert_chain:
46
46
  ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
47
47
  F3MdtaDehhjC
48
48
  -----END CERTIFICATE-----
49
- date: 2016-01-26 00:00:00.000000000 Z
49
+ date: 2016-02-18 00:00:00.000000000 Z
50
50
  dependencies:
51
51
  - !ruby/object:Gem::Dependency
52
52
  name: rspec-support
@@ -293,9 +293,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
293
293
  version: '0'
294
294
  requirements: []
295
295
  rubyforge_project:
296
- rubygems_version: 2.2.2
296
+ rubygems_version: 2.5.1
297
297
  signing_key:
298
298
  specification_version: 4
299
- summary: rspec-core-3.4.2
299
+ summary: rspec-core-3.4.3
300
300
  test_files: []
301
301
  has_rdoc:
metadata.gz.sig CHANGED
Binary file