1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
require_relative "snowglobe"
class RailsApplicationWithShouldaContext < Snowglobe::RailsApplication
ROOT_DIRECTORY = Pathname.new("../../..").expand_path(__FILE__)
def create
super
bundle.updating do
bundle.add_gem(test_framework_gem_name, group: :test)
bundle.add_gem("shoulda-context", path: ROOT_DIRECTORY, group: :test)
end
end
def test_framework_require_path
if TEST_FRAMEWORK == "test_unit"
"test-unit"
else
"minitest/autorun"
end
end
def create_gem_with_macro(module_name:, location:, macro_name:)
fs.write_file("#{location}/shoulda_macros/macros.rb", <<~FILE)
module #{module_name}
def #{macro_name}
puts "#{macro_name} is available"
end
end
Shoulda::Context.configure do |config|
config.extend(#{module_name})
end
FILE
end
private
def test_framework_gem_name
if TEST_FRAMEWORK == "test_unit"
"test-unit"
else
"minitest"
end
end
end
|