<%- assert_locals gem -%>
<%= render partial: "shared/header" -%>

require "bundler/setup"
require "bundler/gem_tasks"

require "rubocop/rake_task"
RuboCop::RakeTask.new

require "rake/testtask"
desc "Run tests."
Rake::TestTask.new do |t|
  t.test_files = FileList["test/**/*_test.rb"]
  t.warning = false
end

namespace :test do
  desc "Runs tests with coverage."
  task :coverage do
    require "simplecov"
    SimpleCov.start do
      command_name "<%= gem.name %>"
      track_files "lib/**/*.rb"
      add_filter "test/"
    end

    Rake::Task[:test].invoke
  end
end

# Acceptance tests
desc "Run the <%= gem.name %> acceptance tests."
task :acceptance do
  puts "The <%= gem.name %> gem does not have acceptance tests."
end

namespace :acceptance do
  task :coverage do
  end
  task :cleanup do
  end
end

require "yard"
require "yard/rake/yardoc_task"
YARD::Rake::YardocTask.new do |y|
  y.options << "--fail-on-warning"
end

desc "Run yard-doctest example tests."
task :doctest do
  puts "The <%= gem.name %> gem does not have doctest tests."
end

desc "Run the CI build"
task :ci do
  header "BUILDING <%= gem.name %>"
  header "<%= gem.name %> rubocop", "*"
  Rake::Task[:rubocop].invoke
  header "<%= gem.name %> yard", "*"
  Rake::Task[:yard].invoke
  header "<%= gem.name %> test", "*"
  Rake::Task[:test].invoke
end

namespace :ci do
  task :acceptance do
  end
  task :a do
  end
end

task default: :test

def header str, token = "#"
  line_length = str.length + 8
  puts ""
  puts token * line_length
  puts "#{token * 3} #{str} #{token * 3}"
  puts token * line_length
  puts ""
end