Sha256: c92a805063a254e741e4e13603f2bb24533a6695302422f94c9f9d9102b2e656

Contents?: true

Size: 1.4 KB

Versions: 8

Compression:

Stored size: 1.4 KB

Contents

$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
$test_env = true
require 'bundlegem'
require 'fileutils'
require 'pry'

# Mock our home directory

ENV['HOME'] = "/tmp/bundlegem_mock_home"





def setup_mock_web_template
  ENV['best_templates'] = "#{ENV['HOME']}/arduino.git"
  FileUtils.mkdir("#{ENV['HOME']}/arduino.git")
  FileUtils.touch("#{ENV['HOME']}/arduino.git/README.md")
  auth_settings = 'git config --local user.email "you@example.com" && git config --local user.name "test"'
  `cd "#{ENV['HOME']}/arduino.git" && git init &&  git add . && #{auth_settings} && git commit -m "haxing"`
end

def remove_mock_web_template
  FileUtils.rm_rf("#{ENV['HOME']}/arduino.git")
end

def create_user_defined_template(category = nil)
  new_templates_dir = "#{@template_root}/empty_template"

  # Creates the gem template (empty folder)
  FileUtils.mkdir_p new_templates_dir

  # Writes the category
  File.open("#{new_templates_dir}/.bundlegem", "w+") do |f|
    f.puts "category: #{category}" unless category.nil?
  end
end


def reset_test_env
  FileUtils.rm_rf @mocked_home
  FileUtils.rm_rf @dst_dir

  FileUtils.mkdir_p @dst_dir
  FileUtils.mkdir_p @template_root
end

# squelch stdout
# usage capture_stdout { a_method(a_signal.new, a_model, a_helper) }
def capture_stdout(&block)
  original_stdout = $stdout
  $stdout = fake = StringIO.new
  begin
    yield
  ensure
    $stdout = original_stdout
  end
 fake.string
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
bundlegem-0.0.14 spec/spec_helper.rb
bundlegem-0.0.13 spec/spec_helper.rb
bundlegem-0.0.12 spec/spec_helper.rb
bundlegem-0.0.11 spec/spec_helper.rb
bundlegem-0.0.10 spec/spec_helper.rb
bundlegem-0.0.9 spec/spec_helper.rb
bundlegem-0.0.8 spec/spec_helper.rb
bundlegem-0.0.7 spec/spec_helper.rb