air_test 0.1.5.1 → 0.1.5.3

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: f817f7224c6f3bc2bc49607ce00e9e069701e85c2bfeab3015aff5795ce0767b
4
- data.tar.gz: a79251b05748bdf35a4b9befaea87bdb9bf3271d4eafaded2e14403911dd3a0a
3
+ metadata.gz: 565823aa988fd7627470ab4c4772922d9104461296b4b74c37a23e5514359692
4
+ data.tar.gz: f8167262c36cb97fa722c8a6de64a62c9f3032627c6088c7af082359e34bbf3d
5
5
  SHA512:
6
- metadata.gz: 1befd0f3de325c240a0299a99ffb1e359282d57e36c1f713a2bef8d7fe1ff2ac927deb183e3dcfb23aab362a63eddb3b5eaa1207c8b7bbe6ec796e043c3e3875
7
- data.tar.gz: 0246d8260912850bec3d9ca8391a1441bf964a92ff343b4fc5d12224f3923c883ac07bd1bcb97edbf3ae8e3d372bc508b266c19072361a38f0420ad5b0ee5901
6
+ metadata.gz: 9623e4ecf1d04c4d3e55cd225750fae5af444e86053577ea3f1bfedfe357f3765e4c6409320dc0b48ee67f426a6411274f1827706e4bd5e9a123e098494065f9
7
+ data.tar.gz: aeed0c493b76b3b8862a1cd1121c9bad0e993c99e48f9644e8a5bf48917e9a8a5b183a13e00d8ddfb9ef78a90163d4bde8f846020cb585cc5e5ad67bcab9071e
@@ -83,10 +83,14 @@ module AirTest
83
83
  in_scenario_block = false
84
84
  in_background_block = false
85
85
  background_steps = []
86
+
86
87
  blocks.each_with_index do |block, idx|
87
- case block["type"]
88
- when "heading_1", "heading_2", "heading_3"
89
- heading_text = extract_text(block[block["type"]]["rich_text"])
88
+ block_type = block["type"]
89
+ text = extract_text(block[block_type]["rich_text"]) rescue ""
90
+
91
+ # Detect headings for feature, background, and scenario
92
+ if %w[heading_1 heading_2 heading_3].include?(block_type)
93
+ heading_text = text.strip
90
94
  if heading_text.downcase.include?("feature")
91
95
  in_feature_block = true
92
96
  in_scenario_block = false
@@ -107,10 +111,15 @@ module AirTest
107
111
  in_scenario_block = false
108
112
  in_background_block = false
109
113
  end
110
- when "paragraph"
111
- text = extract_text(block["paragraph"]["rich_text"])
114
+ elsif block_type == "paragraph" && text.strip.downcase.start_with?("scenario:")
115
+ # Also detect scenario in paragraphs (for robustness)
116
+ in_scenario_block = true
117
+ in_feature_block = false
118
+ in_background_block = false
119
+ current_scenario = { title: text.strip, steps: [] }
120
+ parsed_data[:scenarios] << current_scenario
121
+ elsif %w[paragraph bulleted_list_item numbered_list_item].include?(block_type)
112
122
  next if text.empty?
113
-
114
123
  if in_feature_block
115
124
  parsed_data[:feature] += "\n#{text}"
116
125
  elsif in_background_block
@@ -118,18 +127,7 @@ module AirTest
118
127
  elsif in_scenario_block && current_scenario
119
128
  current_scenario[:steps] << text
120
129
  end
121
- when "bulleted_list_item", "numbered_list_item"
122
- text = extract_text(block[block["type"]]["rich_text"])
123
- next if text.empty?
124
-
125
- if in_feature_block
126
- parsed_data[:feature] += "\n• #{text}"
127
- elsif in_background_block
128
- background_steps << text
129
- elsif in_scenario_block && current_scenario
130
- current_scenario[:steps] << text
131
- end
132
- when "callout"
130
+ elsif block_type == "callout"
133
131
  text = extract_text(block["callout"]["rich_text"])
134
132
  next if text.empty?
135
133
 
@@ -145,21 +143,23 @@ module AirTest
145
143
  end
146
144
  end
147
145
  end
146
+
148
147
  # Prepend background steps to each scenario
149
148
  if background_steps.any?
150
149
  parsed_data[:scenarios].each do |scenario|
151
150
  scenario[:steps] = background_steps + scenario[:steps]
152
151
  end
153
152
  end
154
- # Handle case where there is only one scenario and no explicit scenario heading
153
+
154
+ # Fallback: If no scenarios found, treat all steps after feature as a single scenario
155
155
  if parsed_data[:scenarios].empty?
156
- # Try to find steps after the feature heading
157
156
  steps = []
158
157
  in_steps = false
159
158
  blocks.each do |block|
160
- case block["type"]
161
- when "heading_1", "heading_2", "heading_3"
162
- heading_text = extract_text(block[block["type"]]["rich_text"])
159
+ block_type = block["type"]
160
+ text = extract_text(block[block_type]["rich_text"] || block["paragraph"]["rich_text"]) rescue ""
161
+ if %w[heading_1 heading_2 heading_3].include?(block_type)
162
+ heading_text = text.strip
163
163
  if heading_text.downcase.include?("feature")
164
164
  in_steps = true
165
165
  elsif heading_text.downcase.include?("scenario")
@@ -167,16 +167,15 @@ module AirTest
167
167
  else
168
168
  in_steps = false
169
169
  end
170
- when "paragraph", "bulleted_list_item", "numbered_list_item"
171
- text = extract_text(block[block["type"]]["rich_text"] || block["paragraph"]["rich_text"])
172
- next if text.empty?
173
- steps << text if in_steps
170
+ elsif %w[paragraph bulleted_list_item numbered_list_item].include?(block_type)
171
+ steps << text if in_steps && !text.empty?
174
172
  end
175
173
  end
176
174
  if steps.any?
177
175
  parsed_data[:scenarios] << { title: "Scenario", steps: steps }
178
176
  end
179
177
  end
178
+
180
179
  parsed_data[:feature] = parsed_data[:feature].strip
181
180
  parsed_data[:meta][:tags] = parsed_data[:meta][:tags].uniq
182
181
  parsed_data
@@ -35,8 +35,8 @@ module AirTest
35
35
  if has_changes
36
36
  pr_title = title
37
37
  scenarios_md = parsed_data[:scenarios].map.with_index(1) do |sc, _i|
38
- steps = sc[:steps]&.join(" ")
39
- " - [ ] #{sc[:title]}#{steps}"
38
+ steps = sc[:steps]&.map { |step| " - #{step}" }&.join("\n")
39
+ " - [ ] #{sc[:title]}\n#{steps}"
40
40
  end.join("\n")
41
41
  pr_body = <<~MD
42
42
  - **Story Notion :** #{url}
@@ -22,6 +22,7 @@ module AirTest
22
22
  f.puts " pending '#{step}'"
23
23
  end
24
24
  f.puts " end"
25
+ f.puts ""
25
26
  end
26
27
  f.puts "end"
27
28
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AirTest
4
- VERSION = "0.1.5.1"
4
+ VERSION = "0.1.5.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: air_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5.1
4
+ version: 0.1.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - julien bouland