guard-jasmine-headless-webkit 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/README.md +3 -1
- data/guard-jasmine-headless-webkit.gemspec +2 -1
- data/lib/guard/jasmine-headless-webkit.rb +40 -7
- data/lib/guard/jasmine-headless-webkit/runner.rb +9 -7
- data/lib/guard/jasmine-headless-webkit/version.rb +1 -1
- data/script/gemfile +11 -0
- data/script/hooks/pre-commit +15 -0
- data/script/initialize-environment +35 -0
- data/script/install-git-hooks +6 -0
- data/spec/lib/guard/jasmine-headless-webkit/runner_spec.rb +10 -7
- data/spec/lib/guard/jasmine-headless-webkit_spec.rb +79 -13
- data/spec/spec_helper.rb +2 -0
- metadata +11 -7
data/README.md
CHANGED
@@ -15,9 +15,11 @@ home folder's `.jasmine-headless-webkit` file.
|
|
15
15
|
## `guard` options
|
16
16
|
|
17
17
|
* `:all_on_start => false` to not run everything when starting, just like `guard-rspec`.
|
18
|
-
* `:run_before => "<command to run>"` to run a command before running specs. If the command fails, the test run stops.
|
19
18
|
* `:valid_extensions => %w{js coffee}` to only trigger `run_on_change` events for files with these extensions. Forces Guard to re-run all tests when any other matched file changes.
|
20
19
|
|
20
|
+
### Deprecated options
|
21
|
+
* `:run_before => "<command to run>"` to run a command before running specs. If the command fails, the test run stops.
|
22
|
+
|
21
23
|
## Using with Rails 3.1 and the Asset Pipeline and/or Jammit
|
22
24
|
|
23
25
|
Use [`guard-rails-assets`](https://github.com/dnagir/guard-rails-assets) chained in before `guard-jasmine-headless-webkit` to precompile your application
|
@@ -7,6 +7,11 @@ module Guard
|
|
7
7
|
class JasmineHeadlessWebkit < Guard
|
8
8
|
DEFAULT_EXTENSIONS = %w{js coffee}
|
9
9
|
|
10
|
+
ALL_SPECS_MESSAGE = "Guard::JasmineHeadlessWebkit running all specs..."
|
11
|
+
SOME_SPECS_MESSAGE = "Guard::JasmineHeadlessWebkit running the following: %s"
|
12
|
+
|
13
|
+
attr_reader :files_to_rerun
|
14
|
+
|
10
15
|
def initialize(watchers = [], options = {})
|
11
16
|
super
|
12
17
|
@options = {
|
@@ -14,6 +19,10 @@ module Guard
|
|
14
19
|
:run_before => false,
|
15
20
|
:valid_extensions => DEFAULT_EXTENSIONS
|
16
21
|
}.merge(options)
|
22
|
+
|
23
|
+
UI.deprecation ":run_before is deprecated. Use guard-shell to do something beforehand. This will be removed in a future release." if @options[:run_before]
|
24
|
+
|
25
|
+
@files_to_rerun = []
|
17
26
|
end
|
18
27
|
|
19
28
|
def start
|
@@ -21,11 +30,16 @@ module Guard
|
|
21
30
|
run_all if @options[:all_on_start]
|
22
31
|
end
|
23
32
|
|
33
|
+
def reload
|
34
|
+
@files_to_rerun = []
|
35
|
+
UI.info "Resetting Guard::JasmineHeadlessWebkit failed files..."
|
36
|
+
end
|
37
|
+
|
24
38
|
def run_all
|
25
39
|
run_something_and_rescue do
|
26
|
-
UI.info "Guard::JasmineHeadlessWebkit running all specs..."
|
27
|
-
JasmineHeadlessWebkitRunner.run if run_all_things_before
|
28
40
|
@ran_before = false
|
41
|
+
|
42
|
+
run_for_failed_files if run_all_things_before
|
29
43
|
end
|
30
44
|
end
|
31
45
|
|
@@ -36,8 +50,9 @@ module Guard
|
|
36
50
|
if run_all_things_before
|
37
51
|
@ran_before = true
|
38
52
|
if !paths.empty?
|
39
|
-
|
40
|
-
|
53
|
+
paths = (paths + @files_to_rerun).uniq
|
54
|
+
|
55
|
+
run_for_failed_files(paths)
|
41
56
|
else
|
42
57
|
run_all
|
43
58
|
end
|
@@ -46,6 +61,20 @@ module Guard
|
|
46
61
|
end
|
47
62
|
|
48
63
|
private
|
64
|
+
def run_for_failed_files(paths = [])
|
65
|
+
if paths.empty?
|
66
|
+
UI.info(ALL_SPECS_MESSAGE)
|
67
|
+
else
|
68
|
+
UI.info(SOME_SPECS_MESSAGE % paths.join(' '))
|
69
|
+
end
|
70
|
+
|
71
|
+
if failed_files = JasmineHeadlessWebkitRunner.run(paths)
|
72
|
+
@files_to_rerun = failed_files
|
73
|
+
end
|
74
|
+
|
75
|
+
failed_files && failed_files.empty?
|
76
|
+
end
|
77
|
+
|
49
78
|
def filter_paths(paths)
|
50
79
|
paths.find_all { |path| File.extname(path)[valid_extensions] }.uniq
|
51
80
|
end
|
@@ -81,9 +110,13 @@ module Guard
|
|
81
110
|
yield
|
82
111
|
rescue ::CoffeeScript::CompilationError
|
83
112
|
rescue StandardError => e
|
84
|
-
|
85
|
-
|
86
|
-
|
113
|
+
if ENV['GUARD_ENV'] == 'test'
|
114
|
+
raise e
|
115
|
+
else
|
116
|
+
puts e.message
|
117
|
+
puts e.backtrace.join("\n")
|
118
|
+
puts
|
119
|
+
end
|
87
120
|
end
|
88
121
|
end
|
89
122
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'guard/notifier'
|
2
|
-
require 'jasmine
|
2
|
+
require 'jasmine-headless-webkit'
|
3
3
|
|
4
4
|
module Guard
|
5
5
|
class JasmineHeadlessWebkitRunner
|
@@ -14,14 +14,16 @@ module Guard
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def notify(file)
|
17
|
-
if (
|
18
|
-
Notifier.notify(
|
17
|
+
if (report = Jasmine::Headless::Report.load(file)).valid?
|
18
|
+
Notifier.notify(message(report.total, report.failed, report.time, report.has_used_console?), :title => 'Jasmine results', :image => image(report.has_used_console?, report.failed))
|
19
|
+
report.failed_files
|
19
20
|
else
|
20
|
-
|
21
|
-
|
22
|
-
Notifier.notify(message(total, fails, secs, any_console == "T"), :title => 'Jasmine results', :image => image(any_console == "T", fails))
|
23
|
-
fails.to_i
|
21
|
+
raise Jasmine::Headless::InvalidReport.new
|
24
22
|
end
|
23
|
+
rescue Jasmine::Headless::InvalidReport => e
|
24
|
+
Notifier.notify('Spec runner interrupted!', :title => 'Jasmine results', :image => :failed)
|
25
|
+
rescue Exception => e
|
26
|
+
p e
|
25
27
|
end
|
26
28
|
|
27
29
|
private
|
data/script/gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
OLD_GIT_DIR=$GIT_DIR
|
4
|
+
|
5
|
+
if [ "$(penchant gemfile-env)" != "remote" ]; then
|
6
|
+
unset GIT_DIR
|
7
|
+
penchant gemfile remote
|
8
|
+
GIT_DIR=$OLD_GIT_DIR
|
9
|
+
git add Gemfile*
|
10
|
+
fi
|
11
|
+
|
12
|
+
bundle exec rake
|
13
|
+
R=$?
|
14
|
+
if [ $R -ne 0 ]; then exit $R; fi
|
15
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
if File.file?('Gemfile.erb')
|
4
|
+
pwd = Dir.pwd
|
5
|
+
|
6
|
+
Dir.chdir '..' do
|
7
|
+
File.readlines(File.join(pwd, 'Gemfile.erb')).find_all { |line| line[':git'] }.each do |line|
|
8
|
+
repo = line[%r{:git => (['"])(.*)\1}, 2]
|
9
|
+
|
10
|
+
puts "Installing #{repo}"
|
11
|
+
system %{git clone #{repo}}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
puts "Bundling for local environment"
|
16
|
+
system %{script/gemfile local}
|
17
|
+
else
|
18
|
+
puts "Bundling..."
|
19
|
+
system %{bundle}
|
20
|
+
end
|
21
|
+
|
22
|
+
puts "Installing git hooks"
|
23
|
+
system %{script/install-git-hooks}
|
24
|
+
|
25
|
+
bundle = File.file?('Gemfile') ? 'bundle exec' : ''
|
26
|
+
|
27
|
+
command = [ bundle, 'rake', '-s', '-T', 'bootstrap' ]
|
28
|
+
|
29
|
+
if !(%x{#{command.join(' ')}}).empty?
|
30
|
+
puts "Trying to run rake bootstrap..."
|
31
|
+
system %{#{bundle} rake bootstrap}
|
32
|
+
end
|
33
|
+
|
34
|
+
puts "Done!"
|
35
|
+
|
@@ -13,22 +13,25 @@ describe Guard::JasmineHeadlessWebkitRunner do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
context 'system run not interrupted' do
|
16
|
-
let(:data) { '1
|
16
|
+
let(:data) { 'TOTAL||1||0||5||F' }
|
17
17
|
|
18
18
|
it 'should notify with the right information' do
|
19
|
-
Guard::Notifier.expects(:notify).with("1 test, 0 failures, 5 secs.", { :title => 'Jasmine results', :image => :success })
|
19
|
+
Guard::Notifier.expects(:notify).with("1 test, 0 failures, 5.0 secs.", { :title => 'Jasmine results', :image => :success })
|
20
20
|
|
21
|
-
Guard::JasmineHeadlessWebkitRunner.notify(file)
|
21
|
+
Guard::JasmineHeadlessWebkitRunner.notify(file).should == []
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
context 'with failures' do
|
26
|
-
let(:data) {
|
26
|
+
let(:data) { <<-REPORT }
|
27
|
+
FAIL||Test||Two||file.js:50
|
28
|
+
TOTAL||1||1||5||F
|
29
|
+
REPORT
|
27
30
|
|
28
31
|
it 'should notify with the right information' do
|
29
|
-
Guard::Notifier.expects(:notify).with("1 test,
|
32
|
+
Guard::Notifier.expects(:notify).with("1 test, 1 failures, 5.0 secs.", { :title => 'Jasmine results', :image => :failed })
|
30
33
|
|
31
|
-
Guard::JasmineHeadlessWebkitRunner.notify(file)
|
34
|
+
Guard::JasmineHeadlessWebkitRunner.notify(file).should == [ 'file.js' ]
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
@@ -38,7 +41,7 @@ describe Guard::JasmineHeadlessWebkitRunner do
|
|
38
41
|
it 'should notify failure' do
|
39
42
|
Guard::Notifier.expects(:notify).with("Spec runner interrupted!", { :title => 'Jasmine results', :image => :failed })
|
40
43
|
|
41
|
-
Guard::JasmineHeadlessWebkitRunner.notify(file)
|
44
|
+
Guard::JasmineHeadlessWebkitRunner.notify(file).should be_nil
|
42
45
|
end
|
43
46
|
end
|
44
47
|
end
|
@@ -24,42 +24,98 @@ describe Guard::JasmineHeadlessWebkit do
|
|
24
24
|
guard.start
|
25
25
|
end
|
26
26
|
end
|
27
|
+
|
28
|
+
context 'run_before' do
|
29
|
+
let(:options) { { :run_before => true, :all_on_start => false } }
|
30
|
+
|
31
|
+
it "should warn about deprecation" do
|
32
|
+
Guard::UI.expects(:deprecation).at_least_once
|
33
|
+
guard.start
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#run_all' do
|
39
|
+
before do
|
40
|
+
guard.stubs(:run_all_things_before).returns(true)
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'fails' do
|
44
|
+
it 'should return false' do
|
45
|
+
Guard::JasmineHeadlessWebkitRunner.stubs(:run).returns(['file.js'])
|
46
|
+
|
47
|
+
guard.run_all.should be_false
|
48
|
+
guard.files_to_rerun.should == ['file.js']
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'succeeds' do
|
53
|
+
it 'should return true' do
|
54
|
+
Guard::JasmineHeadlessWebkitRunner.stubs(:run).returns([])
|
55
|
+
|
56
|
+
guard.run_all.should be_true
|
57
|
+
guard.files_to_rerun.should == []
|
58
|
+
end
|
59
|
+
end
|
27
60
|
end
|
28
61
|
|
29
62
|
describe '#run_on_change' do
|
63
|
+
let(:one_file) { %w{test.js} }
|
64
|
+
|
30
65
|
context 'two files' do
|
31
66
|
it "should only run one" do
|
32
|
-
Guard::JasmineHeadlessWebkitRunner.expects(:run).with(
|
33
|
-
guard.expects(:run_all).never
|
67
|
+
Guard::JasmineHeadlessWebkitRunner.expects(:run).with(one_file).returns(one_file)
|
34
68
|
|
35
|
-
guard.run_on_change(%w{test.js test.js})
|
69
|
+
guard.run_on_change(%w{test.js test.js}).should be_false
|
70
|
+
guard.files_to_rerun.should == one_file
|
36
71
|
end
|
37
72
|
end
|
38
73
|
|
39
|
-
context '
|
74
|
+
context 'one file no priors' do
|
40
75
|
it "should not run all" do
|
41
|
-
Guard::JasmineHeadlessWebkitRunner.expects(:run).returns(
|
42
|
-
|
76
|
+
Guard::JasmineHeadlessWebkitRunner.expects(:run).returns(one_file)
|
77
|
+
|
78
|
+
guard.run_on_change(one_file).should be_false
|
79
|
+
guard.files_to_rerun.should == one_file
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'one file one prior' do
|
84
|
+
it "should not run all" do
|
85
|
+
guard.instance_variable_set(:@files_to_rerun, [ "two.js" ])
|
86
|
+
Guard::JasmineHeadlessWebkitRunner.expects(:run).with(one_file + [ "two.js" ]).returns(one_file)
|
87
|
+
|
88
|
+
guard.run_on_change(one_file).should be_false
|
89
|
+
guard.files_to_rerun.should == one_file
|
90
|
+
end
|
91
|
+
end
|
43
92
|
|
44
|
-
|
93
|
+
context 'failed hard' do
|
94
|
+
it "should not run all" do
|
95
|
+
guard.instance_variable_set(:@files_to_rerun, one_file)
|
96
|
+
Guard::JasmineHeadlessWebkitRunner.expects(:run).with(one_file).returns(nil)
|
97
|
+
|
98
|
+
guard.run_on_change(one_file).should be_false
|
99
|
+
guard.files_to_rerun.should == one_file
|
45
100
|
end
|
46
101
|
end
|
47
102
|
|
48
103
|
context 'succeed, but still do not run all' do
|
49
104
|
it "should run all" do
|
50
|
-
Guard::JasmineHeadlessWebkitRunner.expects(:run).returns(
|
51
|
-
guard.expects(:run_all).never
|
105
|
+
Guard::JasmineHeadlessWebkitRunner.expects(:run).returns([])
|
52
106
|
|
53
|
-
guard.run_on_change(
|
107
|
+
guard.run_on_change(one_file).should be_true
|
108
|
+
guard.files_to_rerun.should == []
|
54
109
|
end
|
55
110
|
end
|
56
111
|
|
57
112
|
context 'no files given, just run all' do
|
58
113
|
it 'should run all but not run once' do
|
59
114
|
Guard::JasmineHeadlessWebkitRunner.expects(:run).never
|
60
|
-
guard.expects(:run_all).once
|
115
|
+
guard.expects(:run_all).once.returns(true)
|
61
116
|
|
62
|
-
guard.run_on_change([])
|
117
|
+
guard.run_on_change([]).should be_true
|
118
|
+
guard.files_to_rerun.should == []
|
63
119
|
end
|
64
120
|
end
|
65
121
|
|
@@ -69,6 +125,7 @@ describe Guard::JasmineHeadlessWebkit do
|
|
69
125
|
guard.expects(:run_all).once
|
70
126
|
|
71
127
|
guard.run_on_change(%w{test.jst})
|
128
|
+
guard.files_to_rerun.should == []
|
72
129
|
end
|
73
130
|
end
|
74
131
|
end
|
@@ -78,7 +135,6 @@ describe Guard::JasmineHeadlessWebkit do
|
|
78
135
|
before do
|
79
136
|
Guard::JasmineHeadlessWebkitRunner.expects(:run).never
|
80
137
|
Guard::UI.expects(:info).with(regexp_matches(/false/))
|
81
|
-
Guard::UI.expects(:info).with(regexp_matches(/running all/))
|
82
138
|
end
|
83
139
|
|
84
140
|
let(:options) { { :run_before => 'false' } }
|
@@ -102,4 +158,14 @@ describe Guard::JasmineHeadlessWebkit do
|
|
102
158
|
end
|
103
159
|
end
|
104
160
|
end
|
161
|
+
|
162
|
+
describe '#reload' do
|
163
|
+
it 'should reset the state of the files_to_rerun' do
|
164
|
+
Guard::UI.expects(:info).with(regexp_matches(/Resetting/))
|
165
|
+
|
166
|
+
guard.instance_variable_set(:@files_to_rerun, "test")
|
167
|
+
guard.reload
|
168
|
+
guard.files_to_rerun.should == []
|
169
|
+
end
|
170
|
+
end
|
105
171
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-jasmine-headless-webkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-09-12 00:00:00.000000000 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: guard
|
17
|
-
requirement: &
|
17
|
+
requirement: &2166592000 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,18 +22,18 @@ dependencies:
|
|
22
22
|
version: 0.4.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2166592000
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: jasmine-headless-webkit
|
28
|
-
requirement: &
|
28
|
+
requirement: &2166591500 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.7.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2166591500
|
37
37
|
description: Run jasmine-headless-webkit using guard
|
38
38
|
email:
|
39
39
|
- john@coswellproductions.com
|
@@ -51,6 +51,10 @@ files:
|
|
51
51
|
- lib/guard/jasmine-headless-webkit/runner.rb
|
52
52
|
- lib/guard/jasmine-headless-webkit/templates/Guardfile
|
53
53
|
- lib/guard/jasmine-headless-webkit/version.rb
|
54
|
+
- script/gemfile
|
55
|
+
- script/hooks/pre-commit
|
56
|
+
- script/initialize-environment
|
57
|
+
- script/install-git-hooks
|
54
58
|
- spec/lib/guard/jasmine-headless-webkit/runner_spec.rb
|
55
59
|
- spec/lib/guard/jasmine-headless-webkit_spec.rb
|
56
60
|
- spec/spec_helper.rb
|