Created
September 29, 2023 12:15
-
-
Save ArturT/12a46b7dd65d4d409321d1acd30ef4ca to your computer and use it in GitHub Desktop.
Knapsack Pro Queue Mode hooks examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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