air_test 0.1.5.0 → 0.1.5.2

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: 4b19be078019395eb0f510f9f96d0acb563f45dddfce668d27ed1194d1c2302e
4
- data.tar.gz: 1fb2a90ce3c6581dc5a77fdf23e71d2f0474fec361faf999960a41e92a31c77a
3
+ metadata.gz: e2e98274b6a895b0b6c0e39108f32114b56456f4ed10e9f8dddc82a5e0ea1dfe
4
+ data.tar.gz: 9d839e439c871bb5a1e88b89420da3e28ca1baec3f8771c682aab7a8b703e2eb
5
5
  SHA512:
6
- metadata.gz: 2cc0278ea9d903ce627c1afb64cc052c535900ab371d3b97a3e69e684135b4fbd52adde2e86c33750bc66377b2c8d3c9f63186d77f5eab478c14b42c3838ed5f
7
- data.tar.gz: dfd2c4ad5a70b20c981b961c28e6f09506c6e4ce1176ab6a7296bd52dffa33a01a165e8b38f16724d4c0709753452f5cc7f2751344bc5f381575d47a1a3fef3e
6
+ metadata.gz: 8aea7c921c0941b905f6e25613b1c32b7105543337ff185020c2cd55609be468daaf190a41fdc2580c0e5d00388e54edf5eeb43be214f10df7fa1fc41aea05e2
7
+ data.tar.gz: 919f4c97ed47103ba86ce3d7bacc63feb473e8f7ceb1667e60daa59e171780f3a7a807b8e0ba10484791445689302cc36792fe690581cc15a520407762241094
@@ -81,43 +81,53 @@ module AirTest
81
81
  current_scenario = nil
82
82
  in_feature_block = false
83
83
  in_scenario_block = false
84
- last_block_type = nil
84
+ in_background_block = false
85
+ background_steps = []
86
+
85
87
  blocks.each_with_index do |block, idx|
86
- case block["type"]
87
- when "heading_1", "heading_2", "heading_3"
88
- 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
89
94
  if heading_text.downcase.include?("feature")
90
95
  in_feature_block = true
91
96
  in_scenario_block = false
97
+ in_background_block = false
92
98
  parsed_data[:feature] = heading_text
99
+ elsif heading_text.strip.downcase == "background:"
100
+ in_background_block = true
101
+ in_feature_block = false
102
+ in_scenario_block = false
93
103
  elsif heading_text.downcase.include?("scenario")
94
104
  in_scenario_block = true
95
105
  in_feature_block = false
106
+ in_background_block = false
96
107
  current_scenario = { title: heading_text, steps: [] }
97
108
  parsed_data[:scenarios] << current_scenario
98
109
  else
99
110
  in_feature_block = false
100
111
  in_scenario_block = false
112
+ in_background_block = false
101
113
  end
102
- when "paragraph"
103
- 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)
104
122
  next if text.empty?
105
-
106
123
  if in_feature_block
107
124
  parsed_data[:feature] += "\n#{text}"
125
+ elsif in_background_block
126
+ background_steps << text
108
127
  elsif in_scenario_block && current_scenario
109
128
  current_scenario[:steps] << text
110
129
  end
111
- when "bulleted_list_item", "numbered_list_item"
112
- text = extract_text(block[block["type"]]["rich_text"])
113
- next if text.empty?
114
-
115
- if in_feature_block
116
- parsed_data[:feature] += "\n• #{text}"
117
- elsif in_scenario_block && current_scenario
118
- current_scenario[:steps] << text
119
- end
120
- when "callout"
130
+ elsif block_type == "callout"
121
131
  text = extract_text(block["callout"]["rich_text"])
122
132
  next if text.empty?
123
133
 
@@ -132,17 +142,24 @@ module AirTest
132
142
  parsed_data[:meta][:assignee] = extract_assignee(text)
133
143
  end
134
144
  end
135
- last_block_type = block["type"]
136
145
  end
137
- # Handle case where there is only one scenario and no explicit scenario heading
146
+
147
+ # Prepend background steps to each scenario
148
+ if background_steps.any?
149
+ parsed_data[:scenarios].each do |scenario|
150
+ scenario[:steps] = background_steps + scenario[:steps]
151
+ end
152
+ end
153
+
154
+ # Fallback: If no scenarios found, treat all steps after feature as a single scenario
138
155
  if parsed_data[:scenarios].empty?
139
- # Try to find steps after the feature heading
140
156
  steps = []
141
157
  in_steps = false
142
158
  blocks.each do |block|
143
- case block["type"]
144
- when "heading_1", "heading_2", "heading_3"
145
- 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
146
163
  if heading_text.downcase.include?("feature")
147
164
  in_steps = true
148
165
  elsif heading_text.downcase.include?("scenario")
@@ -150,16 +167,15 @@ module AirTest
150
167
  else
151
168
  in_steps = false
152
169
  end
153
- when "paragraph", "bulleted_list_item", "numbered_list_item"
154
- text = extract_text(block[block["type"]]["rich_text"] || block["paragraph"]["rich_text"])
155
- next if text.empty?
156
- 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?
157
172
  end
158
173
  end
159
174
  if steps.any?
160
175
  parsed_data[:scenarios] << { title: "Scenario", steps: steps }
161
176
  end
162
177
  end
178
+
163
179
  parsed_data[:feature] = parsed_data[:feature].strip
164
180
  parsed_data[:meta][:tags] = parsed_data[:meta][:tags].uniq
165
181
  parsed_data
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AirTest
4
- VERSION = "0.1.5.0"
4
+ VERSION = "0.1.5.2"
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.0
4
+ version: 0.1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - julien bouland