Sha256: 052c52767760da4586b9396fec2a9b357cccc1252f418f0166cef1fb8d9f48ab
Contents?: true
Size: 1.43 KB
Versions: 7
Compression:
Stored size: 1.43 KB
Contents
require 'spec_helper' require 'ronin/gen/generator' require 'gen/helpers/data' require 'gen/classes/basic_generator' require 'gen/classes/file_generator' require 'gen/classes/touch_generator' require 'gen/classes/dir_generator' require 'gen/classes/templated_generator' require 'tmpdir' require 'fileutils' describe Gen::Generator do describe "setup" do subject { BasicGenerator.new } before(:all) do subject.setup end it "should set default values before invoking any tasks" do subject.var.should == 'test' end end describe "actions" do before(:all) do @previous_dir = Dir.pwd @dir = File.join(Dir.tmpdir,'ronin_generators') FileUtils.mkdir(@dir) Dir.chdir(@dir) end it "should generate files" do FileGenerator.generate File.read(File.join(@dir,'test.txt')).should == "hello" end it "should touch files" do TouchGenerator.generate File.file?(File.join(@dir,'test2.txt')).should == true end it "should generate directories" do DirGenerator.generate File.directory?(File.join(@dir,'test')).should == true end it "should generate files using templates" do path = File.join(@dir,'templated.txt') TemplatedGenerator.generate(:message => 'hello') File.read(path).chomp.should == "message: hello" end after(:all) do FileUtils.rm_r(@dir) Dir.chdir(@previous_dir) end end end
Version data entries
7 entries across 7 versions & 1 rubygems