Class: Guard::Jasmine
- Inherits:
-
Guard
- Object
- Guard
- Guard::Jasmine
- Extended by:
- Util
- Defined in:
- lib/guard/jasmine.rb,
lib/guard/jasmine/cli.rb,
lib/guard/jasmine/util.rb,
lib/guard/jasmine/runner.rb,
lib/guard/jasmine/server.rb,
lib/guard/jasmine/formatter.rb,
lib/guard/jasmine/inspector.rb
Overview
The Jasmine guard that gets notifications about the following
Guard events: start, stop, reload, run_all and run_on_change.
Defined Under Namespace
Modules: Formatter, Inspector, Runner, Server, Util Classes: CLI
Constant Summary
- DEFAULT_OPTIONS =
{ server: :auto, server_env: ENV['RAILS_ENV'] || 'development', server_timeout: 60, port: nil, rackup_config: nil, jasmine_url: nil, timeout: 60, spec_dir: nil, notification: true, hide_success: false, all_on_start: true, keep_failed: true, clean: true, all_after_pass: true, max_error_notify: 3, specdoc: :failure, console: :failure, errors: :failure, focus: true, coverage: false, coverage_html: false, coverage_html_dir: "./coverage", coverage_summary: false, statements_threshold: 0, functions_threshold: 0, branches_threshold: 0, lines_threshold: 0 }
Instance Attribute Summary (collapse)
-
- (Object) last_failed_paths
Returns the value of attribute last_failed_paths.
-
- (Object) last_run_failed
Returns the value of attribute last_run_failed.
-
- (Object) run_all_options
Returns the value of attribute run_all_options.
Instance Method Summary (collapse)
-
- (Jasmine) initialize(watchers = [], options = { })
constructor
Initialize Guard::Jasmine.
-
- (Object) reload
Gets called when the Guard should reload itself.
-
- (Object) run_all
Gets called when all specs should be run.
-
- (Object) run_on_changes(paths)
Gets called when watched paths and files have changes.
-
- (Object) start
Gets called once when Guard starts.
-
- (Object) stop
Gets called once when Guard stops.
Methods included from Util
find_free_server_port, phantomjs_bin_valid?, runner_available?, which
Constructor Details
- (Jasmine) initialize(watchers = [], options = { })
Initialize Guard::Jasmine.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/guard/jasmine.rb', line 87 def initialize(watchers = [], = { }) = DEFAULT_OPTIONS.merge() [:spec_dir] ||= File.exists?(File.join('spec', 'javascripts')) ? File.join('spec', 'javascripts') : 'spec' [:port] ||= Jasmine.find_free_server_port [:server] ||= :auto [:server] = ::Guard::Jasmine::Server.detect_server([:spec_dir]) if [:server] == :auto [:jasmine_url] = "http://localhost:#{ [:port] }#{ [:server] == :jasmine_gem ? '/' : '/jasmine' }" unless [:jasmine_url] [:specdoc] = :failure if ![:always, :never, :failure].include? [:specdoc] [:phantomjs_bin] = Jasmine.which('phantomjs') unless [:phantomjs_bin] self. = .delete(:run_all) || { } super(watchers, ) self.last_run_failed = false self.last_failed_paths = [] end |
Instance Attribute Details
- (Object) last_failed_paths
Returns the value of attribute last_failed_paths
22 23 24 |
# File 'lib/guard/jasmine.rb', line 22 def last_failed_paths @last_failed_paths end |
- (Object) last_run_failed
Returns the value of attribute last_run_failed
22 23 24 |
# File 'lib/guard/jasmine.rb', line 22 def last_run_failed @last_run_failed end |
- (Object) run_all_options
Returns the value of attribute run_all_options
22 23 24 |
# File 'lib/guard/jasmine.rb', line 22 def @run_all_options end |
Instance Method Details
- (Object) reload
Gets called when the Guard should reload itself.
135 136 137 138 |
# File 'lib/guard/jasmine.rb', line 135 def reload self.last_run_failed = false self.last_failed_paths = [] end |
- (Object) run_all
Gets called when all specs should be run.
144 145 146 147 148 149 150 151 |
# File 'lib/guard/jasmine.rb', line 144 def run_all passed, failed_specs = Runner.run([[:spec_dir]], .merge(self.)) self.last_failed_paths = failed_specs self.last_run_failed = !passed throw :task_has_failed unless passed end |
- (Object) run_on_changes(paths)
Gets called when watched paths and files have changes.
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/guard/jasmine.rb', line 158 def run_on_changes(paths) specs = [:keep_failed] ? paths + self.last_failed_paths : paths specs = Inspector.clean(specs, ) if [:clean] return false if specs.empty? passed, failed_specs = Runner.run(specs, ) if passed self.last_failed_paths = self.last_failed_paths - paths run_all if self.last_run_failed && [:all_after_pass] else self.last_failed_paths = self.last_failed_paths + failed_specs end self.last_run_failed = !passed throw :task_has_failed unless passed end |
- (Object) start
Gets called once when Guard starts.
110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/guard/jasmine.rb', line 110 def start if Jasmine.phantomjs_bin_valid?([:phantomjs_bin]) Server.start() unless [:server] == :none if Jasmine.runner_available?() run_all if [:all_on_start] end else throw :task_has_failed end end |
- (Object) stop
Gets called once when Guard stops.
127 128 129 |
# File 'lib/guard/jasmine.rb', line 127 def stop Server.stop unless [:server] == :none end |