Skip to content

Commit

Permalink
test: ✅ update should run on step
Browse files Browse the repository at this point in the history
  • Loading branch information
gingerbenw committed Jul 14, 2023
1 parent 6e840c5 commit 4cc5644
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions test/browser/features/steps/browser-steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,27 +197,32 @@

Then(/^on ((?:[A-Za-z]+ versions (?:>=?|<=?|==) [0-9.]+(?:, )?)+):$/) do |browser_specs, steps_to_run|
spec_matcher = /^([A-Za-z]+) versions (>=?|<=?|==) ([0-9.]+)$/
run_steps = false

browser_specs.split(", ").each do |browser_spec|
browser_spec.scan(spec_matcher) do |name, operator, version|
should_run_steps = $browser.name.casecmp?(name) && $browser.version.send(operator, version.to_i)

# make sure this step is debuggable!
$logger.debug("#{$browser.name} == #{name} && v#{$browser.version} #{operator} #{version}? #{should_run_steps}")

$logger.debug("#{$browser.name} == #{name} && v#{$browser.version} #{operator} #{version}? #{should_run_steps}")
if should_run_steps
steps_to_run.each_line(chomp: true) do |step_to_run|
step(step_to_run)
end
else
indent = " " * 4
# e.g. "a step\nanother step\n" -> " 1) a step\n 2) another step"
steps_indented = steps_to_run.each_line.map.with_index(1) { |step, i| "#{indent}#{i}) #{step.chomp}" }.join("\n")

$logger.info("Skipping steps on #{$browser.name} v#{$browser.version}:\n#{steps_indented}")
run_steps = true
end
end
end

if run_steps
steps_to_run.each_line(chomp: true) do |step_to_run|
step(step_to_run)
end
else
indent = " " * 4
# e.g. "a step\nanother step\n" -> " 1) a step\n 2) another step"
steps_indented = steps_to_run.each_line.map.with_index(1) { |step, i| "#{indent}#{i}) #{step.chomp}" }.join("\n")

$logger.info("Skipping steps on #{$browser.name} v#{$browser.version}:\n#{steps_indented}")
end
end

module Maze
Expand Down

0 comments on commit 4cc5644

Please sign in to comment.