guard-phantomjs-jasmine 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/Gemfile +15 -0
- data/Guardfile +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +72 -0
- data/Rakefile +21 -0
- data/guard-phantomjs-jasmine.gemspec +27 -0
- data/lib/guard/phantomjs-jasmine.rb +57 -0
- data/lib/guard/phantomjs-jasmine/cli.rb +73 -0
- data/lib/guard/phantomjs-jasmine/js/console_json_reporter.js +74 -0
- data/lib/guard/phantomjs-jasmine/js/jasmine_runner.coffee +28 -0
- data/lib/guard/phantomjs-jasmine/task.rb +49 -0
- data/lib/guard/phantomjs-jasmine/templates/Guardfile +4 -0
- data/spec/guard/phantomjs-jasmine_spec.rb +95 -0
- data/spec/spec_helper.rb +8 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 48928802607fd6aa08d3923da19cca1b34768ba6
|
4
|
+
data.tar.gz: b609c7140a2d62a0fb6bc68eb267ef27da4cd939
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a42058b63d5165c35a67379985bc588b3fd3fb134ae8b4e82189524c283189d7b3f5a0a4c64e212e6617ce905284ccb6ff58aa162222256557f56b4ddd32aef9
|
7
|
+
data.tar.gz: 58b7c95bd227fb0f9aeb0e34bd8a93b6feb99b95dcea7b182a7f111e5c9691ca41d8943594ed21b72f82c20df9fb6455bff0bc1827dc3e7122212e1cf4765b76
|
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in guard-phantomjs-jasmine.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
require 'rbconfig'
|
7
|
+
|
8
|
+
if RbConfig::CONFIG['target_os'] =~ /darwin/i
|
9
|
+
gem 'rb-fsevent'
|
10
|
+
gem 'growl'
|
11
|
+
end
|
12
|
+
if RbConfig::CONFIG['target_os'] =~ /linux/i
|
13
|
+
gem 'rb-inotify'
|
14
|
+
gem 'libnotify'
|
15
|
+
end
|
data/Guardfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Stas Suscov
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
= guard-phantomjs-jasmine
|
2
|
+
|
3
|
+
{<img src="https://secure.travis-ci.org/stas/guard-phantomjs-jasmine.png" alt="Build Status" />}[http://travis-ci.org/stas/guard-phantomjs-jasmine]
|
4
|
+
|
5
|
+
PhantomJS Jasmine Guard automatically runs Jasmine specs with PhantomJS. It executes the tests and displays the test result.
|
6
|
+
No webserver is required!
|
7
|
+
|
8
|
+
== Install
|
9
|
+
|
10
|
+
Please be sure to have {Guard}[https://github.com/guard/guard] installed before continue.
|
11
|
+
|
12
|
+
Add guard definition to your Guardfile by running this command:
|
13
|
+
|
14
|
+
guard init phantomjs-jasmine
|
15
|
+
|
16
|
+
You will need the Jasmine html runner next. If you have it already, just update your Guardfile pointing :runner to the relevant html file.
|
17
|
+
|
18
|
+
== Usage
|
19
|
+
|
20
|
+
Please read {Guard usage doc}[https://github.com/guard/guard#readme]
|
21
|
+
|
22
|
+
== CI usecase
|
23
|
+
|
24
|
+
You can use builtin rake task if you want to run your specs with Rake
|
25
|
+
|
26
|
+
Create a Rakefile with the following
|
27
|
+
|
28
|
+
require 'guard/phantomjs-jasmine/task'
|
29
|
+
Guard::PhantomJsJasmineTask.new
|
30
|
+
|
31
|
+
if you want to customize the task, you can use options
|
32
|
+
|
33
|
+
require 'guard/phantomjs-jasmine/task'
|
34
|
+
Guard::PhantomJsJasmineTask.new(:ci) do |task|
|
35
|
+
task.options[:runner] = 'path/to/jasmine.html'
|
36
|
+
task.options[:runner_script] = 'path/to/runner.coffee'
|
37
|
+
end
|
38
|
+
|
39
|
+
== Options
|
40
|
+
|
41
|
+
The location of the test runner:
|
42
|
+
|
43
|
+
guard 'phantomjs-jasmine', :runner => '...' do
|
44
|
+
...
|
45
|
+
end
|
46
|
+
|
47
|
+
== AMD / Require.js support
|
48
|
+
|
49
|
+
To make sure the Jasmine is initialized correctly
|
50
|
+
before any test gets executed, we need to detect when Jasmine is loaded.
|
51
|
+
|
52
|
+
Add this callback:
|
53
|
+
|
54
|
+
if ( window['beforeJasmineExecution'] ) {
|
55
|
+
beforeJasmineExecution();
|
56
|
+
}
|
57
|
+
|
58
|
+
right before:
|
59
|
+
|
60
|
+
jasmineEnv.execute();
|
61
|
+
|
62
|
+
== Development
|
63
|
+
|
64
|
+
- Report issues, questions, feature requests on {GitHub Issues}[https://github.com/stas/guard-phantomjs-jasmine/issues]
|
65
|
+
|
66
|
+
Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change you make.
|
67
|
+
|
68
|
+
== Authors
|
69
|
+
|
70
|
+
{Stas Suscov}[https://github.com/stas]
|
71
|
+
|
72
|
+
Thanks to {Klaus Hartl}[https://github.com/carhartl] for guard-phantomjs project.
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
RSpec::Core::RakeTask.new(:spec)
|
6
|
+
task :default => :spec
|
7
|
+
|
8
|
+
namespace(:spec) do
|
9
|
+
desc "Run all specs on multiple ruby versions (requires rvm)"
|
10
|
+
task(:portability) do
|
11
|
+
%w[1.8.6 1.8.7 1.9.2].each do |version|
|
12
|
+
system <<-BASH
|
13
|
+
bash -c 'source ~/.rvm/scripts/rvm;
|
14
|
+
rvm #{version};
|
15
|
+
echo "--------- version #{version} ----------\n";
|
16
|
+
bundle install;
|
17
|
+
rake spec'
|
18
|
+
BASH
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'guard-phantomjs-jasmine'
|
6
|
+
s.version = '0.0.1'
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ['Stas Suscov']
|
9
|
+
s.email = ['stas@nerd.ro']
|
10
|
+
s.homepage = 'http://github.com/stas/guard-phantomjs-jasmine'
|
11
|
+
s.summary = 'Guard for running Jasmine specs using PhantomJS'
|
12
|
+
s.description = 'PhantomJS guard allows to automatically run PhantomJS (headless, WebKit-based browser) Jasmine specs.'
|
13
|
+
|
14
|
+
s.rubyforge_project = 'guard-phantomjs-jasmine'
|
15
|
+
|
16
|
+
s.add_dependency 'guard'
|
17
|
+
|
18
|
+
s.add_development_dependency 'bundler'
|
19
|
+
s.add_development_dependency 'rake'
|
20
|
+
s.add_development_dependency 'rspec'
|
21
|
+
s.add_development_dependency 'guard-rspec'
|
22
|
+
|
23
|
+
s.files = `git ls-files`.split("\n")
|
24
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
25
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
26
|
+
s.require_paths = ['lib']
|
27
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'guard'
|
2
|
+
require 'guard/plugin'
|
3
|
+
require 'guard/phantomjs-jasmine/cli'
|
4
|
+
|
5
|
+
module Guard
|
6
|
+
class PhantomJsJasmine < Plugin
|
7
|
+
include PhantomJsJasmineCli
|
8
|
+
|
9
|
+
# Initialize Guard::PhantomJsJasmine
|
10
|
+
#
|
11
|
+
# @param [Hash] options the options for the Guard
|
12
|
+
# @option options [String] :runner_script, path to the runner script
|
13
|
+
# @option options [String] :runner, path to the jasmine runner
|
14
|
+
def initialize(options = {})
|
15
|
+
super
|
16
|
+
|
17
|
+
@options = options
|
18
|
+
end
|
19
|
+
|
20
|
+
# Gets called once when Guard starts.
|
21
|
+
def start
|
22
|
+
::Guard::UI.info( "#{self.class} is running!" )
|
23
|
+
end
|
24
|
+
|
25
|
+
# Gets called when watched paths and files have changes.
|
26
|
+
#
|
27
|
+
# @param [Array<String>] paths the changed paths and files
|
28
|
+
def run_on_change(paths)
|
29
|
+
return if paths.empty?
|
30
|
+
|
31
|
+
run(@options)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
# Wrapper against Guard::Notifier#notify
|
37
|
+
# @param [String] message, the text to output
|
38
|
+
# @param [Symbol] image, the text image
|
39
|
+
def notify(message, image)
|
40
|
+
::Guard::Notifier.notify(
|
41
|
+
message, :title => 'PhantomJS Jasmine Guard', :image => image)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Wrapper against Guard::UI#error
|
45
|
+
# @param [String] message, the text to output
|
46
|
+
def error(message)
|
47
|
+
::Guard::UI.error(message)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Wrapper against Guard::UI#info
|
51
|
+
# @param [String] message, the text to output
|
52
|
+
def info(message)
|
53
|
+
::Guard::UI.info(message)
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Guard
|
4
|
+
# PhantomJS Jasmine command line utils
|
5
|
+
#
|
6
|
+
module PhantomJsJasmineCli
|
7
|
+
|
8
|
+
# Command line runner
|
9
|
+
# Separated from guard so it's possible to be used in rake tasks too
|
10
|
+
# @param [Hash] options, to be passed to phantomjs
|
11
|
+
#
|
12
|
+
def run(options)
|
13
|
+
options[:runner] ||= 'spec/runner.html'
|
14
|
+
options[:runner_script] ||= File.expand_path(
|
15
|
+
'js/jasmine_runner.coffee',
|
16
|
+
File.dirname(__FILE__))
|
17
|
+
|
18
|
+
cmd = "phantomjs #{options[:runner_script]} #{options[:runner]}"
|
19
|
+
result = IO.popen(cmd)
|
20
|
+
|
21
|
+
begin
|
22
|
+
parsed_result = JSON.parse(result.read, {
|
23
|
+
:max_nesting => false, :symbolize_names => true })
|
24
|
+
result.close
|
25
|
+
rescue Exception => exc
|
26
|
+
error(exc.message)
|
27
|
+
return
|
28
|
+
end
|
29
|
+
|
30
|
+
passed = parsed_result[:passed]
|
31
|
+
failed = parsed_result[:total] - passed
|
32
|
+
run_time = (parsed_result[:ended] - parsed_result[:started]).round(3)
|
33
|
+
|
34
|
+
parsed_result[:suites].each do |suite|
|
35
|
+
msg = "\n" + "#{suite[:desc]} #{suite[:name]}\n\t#{suite[:spec]}".lstrip
|
36
|
+
|
37
|
+
if suite[:passed]
|
38
|
+
info( msg )
|
39
|
+
else
|
40
|
+
error( "#{msg}\n\t\t#{suite[:trace]}" )
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
if failed > 0
|
45
|
+
notify("#{failed} Jasmine spec(s) failed.", :failed)
|
46
|
+
info("\n#{failed}/#{parsed_result[:total]} failed in #{run_time} ms.")
|
47
|
+
else
|
48
|
+
notify("Jasmine specs passed.", :success)
|
49
|
+
info("\n#{parsed_result[:total]} passed in #{run_time} ms.")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Helper to output info messages
|
54
|
+
# @param [String] msg, the text to output
|
55
|
+
def info(msg)
|
56
|
+
puts msg
|
57
|
+
end
|
58
|
+
|
59
|
+
# Helper to output error messages, colors in red
|
60
|
+
# @param [String] msg, the text to output
|
61
|
+
def error(msg)
|
62
|
+
puts "\e[0;31m#{ msg }\e[0m"
|
63
|
+
end
|
64
|
+
|
65
|
+
# Helper to send notifications, not implemented
|
66
|
+
# We don't use notify in CLI sessions
|
67
|
+
# @param [String] msg, the text to output
|
68
|
+
# @param [Symbol] image, the text image
|
69
|
+
def notify(msg, image)
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
/**
|
2
|
+
* Jasmine JSON Console Reporter
|
3
|
+
* Uses console.log to output JSONified Jasmine results
|
4
|
+
*/
|
5
|
+
(function(window, console) {
|
6
|
+
/**
|
7
|
+
* Console Reporter constructor
|
8
|
+
*/
|
9
|
+
var ConsoleReporter = function() {};
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Reporter prototype
|
13
|
+
*/
|
14
|
+
ConsoleReporter.prototype = {
|
15
|
+
/**
|
16
|
+
* Instance storage for result details
|
17
|
+
*/
|
18
|
+
results: {
|
19
|
+
started: (new Date()).getTime(),
|
20
|
+
ended: null,
|
21
|
+
total: 0,
|
22
|
+
passed: 0,
|
23
|
+
suites: []
|
24
|
+
},
|
25
|
+
|
26
|
+
/**
|
27
|
+
* Is called when runner is done.
|
28
|
+
* Outputs the stringified `results` value
|
29
|
+
* Ends with the exit code.
|
30
|
+
*/
|
31
|
+
reportRunnerResults: function() {
|
32
|
+
this.results.ended = (new Date()).getTime();
|
33
|
+
var return_code = 0;
|
34
|
+
|
35
|
+
if ( this.results.total - this.results.passed !== 0 ) {
|
36
|
+
return_code = 1;
|
37
|
+
}
|
38
|
+
|
39
|
+
console.log( JSON.stringify(this.results) );
|
40
|
+
console.log('EXIT ' + return_code);
|
41
|
+
},
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Is called when a spec is processed
|
45
|
+
* Stores all the details in `results` attribute
|
46
|
+
*/
|
47
|
+
reportSpecResults: function( spec ) {
|
48
|
+
var spec_result, items;
|
49
|
+
|
50
|
+
this.results.total++;
|
51
|
+
|
52
|
+
if (spec.results().passed()) {
|
53
|
+
this.results.passed++;
|
54
|
+
}
|
55
|
+
|
56
|
+
spec_result = {
|
57
|
+
desc: spec.suite.parentSuite ? spec.suite.parentSuite.description : '',
|
58
|
+
name: spec.suite.description,
|
59
|
+
spec: spec.description,
|
60
|
+
passed: spec.results().passed(),
|
61
|
+
trace: null
|
62
|
+
};
|
63
|
+
|
64
|
+
items = spec.results().getItems()
|
65
|
+
spec_result.trace = items[0].trace.message || items[0].trace;
|
66
|
+
|
67
|
+
this.results.suites.push( spec_result );
|
68
|
+
}
|
69
|
+
|
70
|
+
};
|
71
|
+
|
72
|
+
// Exposes Console Reporter class
|
73
|
+
window.ConsoleReporter = ConsoleReporter;
|
74
|
+
})(window, console);
|
@@ -0,0 +1,28 @@
|
|
1
|
+
if phantom.args.length == 0
|
2
|
+
console.log 'Missing mandatory parameter.'
|
3
|
+
phantom.exit 1
|
4
|
+
|
5
|
+
runner = phantom.args[0]
|
6
|
+
page = new WebPage()
|
7
|
+
|
8
|
+
page.onInitialized = ->
|
9
|
+
page.injectJs 'console_json_reporter.js'
|
10
|
+
page.evaluate ->
|
11
|
+
window.onload = ->
|
12
|
+
# If this is an AMD environment, add console reporter using a callback
|
13
|
+
if ( window['define'] )
|
14
|
+
window.beforeJasmineExecution = ->
|
15
|
+
jasmine.getEnv().addReporter( new ConsoleReporter )
|
16
|
+
else
|
17
|
+
jasmine.getEnv().addReporter( new ConsoleReporter )
|
18
|
+
|
19
|
+
page.onConsoleMessage = (msg) ->
|
20
|
+
if return_code = msg.match /EXIT (\d)/
|
21
|
+
phantom.exit(return_code[1])
|
22
|
+
else
|
23
|
+
console.log msg
|
24
|
+
|
25
|
+
page.open runner, (status) ->
|
26
|
+
if status != 'success'
|
27
|
+
console.log 'File/URL can not be loaded.'
|
28
|
+
phantom.exit 1
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'rake/tasklib'
|
2
|
+
require 'guard/phantomjs-jasmine/cli'
|
3
|
+
|
4
|
+
module Guard
|
5
|
+
|
6
|
+
# Provides a method to define a Rake task that
|
7
|
+
# runs the PhatomJS Jasmine specs.
|
8
|
+
#
|
9
|
+
class PhantomJsJasmineTask < ::Rake::TaskLib
|
10
|
+
include ::Guard::PhantomJsJasmineCli
|
11
|
+
|
12
|
+
# Name of the main, top level task
|
13
|
+
attr_accessor :name
|
14
|
+
|
15
|
+
# CLI options
|
16
|
+
attr_accessor :options
|
17
|
+
|
18
|
+
# Initialize the Rake task
|
19
|
+
#
|
20
|
+
# @param [Symbol] name the name of the Rake task
|
21
|
+
# @param [Hash] options the CLI options
|
22
|
+
# @yield [PhantomJsJasmineTask] the task
|
23
|
+
#
|
24
|
+
def initialize(name = 'jasmine:ci', options = {})
|
25
|
+
@name = name
|
26
|
+
@options = options
|
27
|
+
|
28
|
+
yield self if block_given?
|
29
|
+
|
30
|
+
namespace :phantomjs do
|
31
|
+
desc 'Run all PhantomJS Jasmine specs'
|
32
|
+
task(name) do
|
33
|
+
begin
|
34
|
+
run(self.options)
|
35
|
+
|
36
|
+
rescue SystemExit => e
|
37
|
+
case e.status
|
38
|
+
when 1
|
39
|
+
fail 'Some specs have failed'
|
40
|
+
when 2
|
41
|
+
fail "The spec couldn't be run: #{ e.message }'"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Guard
|
4
|
+
describe PhantomJsJasmine do
|
5
|
+
|
6
|
+
describe "#run_on_change" do
|
7
|
+
|
8
|
+
context "with modifications" do
|
9
|
+
let(:mock_results) {
|
10
|
+
{
|
11
|
+
:passed => 1,
|
12
|
+
:total => 1,
|
13
|
+
:started => Time.now.to_f,
|
14
|
+
:ended => Time.now.to_f,
|
15
|
+
:suites => [{
|
16
|
+
:name => 'Suite',
|
17
|
+
:spec => 'Spec',
|
18
|
+
:passed => false,
|
19
|
+
:trace => { :message => 'Error Message' }
|
20
|
+
}]
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
it "executes phantomjs" do
|
25
|
+
Notifier.stub(:notify)
|
26
|
+
guard = PhantomJsJasmine.new({
|
27
|
+
:runner => 'spec/run.html',
|
28
|
+
:runner_script => 'run.coffee'
|
29
|
+
})
|
30
|
+
|
31
|
+
io_mock = double('IO Connection').as_null_object
|
32
|
+
IO.should_receive(:popen).with(
|
33
|
+
'phantomjs run.coffee spec/run.html'
|
34
|
+
).and_return(io_mock)
|
35
|
+
|
36
|
+
JSON.should_receive(:parse).and_return(mock_results)
|
37
|
+
|
38
|
+
guard.should_receive(:error)
|
39
|
+
|
40
|
+
guard.run_on_change(['foo'])
|
41
|
+
end
|
42
|
+
|
43
|
+
it "notifies on success" do
|
44
|
+
io_mock = double('IO Connection').as_null_object
|
45
|
+
io_mock.should_receive(:read).and_return(mock_results.to_json)
|
46
|
+
IO.should_receive(:popen).and_return(io_mock)
|
47
|
+
|
48
|
+
Notifier.should_receive(:notify).with('Jasmine specs passed.',
|
49
|
+
:title => 'PhantomJS Jasmine Guard', :image => :success)
|
50
|
+
|
51
|
+
subject.should_receive(:info)
|
52
|
+
subject.should_receive(:error)
|
53
|
+
|
54
|
+
subject.run_on_change(['foo'])
|
55
|
+
end
|
56
|
+
|
57
|
+
it "notifies on failures" do
|
58
|
+
failed_mock_results = mock_results
|
59
|
+
failed_mock_results[:passed] = 0
|
60
|
+
|
61
|
+
io_mock = double('IO Connection').as_null_object
|
62
|
+
io_mock.should_receive(:read).and_return(mock_results.to_json)
|
63
|
+
IO.should_receive(:popen).and_return(io_mock)
|
64
|
+
|
65
|
+
subject.should_receive(:error)
|
66
|
+
subject.should_receive(:info)
|
67
|
+
|
68
|
+
Notifier.should_receive(:notify).with('1 Jasmine spec(s) failed.',
|
69
|
+
:title => 'PhantomJS Jasmine Guard', :image => :failed)
|
70
|
+
|
71
|
+
subject.run_on_change(['foo'])
|
72
|
+
end
|
73
|
+
|
74
|
+
it "handles invalid phantomjs return data" do
|
75
|
+
io_mock = double('IO Connection').as_null_object
|
76
|
+
io_mock.should_receive(:read).and_return('THIS IS WRONG!')
|
77
|
+
IO.should_receive(:popen).and_return(io_mock)
|
78
|
+
|
79
|
+
subject.should_receive(:error)
|
80
|
+
|
81
|
+
subject.run_on_change(['foo'])
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context "without modifications" do
|
86
|
+
it "skips executing phantomjs" do
|
87
|
+
IO.should_not_receive(:popen)
|
88
|
+
subject.run_on_change([])
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'guard/phantomjs-jasmine'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: guard-phantomjs-jasmine
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stas Suscov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: guard
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard-rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: PhantomJS guard allows to automatically run PhantomJS (headless, WebKit-based
|
84
|
+
browser) Jasmine specs.
|
85
|
+
email:
|
86
|
+
- stas@nerd.ro
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- .gitignore
|
92
|
+
- Gemfile
|
93
|
+
- Guardfile
|
94
|
+
- LICENSE
|
95
|
+
- README.rdoc
|
96
|
+
- Rakefile
|
97
|
+
- guard-phantomjs-jasmine.gemspec
|
98
|
+
- lib/guard/phantomjs-jasmine.rb
|
99
|
+
- lib/guard/phantomjs-jasmine/cli.rb
|
100
|
+
- lib/guard/phantomjs-jasmine/js/console_json_reporter.js
|
101
|
+
- lib/guard/phantomjs-jasmine/js/jasmine_runner.coffee
|
102
|
+
- lib/guard/phantomjs-jasmine/task.rb
|
103
|
+
- lib/guard/phantomjs-jasmine/templates/Guardfile
|
104
|
+
- spec/guard/phantomjs-jasmine_spec.rb
|
105
|
+
- spec/spec_helper.rb
|
106
|
+
homepage: http://github.com/stas/guard-phantomjs-jasmine
|
107
|
+
licenses: []
|
108
|
+
metadata: {}
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project: guard-phantomjs-jasmine
|
125
|
+
rubygems_version: 2.0.3
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: Guard for running Jasmine specs using PhantomJS
|
129
|
+
test_files: []
|