Slide 67
Slide 67 text
describe Scaffolder do
before (:each) do
@shell = mock
@shell.should_receive(:shell_extension).any_number_of_times.and_return "cmd"
@shell.should_receive(:remove_command_name).any_number_of_times.and_return "del"
@shell.should_receive(:path_separator).any_number_of_times.and_return ";"
@shell.should_receive(:dir_separator).any_number_of_times.and_return "/"
Scaffolder.should_receive(:current_file).any_number_of_times.and_return("aDir/lib/aFile.rb")
@scaffolder = Scaffolder.new @shell
end
it "generates the files and directories" do
@shell.should_receive(:real_dir_entries).with("aDir/templates/a.template").and_return ["a", "b"]
@shell.should_receive(:cp_r).with "aDir/templates/a.template/a", "."
@shell.should_receive(:file?).with("a").and_return false
@shell.should_receive(:cp_r).with "aDir/templates/a.template/b", "."
@shell.should_receive(:file?).with("b").and_return fals
@scaffolder.scaffold "a.template", 'myKata'
end
it "replaces placeholders" do
@shell.should_receive(:real_dir_entries).with("aDir/templates/a.template").and_return ["a", "README", "run-once.sh", "run-endless.sh"]
@shell.should_receive(:cp_r).with "aDir/templates/a.template/a", "."
@shell.should_receive(:file?).with("a").and_return false
@shell.should_receive(:cp_r).with "aDir/templates/a.template/README", "."
@shell.should_receive(:file?).with("README").and_return true
@shell.should_receive(:read_file).with("README").and_return '%rm% %kata_file%\nb.%sh%\nc%:%d'
@shell.should_receive(:write_file).with "README", 'del myKata\nb.cmd\nc;d'
@shell.should_receive(:cp_r).with "aDir/templates/a.template/run-once.sh", "."
@shell.should_receive(:file?).with("run-once.sh").and_return true
@shell.should_receive(:read_file).with("run-once.sh").and_return "%rm% a\nb.%sh%\nc%:%d"
@shell.should_receive(:write_file).with "run-once.sh", "del a\nb.cmd\nc;d"
@shell.should_receive(:cp_r).with "aDir/templates/a.template/run-endless.sh", "."
@shell.should_receive(:file?).with("run-endless.sh").and_return true
@shell.should_receive(:read_file).with("run-endless.sh").and_return "%rm% a\nb.%sh%\nc%:%d"
@shell.should_receive(:write_file).with "run-endless.sh", "del a\nb.cmd\nc;d"
@scaffolder.scaffold "a.template", 'myKata'
end
end