Class: YardExampleTest::RakeTask

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/yard_example_test/rake.rb

Overview

Rake task for running YARD @example tags as tests.

Examples:

Define the task with defaults

YardExampleTest::RakeTask.new

Define the task with custom options

YardExampleTest::RakeTask.new do |task|
  task.test_examples_opts = %w[-v]
  task.pattern = 'app/**/*.rb'
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = 'yard:test-examples') {|self| ... }

Creates and registers the Rake task

Examples:

YardExampleTest::RakeTask.new do |task|
  task.test_examples_opts = %w[-v]
  task.pattern = 'app/**/*.rb'
end

Parameters:

  • name (String) (defaults to: 'yard:test-examples')

    the Rake task name

Yields:

  • (self)

    gives the task instance to the block for configuration



67
68
69
70
71
72
73
74
# File 'lib/yard_example_test/rake.rb', line 67

def initialize(name = 'yard:test-examples')
  super()
  @name = name
  @test_examples_opts = []
  @pattern = ''
  yield self if block_given?
  define
end

Instance Attribute Details

#nameString

The name of the Rake task

Examples:

task = YardExampleTest::RakeTask.new
task.name #=> 'yard:test-examples'

Returns:

  • (String)

    the task name



29
30
31
# File 'lib/yard_example_test/rake.rb', line 29

def name
  @name
end

#patternString

Glob pattern for files to pass to +yard test-examples+

Examples:

task = YardExampleTest::RakeTask.new
task.pattern = 'app/**/*.rb'
task.pattern #=> 'app/**/*.rb'

Returns:

  • (String)

    the glob pattern, or an empty string to use the default



51
52
53
# File 'lib/yard_example_test/rake.rb', line 51

def pattern
  @pattern
end

#test_examples_optsArray<String>

Options passed to the +yard test-examples+ command

Examples:

task = YardExampleTest::RakeTask.new
task.test_examples_opts = %w[-v]
task.test_examples_opts #=> ['-v']

Returns:

  • (Array<String>)

    the command-line options



40
41
42
# File 'lib/yard_example_test/rake.rb', line 40

def test_examples_opts
  @test_examples_opts
end