Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kaorukobo/32509cd22b98cf99796e932565a7766e to your computer and use it in GitHub Desktop.
Save kaorukobo/32509cd22b98cf99796e932565a7766e to your computer and use it in GitHub Desktop.
require "minitest/autorun"
module HasConstant
CONST = "const"
end
# ================================================
# Pass:
class TheTest1 < Minitest::Test
include HasConstant
def test_it
CONST
end
end
# ================================================
# Fail with the following message:
# Sample#test_0001_anonymous:
# NameError: uninitialized constant TheTest2::CONST
class TheTest2 < Minitest::Test
describe "Sample" do
include HasConstant
it do
CONST
end
end
end
# ================================================
# Pass
class TheTest3 < Minitest::Test
include HasConstant
describe "Sample" do
it do
CONST
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment