Skip to content

Instantly share code, notes, and snippets.

@practicingruby
Created March 7, 2013 14:43
Show Gist options
  • Select an option

  • Save practicingruby/5108497 to your computer and use it in GitHub Desktop.

Select an option

Save practicingruby/5108497 to your computer and use it in GitHub Desktop.
require "fileutils"
class Skeletor
include FileUtils
def self.generate(project_dir)
new(project_dir).generate
end
def initialize(project_dir)
self.project_dir = project_dir
end
attr_accessor :project_dir
def generate
cd(project_dir) do
mkdir_p("lib")
mkdir_p("bin")
touch("README.md")
touch("Gemfile")
end
end
end
require "tempfile"
require "minitest/autorun"
describe "A code generator" do
let(:project_dir) { Dir.mktmpdir }
after { FileUtils.remove_entry_secure(project_dir) }
it "generates an application skeleton" do
Skeletor.generate(project_dir)
FileUtils.cd(project_dir) do
assert Dir.exist?("lib"), "expected lib dir to exist"
assert Dir.exist?("bin"), "expected bin dir to exist"
assert File.exist?("README.md"), "expected README.md to exist"
assert File.exist?("Gemfile"), "expected Gemfile to exist"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment