Class: Guard::JasmineTask

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/guard/jasmine/task.rb

Overview

Provides a method to define a Rake task that runs the Jasmine specs.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = :jasmine, options = '') {|JasmineTask| ... } ⇒ JasmineTask

Initialize the Rake task

Parameters:

  • name (Symbol) (defaults to: :jasmine)

    the name of the Rake task

  • options (String) (defaults to: '')

    the CLI options

Yields:



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/guard/jasmine/task.rb', line 25

def initialize(name = :jasmine, options = '')
  @name    = name
  @options = options

  yield self if block_given?

  namespace :guard do
    desc 'Run all Jasmine specs'
    task(name) do
      begin
        ::Guard::Jasmine::CLI.start(self.options.split)

      rescue SystemExit => e
        case e.status
        when 1
          raise 'Some specs have failed'
        when 2
          raise "The spec couldn't be run: #{e.message}'"
        end
      end
    end
  end
end

Instance Attribute Details

#nameObject

Name of the main, top level task



14
15
16
# File 'lib/guard/jasmine/task.rb', line 14

def name
  @name
end

#optionsObject

CLI options



17
18
19
# File 'lib/guard/jasmine/task.rb', line 17

def options
  @options
end