Sha256: f5159daccfc77004eaf4c85c70c314e0a020a04df835d5db90b8fb9d681462d5

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

require "spec_helper"

describe "Hisyo.generate_project" do
  after(:each) do
    system("rm -rf #{@approot}")
  end

  it "should same data/ and approot/" do
    Hisyo.generate_project(
      :root => @approot,
    )
    dest= Dir.glob("#{@approot}/**/*", File::FNM_DOTMATCH).find_all{|f| File.file?(f)}.map{|f| f.gsub(@approot, "")}
    src_dir = "#{@root}/data/generators/project"
    src = Dir.glob("#{src_dir}/**/*", File::FNM_DOTMATCH).find_all{|f| File.file?(f)}.map{|f| f.gsub(src_dir, "")}
    dest.should == src
  end

  it "should not create files when :dryrun option given" do
    Hisyo.generate_project(
      :root => @approot,
      :dryrun => true,
    )
    Dir.glob("#{@approot}/**/*", File::FNM_DOTMATCH).to_a.should == []
  end

  it "should skip if file exists" do
    out,err = capture_io do
      Hisyo.generate_project(
        :root => @approot,
        :verbose => true,
      )
    end
    out.split("\n").map{|line| line.gsub(/\e\[\d+m/, "")}.map{|line| line.split(": ").first}.uniq.should == ["create", "copy to"]

    out,err = capture_io do
      Hisyo.generate_project(
        :root => @approot,
        :verbose => true,
      )
    end
    out.split("\n").map{|line| line.gsub(/\e\[\d+m/, "")}.map{|line| line.split(": ").first}.uniq.should == ["skip"]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hisyo-0.0.3 spec/generator_spec.rb