Created
July 12, 2016 14:45
-
-
Save jah2488/7edf5af2f09853cb08021b127a5a5df5 to your computer and use it in GitHub Desktop.
A ruby script for generating an empty kata project.
This file contains 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
#!/usr/bin/env ruby | |
# This script will create the folder structure and files | |
# needed for doing a kata using TDD. | |
kata_name = (ARGV[0] || 'morning') | |
dir_name = kata_name + "_kata" | |
# These are all the commands we will run | |
# in the order in which we will run them. | |
commands = [ | |
"mkdir #{dir_name}", | |
"touch #{dir_name}/Gemfile", | |
"mkdir #{dir_name}/lib", | |
"mkdir #{dir_name}/test", | |
"touch #{dir_name}/test/#{kata_name.downcase}_test.rb", | |
"touch #{dir_name}/lib/#{kata_name.downcase}.rb", | |
] | |
commands.each do |command| | |
puts command | |
`#{command}` | |
end | |
File.open("#{dir_name}/Gemfile", "w") do |f| | |
f.puts("source 'https://rubygems.org'") | |
f.puts("") | |
f.puts("gem 'mintest'") | |
f.puts("gem 'pry'") | |
end | |
File.open("#{dir_name}/test/#{kata_name.downcase}_test.rb", "w") do |f| | |
f.puts("require 'minitest/autorun'") | |
f.puts("require 'minitest/pride'") | |
f.puts("require_relative '../lib/#{kata_name.downcase}'") | |
f.puts("") | |
f.puts("class #{kata_name.capitalize}Test < Minitest::Test") | |
f.puts(" def test_working") | |
f.puts(" assert_equal(2, (1 + 1))") | |
f.puts(" end") | |
f.puts("end") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment