Sha256: 5fec14a9fc4eec4c56c64bd7be73f1f389b73c2f1d794568ac9567af23540221

Contents?: true

Size: 1.78 KB

Versions: 3

Compression:

Stored size: 1.78 KB

Contents

require 'coveralls'
Coveralls.wear!

require 'licensee'
require 'open3'
require 'tmpdir'

RSpec.configure do |config|
  config.shared_context_metadata_behavior = :apply_to_host_groups
  config.example_status_persistence_file_path = 'spec/examples.txt'
  config.disable_monkey_patching!
  config.warnings = true

  config.default_formatter = 'doc' if config.files_to_run.one?

  config.order = :random
  Kernel.srand config.seed
end

def project_root
  File.expand_path '../', File.dirname(__FILE__)
end

def fixtures_base
  File.expand_path 'spec/fixtures', project_root
end

def fixture_path(fixture)
  File.expand_path fixture, fixtures_base
end

def sub_copyright_info(text)
  text.sub! '[fullname]', 'Ben Balter'
  text.sub! '[year]', '2016'
  text.sub! '[email]', 'ben@github.invalid'
  text
end

def wrap(text, line_width = 80)
  text = text.clone
  copyright = /^#{Licensee::Matchers::Copyright::REGEX}$/i.match(text)
  if copyright
    text.gsub!(/^#{Licensee::Matchers::Copyright::REGEX}$/i, '[COPYRIGHT]')
  end
  text.gsub!(/([^\n])\n([^\n])/, '\1 \2')

  text = text.split("\n").collect do |line|
    if line.length > line_width
      line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip
    else
      line
    end
  end * "\n"
  text.gsub! '[COPYRIGHT]', "\n#{copyright}\n" if copyright
  text.strip
end

# Add random words to the end of a license to test similarity tollerances
def add_random_words(string, count = 5)
  string = string.dup
  ipsum = %w(lorem ipsum dolor sit amet consectetur adipiscing elit)
  count.times do
    string << " #{ipsum[Random.rand(ipsum.length)]}"
  end
  string
end

def git_init(path)
  Dir.chdir path do
    `git init`
    `git add .`
    `git commit -m 'initial commit'`
  end
end

RSpec::Matchers.define :be_an_existing_file do
  match { |path| File.exist?(path) }
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
licensee-8.7.0 spec/spec_helper.rb
licensee-8.6.1 spec/spec_helper.rb
licensee-8.6.0 spec/spec_helper.rb