Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Edouard-chin/70705542a59a8593f619b02e1c0a188c to your computer and use it in GitHub Desktop.
Save Edouard-chin/70705542a59a8593f619b02e1c0a188c to your computer and use it in GitHub Desktop.
Rails' SetupAndTeardown bug
require 'bundler/inline'
gemfile(true) do
gem 'activesupport', github: 'rails/rails'
end
require 'active_support/all'
require 'minitest/autorun'
class BeforeSetupTest < ActiveSupport::TestCase
module MyLibrary
def before_setup
super
puts "before_setup called"
end
end
include MyLibrary
setup do
puts "Test#setup called"
end
test 'before_setup is called after setup' do
assert true
end
end
class AfterTeardownTest < ActiveSupport::TestCase
module MyLibrary
def after_teardown
super
puts "Will never get called"
end
end
include MyLibrary
teardown do
raise 'Teardown raises for any reason'
end
test 'after_teardown does not get called' do
assert true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment