Class: Guard::PhantomJsJasmineTask

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

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PhantomJsJasmineCli

#error, #info, #notify, #run

Constructor Details

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

Initialize the Rake task

Parameters:

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

    the name of the Rake task

  • options (Hash) (defaults to: {})

    the CLI options

Yields:



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

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

  yield self if block_given?

  namespace :phantomjs do
    desc 'Run all PhantomJS Jasmine specs'
    task(name) do
      begin
        run(self.options)

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

Instance Attribute Details

#nameObject

Name of the main, top level task



13
14
15
# File 'lib/guard/phantomjs-jasmine/task.rb', line 13

def name
  @name
end

#optionsObject

CLI options



16
17
18
# File 'lib/guard/phantomjs-jasmine/task.rb', line 16

def options
  @options
end