Sha256: 9516f09af2a06d8a3772f555b11bde4ab90c700780e7ec88e80e597db344feee

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

require 'ronin/generators/generator'

require 'spec_helper'
require 'generators/helpers/generators'
require 'generators/classes/file_generator'
require 'generators/classes/touch_generator'
require 'generators/classes/dir_generator'
require 'generators/classes/templated_generator'


require 'tmpdir'
require 'fileutils'

describe Generators::Generator do
  before(:all) do
    @dir = File.join(Dir.tmpdir,'ronin_generators')

    FileUtils.mkdir(@dir)
  end

  it "should generate files" do
    generator = FileGenerator.new
    generator.run(@dir)

    File.read(File.join(@dir,'test.txt')).should == "hello\n"
  end

  it "should touch files" do
    generator = TouchGenerator.new
    generator.run(@dir)

    File.file?(File.join(@dir,'test2.txt')).should == true
  end

  it "should generate directories" do
    generator = DirGenerator.new
    generator.run(@dir)

    File.directory?(File.join(@dir,'test')).should == true
  end

  it "should generate files using templates" do
    generator = TemplatedGenerator.new('hello')
    generator.run(@dir)

    File.read(File.join(@dir,'templated.txt')).should == "message: hello\n"
  end

  after(:all) do
    FileUtils.rm_r(@dir)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ronin-gen-0.1.1 spec/generators/generator_spec.rb