Class: GemOf::TestTasks

Inherits:
Object
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/gem_of/rake_tasks.rb

Overview

unit testing tasks

Instance Method Summary collapse

Constructor Details

#initializeTestTasks

instance unit tasks in namespace :test

Examples:

TestTasks.new




201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/gem_of/rake_tasks.rb', line 201

def initialize
  namespace :test do
    begin
      # this will produce the 'test:spec' task
      require "rspec/core/rake_task"
      desc "Run unit tests"
      RSpec::Core::RakeTask.new do |t|
        t.rspec_opts = ["--color"]
        t.pattern = ENV["SPEC_PATTERN"]
      end
      # if rspec isn't available, we can still use this Rakefile
      # rubocop:disable Lint/HandleExceptions
    rescue LoadError
    end

    task spec: [:check_spec]

    desc "" # empty description so it doesn't show up in rake -T
    rototiller_task :check_spec do |t|
      t.add_env(name: "SPEC_PATTERN", default: "spec/",
                message: "The pattern RSpec will use to find tests")
    end
  end
end