Module: Bones::Plugins::Test

Extended by:
Test
Includes:
Helpers
Included in:
Test
Defined in:
lib/bones/plugins/test.rb

Constant Summary

Constants included from Helpers

Helpers::DEV_NULL, Helpers::GEM, Helpers::HAVE, Helpers::HAVE_SVN, Helpers::RCOV, Helpers::RDOC, Helpers::SUDO

Instance Method Summary collapse

Methods included from Helpers

#find_file, #have?, #paragraphs_of, #quiet, #remove_desc_for_task

Instance Method Details

#define_tasksObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/bones/plugins/test.rb', line 37

def define_tasks
  return unless have? :test
  config = ::Bones.config

  namespace :test do
    Rake::TestTask.new(:run) do |t|
      t.libs = config.libs
      t.test_files = if test(?f, config.test.file) then [config.test.file]
                     else config.test.files end
      t.ruby_opts += config.ruby_opts
      t.ruby_opts += config.test.opts
    end
  end  # namespace :test

  desc 'Alias to test:run'
  task :test => 'test:run'
end

#initialize_testObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/bones/plugins/test.rb', line 8

def initialize_test
  ::Bones.config {
    desc 'Configuration settings for the Ruby test framework.'
    test {
      files FileList['test/**/test_*.rb'], :desc => <<-__
        The list of test files to run. This defaults to all the ruby fines
        in the 'test' directory that start with 'test_' as their filename.
      __

      file 'test/all.rb', :desc => <<-__
        In fashion at one time was the concept of an encompassing test file
        that would run all ruby tests for your project. You can specify that
        file here. If the file does not exist this setting will be ignored.
      __

      opts [], :desc => <<-__
        Extra ruby options to be used when running tests.
      __
    }
  }
end

#post_loadObject



30
31
32
33
34
35
# File 'lib/bones/plugins/test.rb', line 30

def post_load
  config = ::Bones.config
  have?(:test) {
    Kernel.test(?e, config.test.file) or not config.test.files.to_a.empty?
  }
end