Skip to content

Instantly share code, notes, and snippets.

@ArturT
Created September 29, 2023 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArturT/12a46b7dd65d4d409321d1acd30ef4ca to your computer and use it in GitHub Desktop.
Save ArturT/12a46b7dd65d4d409321d1acd30ef4ca to your computer and use it in GitHub Desktop.
Knapsack Pro Queue Mode hooks examples
before_suite_block = proc {
puts '+'*100
puts 'RSpec before suite hook called only once'
}
unless KnapsackPro::Config::Env.queue_recording_enabled?
RSpec.configure do |config|
config.before(:suite) do
before_suite_block.call
puts 'Run this only when not using Knapsack Pro Queue Mode'
end
end
end
KnapsackPro::Hooks::Queue.before_queue do |queue_id|
before_suite_block.call
puts 'Run this only when using Knapsack Pro Queue Mode'
puts 'This code is executed within the context of RSpec before(:suite) hook'
end
after_suite_block = proc {
puts '+'*100
puts 'after suite hook called only once'
}
unless KnapsackPro::Config::Env.queue_recording_enabled?
RSpec.configure do |config|
config.after(:suite) do
after_suite_block.call
puts 'Run this only when not using Knapsack Pro Queue Mode'
end
end
end
KnapsackPro::Hooks::Queue.after_queue do |queue_id|
after_suite_block.call
puts 'Run this only when using Knapsack Pro Queue Mode'
puts "This code is executed outside of the RSpec after(:suite) hook context because it's impossible to determine which after(:suite) is the last one to execute until it's executed."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment