Module: Assert::RakeTasks

Includes:
Rake::DSL
Defined in:
lib/assert/rake_tasks.rb,
lib/assert/rake_tasks.rb,
lib/assert/rake_tasks/irb.rb,
lib/assert/rake_tasks/scope.rb,
lib/assert/rake_tasks/test_task.rb

Defined Under Namespace

Classes: Irb, Scope, TestTask

Class Method Summary collapse

Class Method Details

.for(test_root_name) ⇒ Object



30
31
32
# File 'lib/assert/rake_tasks.rb', line 30

def self.for(test_root_name)
  warn "[DEPRECATED] `Assert::RakeTasts.for` has been deprecated.  Use `Assert::RakeTasks.install` instead."
end

.included(receiver) ⇒ Object

Setup the rake tasks for testing

  • add ‘include Assert::RakeTasks’ to your Rakefile



14
15
16
17
# File 'lib/assert/rake_tasks.rb', line 14

def self.included(receiver)
  # auto-install rake tasks
  self.install
end

.installObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/assert/rake_tasks.rb', line 19

def self.install
  warn "[DEPRECATED] `Assert::RakeTasts` has been deprecated.  Support for running tests with Rake will be removed in v2.0.  Use the assert CLI instead."

  assert_test_root = ENV['ASSERT_TEST_ROOT'] || './test'

  if File.exists?(assert_test_root)
    self.irb_task(Assert::RakeTasks::Irb.new(assert_test_root))
    self.to_tasks(Assert::RakeTasks::Scope.new(assert_test_root))
  end
end

.irb_task(irb) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/assert/rake_tasks.rb', line 37

def irb_task(irb)
  if irb.helper_exists?
    desc irb.description
    task irb.class.task_name do
      sh irb.cmd
    end
  end
end

.to_tasks(scope) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/assert/rake_tasks.rb', line 46

def to_tasks(scope)
  # if there is a test task for the scope
  if (scope_tt = scope.to_test_task)
    # create a rake task to run it
    desc scope_tt.description
    task scope_tt.name do
      RakeFileUtils.verbose(scope_tt.show_loaded_files?) { ruby scope_tt.ruby_args }
    end
  end

  # create a namespace for the scope
  namespace scope.namespace do
    # for each test task in the scope, create a rake task to run it
    scope.test_tasks.each do |test_file_tt|
      desc test_file_tt.description
      task test_file_tt.name do
        RakeFileUtils.verbose(test_file_tt.show_loaded_files?) { ruby test_file_tt.ruby_args }
      end
    end

    # recusively generate rake tasks for each sub-scope in the scope
    scope.scopes.each do |sub_scope|
      self.to_tasks(sub_scope)
    end
  end

end