guard-jasmine-node 0.0.1 → 0.0.3
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.
- data/README.md +112 -0
- data/guard-jasmine-node.gemspec +1 -0
- data/lib/guard/jasmine_node.rb +39 -28
- data/lib/guard/jasmine_node/runner.rb +22 -6
- data/lib/guard/jasmine_node/spec_state.rb +67 -0
- data/lib/guard/jasmine_node/templates/Guardfile +16 -4
- data/lib/guard/jasmine_node/version.rb +1 -1
- data/spec/{spec → lib}/jasmine_node_spec.rb +54 -70
- data/spec/lib/runner_spec.rb +74 -0
- data/spec/lib/spec_state_spec.rb +127 -0
- metadata +114 -64
- data/spec/spec/runner_spec.rb +0 -36
data/README.md
CHANGED
@@ -0,0 +1,112 @@
|
|
1
|
+
Guard::JasmineNode 
|
2
|
+
==================
|
3
|
+
|
4
|
+
JasmineNode guard automatically & intelligently executes jasmine node specs when files are modified.
|
5
|
+
|
6
|
+
It works brilliantly with Node projects whereas [guard-jasmine](https://github.com/netzpirat/guard-jasmine)
|
7
|
+
looks better for jasmine specs in the context of e.g. a Rails app.
|
8
|
+
|
9
|
+
* Tested against Node 0.4, jasmine-node 1.0.10
|
10
|
+
|
11
|
+
Requirements
|
12
|
+
------------
|
13
|
+
|
14
|
+
* [Node](http://nodejs.org/)
|
15
|
+
* [jasmine-node](https://github.com/mhevery/jasmine-node)
|
16
|
+
* [Ruby](http://ruby-lang.org) and rubygems
|
17
|
+
|
18
|
+
Install
|
19
|
+
-------
|
20
|
+
|
21
|
+
Install the gem:
|
22
|
+
|
23
|
+
$ gem install guard-jasmine-node
|
24
|
+
|
25
|
+
Add guard definition to your Guardfile by running this command:
|
26
|
+
|
27
|
+
$ guard init jasmine-node
|
28
|
+
|
29
|
+
Usage
|
30
|
+
-----
|
31
|
+
|
32
|
+
$ guard
|
33
|
+
|
34
|
+
This will watch your project and execute your specs when files
|
35
|
+
change. It's worth checking out [the docs](https://github.com/guard/guard#readme).
|
36
|
+
|
37
|
+
Options
|
38
|
+
-------
|
39
|
+
|
40
|
+
* `:all_on_start # default => true`
|
41
|
+
|
42
|
+
Run all the specs as soon as Guard is started.
|
43
|
+
|
44
|
+
* `:all_after_pass # default => true`
|
45
|
+
|
46
|
+
When files are modified and the specs covering the modified files
|
47
|
+
pass, run all the specs automatically.
|
48
|
+
|
49
|
+
* `:keep_failed # default => true`
|
50
|
+
|
51
|
+
When files are modified, run failing specs as well as specs covering
|
52
|
+
the modified files.
|
53
|
+
|
54
|
+
* `:notify # default => true`
|
55
|
+
|
56
|
+
Display growl/libnotify notifications.
|
57
|
+
|
58
|
+
* `:coffeescript # default => true`
|
59
|
+
|
60
|
+
Load coffeescript and all execution of .coffee files.
|
61
|
+
|
62
|
+
* `:jasmine_node_bin`
|
63
|
+
|
64
|
+
Specify the path to the jasmine-node binary that will execute your specs.
|
65
|
+
|
66
|
+
The default `:jasmine_node_bin` in the Guardfile assumes:
|
67
|
+
|
68
|
+
* you are running guard from the root of the project
|
69
|
+
* you installed jasmine-node using npm
|
70
|
+
* you installed jasmine-node locally to node_modules
|
71
|
+
|
72
|
+
If you delete the option completely from the Guardfile, it assumes the
|
73
|
+
jasmine-node binary is already in your `$PATH`.
|
74
|
+
|
75
|
+
So if you have installed jasmine-node globally using e.g. `npm install
|
76
|
+
-g jasmine-node`, remove the `:jasmine_node_bin` option from the Guardfile.
|
77
|
+
|
78
|
+
Guardfile
|
79
|
+
---------
|
80
|
+
|
81
|
+
Please read the [guard docs](https://github.com/guard/guard#readme) for
|
82
|
+
more information about the Guardfile DSL.
|
83
|
+
|
84
|
+
It's powerful stuff.
|
85
|
+
|
86
|
+
Development
|
87
|
+
-----------
|
88
|
+
|
89
|
+
* Source hosted at [GitHub](https://github.com/kapoq/guard-jasmine-node)
|
90
|
+
* Report issues/Questions/Feature requests on [GitHub Issues](https://github.com/kapoq/guard-jasmine-node/issues)
|
91
|
+
* CI at [Travis](http://travis-ci.org/#!/textgoeshere/guard-jasmine-node)
|
92
|
+
|
93
|
+
Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change
|
94
|
+
you make.
|
95
|
+
|
96
|
+
TODO
|
97
|
+
----
|
98
|
+
|
99
|
+
* write a JsonFormatter for jasmine-node so we have finer-grained
|
100
|
+
control over rendering output
|
101
|
+
* write an RSpec-style progress formatter (aka lots of green dots)
|
102
|
+
* patch Guard to locate CamelCased modules correctly
|
103
|
+
|
104
|
+
Testing
|
105
|
+
-------
|
106
|
+
|
107
|
+
$ rake
|
108
|
+
|
109
|
+
Author
|
110
|
+
------
|
111
|
+
|
112
|
+
[Dave Nolan](https://github.com/textgoeshere)
|
data/guard-jasmine-node.gemspec
CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
|
18
18
|
s.add_development_dependency "rspec"
|
19
19
|
s.add_development_dependency "guard-rspec"
|
20
|
+
s.add_development_dependency "rake"
|
20
21
|
if RUBY_PLATFORM =~ /linux/
|
21
22
|
s.add_development_dependency "rb-inotify"
|
22
23
|
s.add_development_dependency "libnotify"
|
data/lib/guard/jasmine_node.rb
CHANGED
@@ -7,14 +7,19 @@ module Guard
|
|
7
7
|
:jasmine_node_bin => "jasmine-node",
|
8
8
|
:all_after_pass => true,
|
9
9
|
:all_on_start => true,
|
10
|
-
:keep_failed => true
|
10
|
+
:keep_failed => true,
|
11
|
+
:notify => true,
|
12
|
+
:coffeescript => true
|
11
13
|
}
|
12
|
-
|
13
|
-
autoload :Runner, "guard/jasmine_node/runner"
|
14
14
|
|
15
|
+
PATHS_FOR_ALL_SPECS = %w(spec)
|
16
|
+
|
17
|
+
autoload :Runner, "guard/jasmine_node/runner"
|
18
|
+
autoload :SpecState, "guard/jasmine_node/spec_state"
|
19
|
+
|
15
20
|
def initialize(watchers = [], options = {})
|
16
21
|
super(watchers, DEFAULT_OPTIONS.merge(options))
|
17
|
-
|
22
|
+
@state = SpecState.new
|
18
23
|
end
|
19
24
|
|
20
25
|
def start
|
@@ -22,8 +27,8 @@ module Guard
|
|
22
27
|
end
|
23
28
|
|
24
29
|
def run_all
|
25
|
-
|
26
|
-
|
30
|
+
run(PATHS_FOR_ALL_SPECS)
|
31
|
+
notify(:all)
|
27
32
|
end
|
28
33
|
|
29
34
|
def run_on_change(changed_paths = [])
|
@@ -33,38 +38,44 @@ module Guard
|
|
33
38
|
changed_paths
|
34
39
|
end
|
35
40
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
if passing?
|
40
|
-
run_all if options[:all_after_pass]
|
41
|
-
end
|
41
|
+
run(run_paths)
|
42
|
+
notify(:some)
|
43
|
+
|
44
|
+
run_all if passing? and options[:all_after_pass]
|
42
45
|
end
|
43
46
|
|
47
|
+
def failing_paths
|
48
|
+
@state.failing_paths
|
49
|
+
end
|
50
|
+
|
44
51
|
def passing?
|
45
|
-
@passing
|
52
|
+
@state.passing?
|
46
53
|
end
|
47
54
|
|
48
|
-
def
|
49
|
-
@
|
55
|
+
def fixed?
|
56
|
+
@state.fixed?
|
50
57
|
end
|
51
58
|
|
52
59
|
private
|
53
60
|
|
54
|
-
def
|
55
|
-
@
|
56
|
-
@failing_paths = []
|
61
|
+
def run(run_paths = [], runner_options = {}, notifications = {})
|
62
|
+
@state.update(run_paths, options.merge(runner_options))
|
57
63
|
end
|
58
|
-
|
59
|
-
def
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
64
|
+
|
65
|
+
def notify(scope = :all)
|
66
|
+
return unless options[:notify]
|
67
|
+
|
68
|
+
message = if passing?
|
69
|
+
if fixed?
|
70
|
+
scope == :all ? "All fixed" : "Specs fixed"
|
71
|
+
else
|
72
|
+
scope == :all ? "All specs pass" : "Specs pass"
|
73
|
+
end
|
74
|
+
else
|
75
|
+
"Some specs failing"
|
76
|
+
end
|
77
|
+
image = passing? ? :success : :failed
|
78
|
+
::Guard::Notifier.notify(message, :image => image, :title => "jasmine-node")
|
68
79
|
end
|
69
80
|
end
|
70
81
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'open3'
|
1
2
|
require 'guard/ui'
|
2
3
|
|
3
4
|
module Guard
|
@@ -5,17 +6,32 @@ module Guard
|
|
5
6
|
module Runner
|
6
7
|
def self.run(paths = [], options = {})
|
7
8
|
return false if paths.empty?
|
8
|
-
|
9
|
-
message = options.fetch(:message, "Running: #{paths.join(' ')}")
|
10
|
-
::Guard::UI.info(message, :reset => true)
|
11
9
|
|
12
|
-
|
10
|
+
@paths = paths
|
11
|
+
@options = options
|
12
|
+
|
13
|
+
print_message
|
14
|
+
execute_jasmine_node_command
|
13
15
|
end
|
14
16
|
|
15
17
|
private
|
16
18
|
|
17
|
-
def self.
|
18
|
-
|
19
|
+
def self.print_message
|
20
|
+
message = @options[:message]
|
21
|
+
message ||= @paths == PATHS_FOR_ALL_SPECS ? "Running all specs" : "Running: #{@paths.join(' ')}"
|
22
|
+
::Guard::UI.info(message, :reset => true)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.execute_jasmine_node_command
|
26
|
+
::Open3.popen3(jasmine_node_command)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.jasmine_node_command
|
30
|
+
"#{@options[:jasmine_node_bin]} #{command_line_options} #{@paths.join(' ')}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.command_line_options
|
34
|
+
"--coffee" if @options[:coffeescript]
|
19
35
|
end
|
20
36
|
end
|
21
37
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Guard
|
2
|
+
class JasmineNode
|
3
|
+
class SpecState
|
4
|
+
STDIN = 0
|
5
|
+
STDOUT = 1
|
6
|
+
STDERR = 2
|
7
|
+
THREAD = 3
|
8
|
+
|
9
|
+
SUCCESS_CODE = 0
|
10
|
+
ERROR_CODE = 1
|
11
|
+
|
12
|
+
attr_accessor :failing_paths
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
clear!
|
16
|
+
end
|
17
|
+
|
18
|
+
def update(run_paths = [], options = {})
|
19
|
+
@run_paths = run_paths
|
20
|
+
@io = Runner.run(@run_paths, options)
|
21
|
+
@stdout = @io[STDOUT]
|
22
|
+
@exitstatus = @io[THREAD].value rescue ERROR_CODE
|
23
|
+
@stdout.lines { |line| print line }
|
24
|
+
close_io
|
25
|
+
update_passed_and_fixed
|
26
|
+
update_failing_paths
|
27
|
+
passing?
|
28
|
+
end
|
29
|
+
|
30
|
+
def passing?
|
31
|
+
@passed
|
32
|
+
end
|
33
|
+
|
34
|
+
def fixed?
|
35
|
+
@fixed
|
36
|
+
end
|
37
|
+
|
38
|
+
def clear!
|
39
|
+
@passed = true
|
40
|
+
@fixed = false
|
41
|
+
@failing_paths = []
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def close_io
|
47
|
+
@io[STDIN..STDERR].each { |s| s.close }
|
48
|
+
end
|
49
|
+
|
50
|
+
def update_passed_and_fixed
|
51
|
+
previously_failed = !passing?
|
52
|
+
@passed = @exitstatus == SUCCESS_CODE
|
53
|
+
@fixed = @passed && previously_failed
|
54
|
+
end
|
55
|
+
|
56
|
+
def update_failing_paths
|
57
|
+
if @run_paths.any?
|
58
|
+
@failing_paths = if passing?
|
59
|
+
@failing_paths - @run_paths
|
60
|
+
else
|
61
|
+
@failing_paths + @run_paths
|
62
|
+
end.uniq
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -1,5 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
# Installed by guard-jasmine-node
|
2
|
+
|
3
|
+
# JavaScript/CoffeeScript watchers
|
4
|
+
|
5
|
+
guard 'jasmine-node', :jasmine_node_bin => File.expand_path(File.dirname(__FILE__) + "/node_modules/jasmine-node/bin/jasmine-node") do
|
6
|
+
watch(%r{^spec/(.+)_spec\.(js\.coffee|js|coffee)}) { |m| "spec/#{m[1]}_spec.#{m[2]}" }
|
7
|
+
watch(%r{^lib/(.+)\.(js\.coffee|js)|coffee}) { |m| "spec/lib/#{m[1]}_spec.#{m[2]}" }
|
8
|
+
watch(%r{spec/spec_helper\.(js\.coffee|js|coffee)}) { "spec" }
|
5
9
|
end
|
10
|
+
|
11
|
+
# JavaScript only watchers
|
12
|
+
#
|
13
|
+
# guard "jasmine-node", :jasmine_node_bin => File.expand_path(File.dirname(__FILE__) + "/node_modules/jasmine-node/bin/jasmine-node") do
|
14
|
+
# watch(%r{^spec/.+_spec\.js$})
|
15
|
+
# watch(%r{^lib/(.+)\.js$}) { |m| "spec/lib/#{m[1]}_spec.js" }
|
16
|
+
# watch('spec/spec_helper.js')
|
17
|
+
# end
|
@@ -1,8 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Guard::JasmineNode do
|
4
|
+
let(:state) { Guard::JasmineNode::SpecState.new }
|
4
5
|
let(:guard) { Guard::JasmineNode.new }
|
5
|
-
|
6
|
+
|
7
|
+
before do
|
8
|
+
Guard::JasmineNode::SpecState.stub(:new => state)
|
9
|
+
Guard::Notifier.stub(:notify)
|
10
|
+
state.stub(:update => true)
|
11
|
+
end
|
6
12
|
|
7
13
|
describe "#initialize" do
|
8
14
|
context "when no options are given" do
|
@@ -10,18 +16,26 @@ describe Guard::JasmineNode do
|
|
10
16
|
guard.options[:jasmine_node_bin].should eql "jasmine-node"
|
11
17
|
end
|
12
18
|
|
13
|
-
it "sets
|
19
|
+
it "sets :notify option to true" do
|
20
|
+
guard.options[:notify].should eql true
|
21
|
+
end
|
22
|
+
|
23
|
+
it "sets :all_after_pass option to true" do
|
14
24
|
guard.options[:all_after_pass].should be_true
|
15
25
|
end
|
16
26
|
|
17
|
-
it "sets
|
27
|
+
it "sets :all_on_start option to true" do
|
18
28
|
guard.options[:all_on_start].should be_true
|
19
29
|
end
|
20
30
|
|
21
|
-
it "sets
|
31
|
+
it "sets :keep_failed option to true" do
|
22
32
|
guard.options[:keep_failed].should be_true
|
23
33
|
end
|
24
34
|
|
35
|
+
it "sets :coffescript option to true" do
|
36
|
+
guard.options[:coffeescript].should be_true
|
37
|
+
end
|
38
|
+
|
25
39
|
it "is passing" do
|
26
40
|
guard.should be_passing
|
27
41
|
end
|
@@ -37,12 +51,18 @@ describe Guard::JasmineNode do
|
|
37
51
|
:jasmine_node_bin => a_path,
|
38
52
|
:all_on_start => false,
|
39
53
|
:all_after_pass => false,
|
40
|
-
:keep_failed => false
|
54
|
+
:keep_failed => false,
|
55
|
+
:notify => false,
|
56
|
+
:coffeescript => false
|
41
57
|
}) }
|
42
58
|
|
43
59
|
it "sets the path to jasmine-node bin" do
|
44
60
|
guard.options[:jasmine_node_bin].should eql a_path
|
45
61
|
end
|
62
|
+
|
63
|
+
it "sets the :notify option" do
|
64
|
+
guard.options[:notify].should be_false
|
65
|
+
end
|
46
66
|
|
47
67
|
it "sets the :all_after_pass option" do
|
48
68
|
guard.options[:all_after_pass].should be_false
|
@@ -55,6 +75,10 @@ describe Guard::JasmineNode do
|
|
55
75
|
it "sets the :keep_failed option" do
|
56
76
|
guard.options[:keep_failed].should be_false
|
57
77
|
end
|
78
|
+
|
79
|
+
it "sets the :coffeescript option" do
|
80
|
+
guard.options[:coffeescript].should be_false
|
81
|
+
end
|
58
82
|
end
|
59
83
|
end
|
60
84
|
|
@@ -77,78 +101,49 @@ describe Guard::JasmineNode do
|
|
77
101
|
end
|
78
102
|
|
79
103
|
describe "#run_all" do
|
80
|
-
it "
|
81
|
-
|
82
|
-
guard.run_all
|
83
|
-
end
|
84
|
-
|
85
|
-
it "tells the message to the runner" do
|
86
|
-
runner.should_receive(:run).with(anything, hash_including(:message => "Running all specs"))
|
104
|
+
it "updates the state with the specs in the spec dir" do
|
105
|
+
state.should_receive(:update).with(["spec"], anything)
|
87
106
|
guard.run_all
|
88
107
|
end
|
89
108
|
|
90
|
-
it "passes the options
|
109
|
+
it "passes the options through to the state" do
|
91
110
|
an_option = { :option => "value" }
|
92
111
|
guard.options.update(an_option)
|
93
|
-
|
112
|
+
state.should_receive(:update).with(anything, hash_including(an_option))
|
94
113
|
guard.run_all
|
95
114
|
end
|
96
115
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
guard.run_all
|
101
|
-
end
|
102
|
-
|
103
|
-
it "is passing" do
|
104
|
-
guard.should be_passing
|
105
|
-
end
|
106
|
-
|
107
|
-
it "has no failed paths" do
|
108
|
-
guard.failing_paths.should be_empty
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
context "when specs fail" do
|
113
|
-
before do
|
114
|
-
runner.stub(:run => false)
|
115
|
-
end
|
116
|
-
|
117
|
-
it "is not passing" do
|
118
|
-
guard.run_all
|
119
|
-
guard.should_not be_passing
|
120
|
-
end
|
121
|
-
|
122
|
-
it "keeps previously failing specs" do
|
123
|
-
failing_paths = %w(foo bar)
|
124
|
-
guard.run_on_change(failing_paths)
|
125
|
-
guard.run_all
|
126
|
-
guard.failing_paths.should eql failing_paths
|
127
|
-
end
|
116
|
+
it "notifies the user with the outcome of running all specs" do
|
117
|
+
guard.should_receive(:notify).with(:all)
|
118
|
+
guard.run_all
|
128
119
|
end
|
129
120
|
end
|
130
121
|
|
131
122
|
describe "#run_on_change" do
|
132
|
-
|
133
|
-
|
123
|
+
before do
|
124
|
+
guard.options[:all_after_pass] = false
|
125
|
+
end
|
126
|
+
|
127
|
+
it "updates the state with paths" do
|
128
|
+
state.should_receive(:update).with(["/a/path"], anything)
|
134
129
|
guard.run_on_change(["/a/path"])
|
135
130
|
end
|
136
131
|
|
137
|
-
it "passes options through to the
|
132
|
+
it "passes options through to the state" do
|
138
133
|
an_option = { :option => "value" }
|
139
134
|
guard.options.update(an_option)
|
140
|
-
|
135
|
+
state.should_receive(:update).with(anything, hash_including(an_option))
|
136
|
+
guard.run_on_change
|
137
|
+
end
|
138
|
+
|
139
|
+
it "notifies the user with the outcome of running the specs" do
|
140
|
+
guard.should_receive(:notify).with(:some)
|
141
141
|
guard.run_on_change
|
142
142
|
end
|
143
143
|
|
144
144
|
context "when specs pass" do
|
145
145
|
before do
|
146
|
-
|
147
|
-
end
|
148
|
-
|
149
|
-
it "is passing" do
|
150
|
-
guard.run_on_change
|
151
|
-
guard.should be_passing
|
146
|
+
guard.stub(:passing? => true)
|
152
147
|
end
|
153
148
|
|
154
149
|
context "and :all_after_pass is true" do
|
@@ -176,17 +171,6 @@ describe Guard::JasmineNode do
|
|
176
171
|
end
|
177
172
|
end
|
178
173
|
|
179
|
-
context "when specs fail" do
|
180
|
-
before do
|
181
|
-
runner.stub(:run => false)
|
182
|
-
end
|
183
|
-
|
184
|
-
it "is not passing" do
|
185
|
-
guard.run_on_change
|
186
|
-
guard.should_not be_passing
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
174
|
context "when there are failing paths" do
|
191
175
|
let(:failing_paths) { %w(foo/bar zip/zap) }
|
192
176
|
let(:changed_paths) { %w(aaa/bbb ccc/ddd) }
|
@@ -201,8 +185,8 @@ describe Guard::JasmineNode do
|
|
201
185
|
guard.options[:keep_failed] = true
|
202
186
|
end
|
203
187
|
|
204
|
-
it "
|
205
|
-
|
188
|
+
it "updates state with failing paths and the changed paths" do
|
189
|
+
state.should_receive(:update).with(all_paths, anything)
|
206
190
|
guard.run_on_change(changed_paths)
|
207
191
|
end
|
208
192
|
end
|
@@ -212,8 +196,8 @@ describe Guard::JasmineNode do
|
|
212
196
|
guard.options[:keep_failed] = false
|
213
197
|
end
|
214
198
|
|
215
|
-
it "
|
216
|
-
|
199
|
+
it "updates state with only the changed paths" do
|
200
|
+
state.should_receive(:update).with(changed_paths, anything)
|
217
201
|
guard.run_on_change(changed_paths)
|
218
202
|
end
|
219
203
|
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Guard::JasmineNode::Runner do
|
4
|
+
let(:runner) { Guard::JasmineNode::Runner }
|
5
|
+
|
6
|
+
before do
|
7
|
+
Open3.stub(:popen3 => "response")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".run" do
|
11
|
+
context "when passed no paths" do
|
12
|
+
it "returns false" do
|
13
|
+
runner.run.should be_false
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "when passed paths" do
|
18
|
+
let(:some_paths) { %w(/foo/bar /zip/zap) }
|
19
|
+
|
20
|
+
it "executes jasmine node" do
|
21
|
+
Open3.should_receive(:popen3).with(/__EXECUTABLE__/)
|
22
|
+
runner.run(some_paths, :jasmine_node_bin => "__EXECUTABLE__")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "passes the paths to the executable" do
|
26
|
+
Open3.should_receive(:popen3).with(/#{some_paths.join(" ")}/)
|
27
|
+
runner.run(some_paths)
|
28
|
+
end
|
29
|
+
|
30
|
+
context "and coffeescript option is true" do
|
31
|
+
it "passes the --coffee option to jasmine node" do
|
32
|
+
Open3.should_receive(:popen3).with(/--coffee/)
|
33
|
+
runner.run(some_paths, :coffeescript => true)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "and coffeescript option is false" do
|
38
|
+
it "does not pass the --coffee option to jasmine node" do
|
39
|
+
Open3.should_not_receive(:popen3).with(/--coffee/)
|
40
|
+
runner.run(some_paths, :coffeescript => false)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returns IO object" do
|
45
|
+
io_obj = double("io obj")
|
46
|
+
Open3.stub(:popen3 => io_obj)
|
47
|
+
runner.run(some_paths).should eql io_obj
|
48
|
+
end
|
49
|
+
|
50
|
+
context "when message option is given" do
|
51
|
+
it "outputs message" do
|
52
|
+
Guard::UI.should_receive(:info).with("hello", anything)
|
53
|
+
runner.run(some_paths, :message => "hello")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "when no message option is given" do
|
58
|
+
context "and running all specs" do
|
59
|
+
it "outputs message confirming all specs are being run" do
|
60
|
+
Guard::UI.should_receive(:info).with("Running all specs", anything)
|
61
|
+
runner.run(Guard::JasmineNode::PATHS_FOR_ALL_SPECS)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context "and running some specs" do
|
66
|
+
it "outputs paths of specs being run" do
|
67
|
+
Guard::UI.should_receive(:info).with("Running: /foo/bar /zip/zap", anything)
|
68
|
+
runner.run(some_paths)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Guard::JasmineNode::SpecState do
|
4
|
+
let(:state) { Guard::JasmineNode::SpecState.new }
|
5
|
+
let(:runner) { Guard::JasmineNode::Runner }
|
6
|
+
|
7
|
+
describe "#initialize" do
|
8
|
+
it "is passing" do
|
9
|
+
state.should be_passing
|
10
|
+
end
|
11
|
+
|
12
|
+
it "has no failing paths" do
|
13
|
+
state.failing_paths.should be_empty
|
14
|
+
end
|
15
|
+
|
16
|
+
it "is has not been fixed" do
|
17
|
+
state.should_not be_fixed
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#update" do
|
22
|
+
let(:io) { [
|
23
|
+
double("stdin", :close => true),
|
24
|
+
double("stdout", :close => true, :lines => []),
|
25
|
+
double("stderr", :close => true),
|
26
|
+
double("thread", :value => 0)
|
27
|
+
] }
|
28
|
+
let(:some_paths) { %w(some paths) }
|
29
|
+
let(:some_options) { double("some options") }
|
30
|
+
|
31
|
+
before do
|
32
|
+
runner.stub(:run => io)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "runs the runner with the paths and options" do
|
36
|
+
runner.should_receive(:run).with(some_paths, some_options).and_return(io)
|
37
|
+
state.update(some_paths, some_options)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "closes stdin, stdout, and stderr of the subprocess" do
|
41
|
+
io[0..2].each { |i| i.should_receive(:close) }
|
42
|
+
state.update
|
43
|
+
end
|
44
|
+
|
45
|
+
context "when the runner process exit value is zero" do
|
46
|
+
before do
|
47
|
+
io[3].stub(:value => 0)
|
48
|
+
state.update
|
49
|
+
end
|
50
|
+
|
51
|
+
it "is passing" do
|
52
|
+
state.should be_passing
|
53
|
+
end
|
54
|
+
|
55
|
+
context "and there are run paths" do
|
56
|
+
it "removes the run paths from the failing paths" do
|
57
|
+
state.failing_paths = %w(/keep /remove)
|
58
|
+
state.update(%w(/remove))
|
59
|
+
state.failing_paths.should eql %w(/keep)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context "and there are no run paths" do
|
64
|
+
it "does not change the current failing paths" do
|
65
|
+
original_failing_paths = %w(/keep1 /keep2)
|
66
|
+
state.failing_paths = original_failing_paths
|
67
|
+
state.update
|
68
|
+
state.failing_paths.should eql original_failing_paths
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context "and the previous spec failed" do
|
73
|
+
before do
|
74
|
+
state.stub(:passing? => false)
|
75
|
+
state.update
|
76
|
+
end
|
77
|
+
|
78
|
+
it "is fixed" do
|
79
|
+
state.should be_fixed
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context "and the previous spec passed" do
|
84
|
+
before do
|
85
|
+
state.stub(:passing? => true)
|
86
|
+
state.update
|
87
|
+
end
|
88
|
+
|
89
|
+
it "is not fixed" do
|
90
|
+
state.should_not be_fixed
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context "when the runner process exit value is not zero" do
|
96
|
+
before do
|
97
|
+
io[3].stub(:value => 1)
|
98
|
+
state.update(some_paths, some_options)
|
99
|
+
end
|
100
|
+
|
101
|
+
it "is not passing" do
|
102
|
+
state.should_not be_passing
|
103
|
+
end
|
104
|
+
|
105
|
+
it "is not fixed" do
|
106
|
+
state.should_not be_fixed
|
107
|
+
end
|
108
|
+
|
109
|
+
context "and there are run paths" do
|
110
|
+
it "updates the failing paths with the union of the failing paths and the run paths" do
|
111
|
+
state.failing_paths = %w(/dupe /other)
|
112
|
+
state.update(%w(/dupe /another))
|
113
|
+
state.failing_paths.should =~ %w(/dupe /other /another)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context "and there are no run paths" do
|
118
|
+
it "does not change the current failing paths" do
|
119
|
+
original_failing_paths = %w(/keep1 /keep2)
|
120
|
+
state.failing_paths = original_failing_paths
|
121
|
+
state.update
|
122
|
+
state.failing_paths.should eql original_failing_paths
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
metadata
CHANGED
@@ -1,78 +1,117 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-jasmine-node
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- dave@kapoq.com
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2011-09-23 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: guard
|
16
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
24
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
- 4
|
32
|
+
version: "0.4"
|
22
33
|
type: :runtime
|
23
|
-
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
26
36
|
name: rspec
|
27
|
-
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
39
|
none: false
|
29
|
-
requirements:
|
30
|
-
- -
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
33
47
|
type: :development
|
34
|
-
|
35
|
-
|
36
|
-
- !ruby/object:Gem::Dependency
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
37
50
|
name: guard-rspec
|
38
|
-
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
39
53
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
44
61
|
type: :development
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: rake
|
45
65
|
prerelease: false
|
46
|
-
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: rb-inotify
|
49
|
-
requirement: &21458360 !ruby/object:Gem::Requirement
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
50
67
|
none: false
|
51
|
-
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
55
75
|
type: :development
|
76
|
+
version_requirements: *id004
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
name: rb-inotify
|
56
79
|
prerelease: false
|
57
|
-
|
58
|
-
- !ruby/object:Gem::Dependency
|
59
|
-
name: libnotify
|
60
|
-
requirement: &21457940 !ruby/object:Gem::Requirement
|
80
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
|
-
requirements:
|
63
|
-
- -
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
66
89
|
type: :development
|
90
|
+
version_requirements: *id005
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: libnotify
|
67
93
|
prerelease: false
|
68
|
-
|
69
|
-
|
70
|
-
|
94
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
hash: 3
|
100
|
+
segments:
|
101
|
+
- 0
|
102
|
+
version: "0"
|
103
|
+
type: :development
|
104
|
+
version_requirements: *id006
|
105
|
+
description: ""
|
106
|
+
email:
|
71
107
|
- dave@kapoq.com
|
72
108
|
executables: []
|
109
|
+
|
73
110
|
extensions: []
|
111
|
+
|
74
112
|
extra_rdoc_files: []
|
75
|
-
|
113
|
+
|
114
|
+
files:
|
76
115
|
- .gitignore
|
77
116
|
- .travis.yml
|
78
117
|
- CHANGELOG.md
|
@@ -84,34 +123,45 @@ files:
|
|
84
123
|
- lib/guard/jasmine-node.rb
|
85
124
|
- lib/guard/jasmine_node.rb
|
86
125
|
- lib/guard/jasmine_node/runner.rb
|
126
|
+
- lib/guard/jasmine_node/spec_state.rb
|
87
127
|
- lib/guard/jasmine_node/templates/Guardfile
|
88
128
|
- lib/guard/jasmine_node/version.rb
|
89
|
-
- spec/
|
90
|
-
- spec/
|
129
|
+
- spec/lib/jasmine_node_spec.rb
|
130
|
+
- spec/lib/runner_spec.rb
|
131
|
+
- spec/lib/spec_state_spec.rb
|
91
132
|
- spec/spec_helper.rb
|
92
133
|
homepage: https://github.com/kapoq/guard-jasmine-node
|
93
134
|
licenses: []
|
135
|
+
|
94
136
|
post_install_message:
|
95
137
|
rdoc_options: []
|
96
|
-
|
138
|
+
|
139
|
+
require_paths:
|
97
140
|
- lib
|
98
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
142
|
none: false
|
100
|
-
requirements:
|
101
|
-
- -
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
|
104
|
-
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
hash: 3
|
147
|
+
segments:
|
148
|
+
- 0
|
149
|
+
version: "0"
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
151
|
none: false
|
106
|
-
requirements:
|
107
|
-
- -
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
hash: 3
|
156
|
+
segments:
|
157
|
+
- 0
|
158
|
+
version: "0"
|
110
159
|
requirements: []
|
160
|
+
|
111
161
|
rubyforge_project: guard-jasmine-node
|
112
|
-
rubygems_version: 1.8.
|
162
|
+
rubygems_version: 1.8.6
|
113
163
|
signing_key:
|
114
164
|
specification_version: 3
|
115
|
-
summary: Guard::JasmineNode automatically runs your Jasmine Node specs when files
|
116
|
-
are modified
|
165
|
+
summary: Guard::JasmineNode automatically runs your Jasmine Node specs when files are modified
|
117
166
|
test_files: []
|
167
|
+
|
data/spec/spec/runner_spec.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Guard::JasmineNode::Runner do
|
4
|
-
let(:runner) { Guard::JasmineNode::Runner }
|
5
|
-
|
6
|
-
describe ".run" do
|
7
|
-
context "when passed no paths" do
|
8
|
-
it "returns false" do
|
9
|
-
runner.run.should be_false
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
context "when passed paths" do
|
14
|
-
let(:some_paths) { %w(/foo/bar /zip/zap) }
|
15
|
-
|
16
|
-
it "executes jasmine node" do
|
17
|
-
runner.should_receive(:system).with(/__EXECUTABLE__/)
|
18
|
-
runner.run(some_paths, :jasmine_node_bin => "__EXECUTABLE__")
|
19
|
-
end
|
20
|
-
|
21
|
-
context "when message option is given" do
|
22
|
-
it "outputs message" do
|
23
|
-
Guard::UI.should_receive(:info).with("hello", anything)
|
24
|
-
runner.run(some_paths, :message => "hello")
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
context "when no message option is given" do
|
29
|
-
it "outputs default message" do
|
30
|
-
Guard::UI.should_receive(:info).with("Running: /foo/bar /zip/zap", anything)
|
31
|
-
runner.run(some_paths)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|