class Guard::Jasmine::CLI
Small helper class to run the Jasmine
runner_options
once from the command line. This can be useful to integrate guard-jasmine into a continuous integration server.
This outputs the specdoc and disables any notifications.
Public Instance Methods
spec(*paths)
click to toggle source
Run the Guard::Jasmine::Runner
with options from the command line.
@param [Array<String>] paths the name of the specs to run
# File lib/guard/jasmine/cli.rb, line 164 def spec(*paths) options = runner_options paths = [options[:spec_dir]] if paths.empty? if CLI.phantomjs_bin_valid?(options[:phantomjs_bin]) catch(:task_has_failed) do ::Guard::Jasmine::Server.start(options) unless options[:server] == :none end if CLI.runner_available?(options) result = ::Guard::Jasmine::Runner.new(options).run(paths) ::Guard::Jasmine::Server.stop Process.exit result.empty? ? 0 : 1 else Process.exit 2 end else Process.exit 2 end rescue => e Compat::UI.error "Something went wrong: #{e.message}" Process.exit 2 ensure ::Guard::Jasmine::Server.stop end
version()
click to toggle source
Shows the current version of Guard::Jasmine
.
@see Guard::Jasmine::VERSION
# File lib/guard/jasmine/cli.rb, line 197 def version Compat::UI.info "Guard::Jasmine version #{::Guard::JasmineVersion::VERSION}" end
Private Instance Methods
runner_options()
click to toggle source
# File lib/guard/jasmine/cli.rb, line 203 def runner_options ro = {} ro[:port] = options.port || CLI.find_free_server_port ro[:spec_dir] = options.spec_dir || (File.exist?(File.join('spec', 'javascripts')) ? File.join('spec', 'javascripts') : 'spec') ro[:line_number] = options.line_number ro[:server] = options.server.to_sym == :auto ? ::Guard::Jasmine::Server.detect_server(ro[:spec_dir]) : options.server.to_sym ro[:server_mount] = options.mount || (defined?(JasmineRails) ? '/specs' : '/jasmine') ro[:jasmine_url] = options.url || "http://localhost:#{ro[:port]}#{options.server.to_sym == :jasmine_gem ? '/' : ro[:server_mount]}" ro[:phantomjs_bin] = options.bin || CLI.which('phantomjs') ro[:timeout] = options.timeout ro[:verbose] = options.verbose ro[:server_env] = options.server_env ro[:server_timeout] = options.server_timeout ro[:rackup_config] = options.rackup_config ro[:console] = [:always, :never, :failure].include?(options.console.to_sym) ? options.console.to_sym : :failure ro[:errors] = [:always, :never, :failure].include?(options.errors.to_sym) ? options.errors.to_sym : :failure ro[:specdoc] = [:always, :never, :failure].include?(options.specdoc.to_sym) ? options.specdoc.to_sym : :always ro[:focus] = options.focus ro[:coverage] = options.coverage || options.coverage_html || options.coverage_summary || options.coverage_html_dir != './coverage' ro[:coverage_html] = options.coverage_html || options.coverage_html_dir != './coverage' ro[:coverage_html_dir] = options.coverage_html_dir ro[:coverage_summary] = options.coverage_summary ro[:ignore_instrumentation] = options.ignore_instrumentation ro[:statements_threshold] = options.statements_threshold ro[:functions_threshold] = options.functions_threshold ro[:branches_threshold] = options.branches_threshold ro[:lines_threshold] = options.lines_threshold ro[:notification] = false ro[:hide_success] = true ro[:max_error_notify] = 0 ro[:query_params] = options.reporters ? { reporters: options.reporters } : nil ro[:is_cli] = true ro end