flakey_spec_catcher 0.11.0 → 0.11.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1be370079a94e8f578e03be6e8683cd76ff8d1f5656422427c8ca3920856b38c
4
- data.tar.gz: 6dddff4adf5e7f452a366bff7b67a50e8e4a04e64a9165c80e9318235afcae33
3
+ metadata.gz: 6a88793e18d2fc8a483639620b2876b4955f3fc8a5425f41a25cc2e3509cd6e0
4
+ data.tar.gz: f4c0a38a03eb0fabcde7111f3bf8bfc3698a7c5c576a106fb7c7b4337ed782b8
5
5
  SHA512:
6
- metadata.gz: b49520ad8fe8a9115ae04bf90c93159694c0bcbbae087acaa9953aac26927b61efb68e3531d9097ea86b5b60d8bf6f84df685baf6798c95bcd0f5e560c752af5
7
- data.tar.gz: 927b24f3283dfdd8575c3210a560c21a63f315bc98ada713390b15ac1d3dea0773534d761bf51ca5216eaee03567f7602e50615dc85fdab52620ab78ea456070
6
+ metadata.gz: 8c033294dc195ab6784dc22919ff986f7e646657b85a7efe6a5780333b666b4a7c7bba5f10ab41839ee9574cd9f4307a6f9b6c276f5da4f9144b5828dd1f2e06
7
+ data.tar.gz: 00a950c3296e05a81c8294c2005d6c84b454296de2f697b7ef2152ec6f29ef02c6305b3749d3a2d1449436fa1b6fb6ac0ccc2d9e3f5ae9db7ebef04043db2b96
@@ -24,23 +24,30 @@ module FlakeySpecCatcher
24
24
  @change_contexts.map(&:rerun_info)
25
25
  end
26
26
 
27
+ # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
27
28
  def fill_contexts
28
29
  change_context_stack = []
29
30
  ignore_scope_closure = 0
30
31
  lines_in_file = File.read(@file_name).split("\n")
31
32
  lines_in_file.each_with_index do |line, index|
33
+ shared_example_identified = false
34
+
32
35
  # Check if line matches an rspec example or examplegroup format
33
36
  if line =~ spec_scope
34
37
  handle_change_context(line, index, change_context_stack)
35
38
  # Else, ignore other blocks that might pollute context stack
39
+ elsif line =~ shared_example_scope
40
+ handle_change_context(line, index, change_context_stack)
41
+ shared_example_identified = true
36
42
  elsif line_matches_method_or_block(line)
37
43
  ignore_scope_closure += 1
38
44
  end
39
45
 
40
46
  fill_context(line, index, change_context_stack)
41
47
 
42
- # Note - some things use do-like loops and we need to be able to ignore those
43
- if line =~ pop_scope
48
+ if shared_example_identified
49
+ change_context_stack.pop
50
+ elsif line =~ pop_scope
44
51
  if ignore_scope_closure.positive?
45
52
  ignore_scope_closure -= 1
46
53
  else
@@ -49,6 +56,7 @@ module FlakeySpecCatcher
49
56
  end
50
57
  end
51
58
  end
59
+ # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
52
60
 
53
61
  private
54
62
 
@@ -70,14 +78,15 @@ module FlakeySpecCatcher
70
78
  end
71
79
 
72
80
  def spec_scope
73
- # Not sure if we need to check for description in quotes
74
- # spec_scope = /^\s*(#{SCOPE_SPECIFIERS.join("|")})\s*('.*'|".*").*do\s*$/
75
-
76
81
  /\s*(#{SCOPE_SPECIFIERS.join("|")}).*\s+do.*$/
77
82
  end
78
83
 
84
+ def shared_example_scope
85
+ /\s*(#{SHARED_EXAMPLES.join("|")}).*\s+.*$/
86
+ end
87
+
79
88
  def line_matches_method_or_block(line)
80
- return true if line =~ /\s*do(\s+|$)/ || line =~ /^\s*def\s+/ || line =~ /^\s*if\s+/
89
+ return true if line =~ /\s*do(\s+|$)/ || line =~ /^\s*def\s+/ || line =~ /^\s*if\s+/ || line =~ /^\s*class\s+/
81
90
 
82
91
  false
83
92
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FlakeySpecCatcher
4
- VERSION = '0.11.0'
4
+ VERSION = '0.11.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flakey_spec_catcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Watson
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-10-12 00:00:00.000000000 Z
13
+ date: 2021-10-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec