guard-mocha-node 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae8b7b547d5bc0fddacd89dbabb3a40dbc2b160b
4
- data.tar.gz: 8997479c237892833a1953cee52ce0738b96ed87
3
+ metadata.gz: ef3935e2938c11f5fdcd34aa6fd3692fdc46d9ba
4
+ data.tar.gz: c2fe24f694f378c05cd3531e0031471882e8cd34
5
5
  SHA512:
6
- metadata.gz: 055b68bea222173bf83028fbc186d0af90bd8589fa4e67de27a82997ae2fde4205ca936e149d722b87f0df9b71ee2888c62d8ad522af89be9f87d1c32049e7ed
7
- data.tar.gz: f951c9910b9561bcffb64823a335d2181cdb325ba454e225dec087ca88d6179c201bc0d9caa549552a7a637f686fbe8cac8cced98800dd903e06361ae5019159
6
+ metadata.gz: b9867a0c2be875a7c97ef1835de2ab14bdb2e5645f3b6eb268c8e3dff3137a0a9b2402d03e0ee762d8d1eb123874af4d55911b575cd6a9501cfdf59d68a78f95
7
+ data.tar.gz: 4c8c3fb0c17fdde975d241c8eb37fa119dd502833aca3817c047f3837b766bc6349fe9d3020290e67c192591c7eda8a0b08961ac0a7012d7bce187f45eb30159
@@ -1,4 +1,3 @@
1
- require 'open3'
2
1
  require 'guard/ui'
3
2
 
4
3
  module Guard
@@ -18,13 +17,13 @@ module Guard
18
17
 
19
18
  def self.print_message
20
19
  message = @options[:message]
21
- is_all_specs = @paths.sort == @options[:paths_for_all_specs].sort
20
+ is_all_specs = @paths.sort == @options[:paths_for_all_specs].sort
22
21
  message ||= is_all_specs ? "Running all specs" : "Running: #{@paths.join(' ')}"
23
22
  ::Guard::UI.info(message, :reset => true)
24
23
  end
25
24
 
26
25
  def self.execute_mocha_node_command
27
- ::Open3.popen3(*mocha_node_command)
26
+ Kernel.system(*mocha_node_command)
28
27
  end
29
28
 
30
29
  def self.mocha_node_command
@@ -36,34 +35,34 @@ module Guard
36
35
 
37
36
  def self.command_line_options
38
37
  options = []
39
- compilers = []
38
+ compilers = []
40
39
 
41
40
  if @options[:coffeescript]
42
41
  compilers << "coffee:coffee-script"
43
42
  end
44
43
 
45
- if @options[:livescript]
44
+ if @options[:livescript]
46
45
  compilers << "ls:LiveScript"
47
46
  end
48
47
 
49
- if not compilers.empty?
50
- options << "--compilers"
51
- options << compilers.join(",")
52
- end
48
+ if not compilers.empty?
49
+ options << "--compilers"
50
+ options << compilers.join(",")
51
+ end
53
52
 
54
53
  if @options[:recursive]
55
54
  options << "--recursive"
56
55
  end
57
56
 
58
- if @options[:require]
59
- r = @options[:require]
60
- r = [r] if not r.instance_of? Array
57
+ if @options[:require]
58
+ r = @options[:require]
59
+ r = [r] if not r.instance_of? Array
61
60
 
62
- r.each { |e|
63
- options << "-r"
64
- options << e
65
- }
66
- end
61
+ r.each { |e|
62
+ options << "-r"
63
+ options << e
64
+ }
65
+ end
67
66
 
68
67
  if @options[:color]
69
68
  options << "-c"
@@ -81,8 +80,8 @@ module Guard
81
80
  options << @options[:reporter]
82
81
  end
83
82
 
84
- # puts "---- printing the options"
85
- # puts options
83
+ # puts "---- printing the options"
84
+ # puts options
86
85
  options
87
86
  end
88
87
  end
@@ -1,14 +1,6 @@
1
1
  module Guard
2
2
  class MochaNode
3
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
4
  attr_accessor :failing_paths
13
5
 
14
6
  def initialize
@@ -17,17 +9,7 @@ module Guard
17
9
 
18
10
  def update(run_paths = [], options = {})
19
11
  @run_paths = run_paths
20
- @io = Runner.run(@run_paths, options)
21
- @stdout = @io[STDOUT]
22
- @stderr = @io[STDERR]
23
- # stream stdout immediately
24
- until @stdout.eof?
25
- line = @stdout.gets
26
- print line if !line.strip.empty?
27
- end
28
- @stderr.each { |line| print line }
29
- @exitstatus = @io[THREAD].value rescue ERROR_CODE
30
- close_io
12
+ @exitok = Runner.run(@run_paths, options)
31
13
  update_passed_and_fixed
32
14
  update_failing_paths
33
15
  passing?
@@ -49,13 +31,9 @@ module Guard
49
31
 
50
32
  private
51
33
 
52
- def close_io
53
- @io[STDIN..STDERR].each { |s| s.close }
54
- end
55
-
56
34
  def update_passed_and_fixed
57
35
  previously_failed = !passing?
58
- @passed = @exitstatus == SUCCESS_CODE
36
+ @passed = @exitok
59
37
  @fixed = @passed && previously_failed
60
38
  end
61
39
 
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module MochaNodeVersion
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
@@ -4,7 +4,7 @@ describe Guard::MochaNode::Runner do
4
4
  let(:runner) { Guard::MochaNode::Runner }
5
5
 
6
6
  before do
7
- Open3.stub(:popen3 => "response")
7
+ Kernel.stub(:system => "response")
8
8
  end
9
9
 
10
10
  describe ".run" do
@@ -19,118 +19,118 @@ describe Guard::MochaNode::Runner do
19
19
  let(:some_paths) { %w(/foo/bar /zip/zap) }
20
20
 
21
21
  it "executes mocha node" do
22
- Open3.should_receive(:popen3) do |*args|
23
- args[0].should eq "__EXECUTABLE__"
24
- end
22
+ Kernel.should_receive(:system) do |*args|
23
+ args[0].should eq "__EXECUTABLE__"
24
+ end
25
25
  runner.run(some_paths, options.merge({ :mocha_bin => "__EXECUTABLE__"}))
26
26
  end
27
27
 
28
28
  it "passes the paths to the executable" do
29
- Open3.should_receive(:popen3) do |*args|
30
- last_args = args[(some_paths.length * -1)..(-1)]
31
- last_args.should eql some_paths
32
- end
29
+ Kernel.should_receive(:system) do |*args|
30
+ last_args = args[(some_paths.length * -1)..(-1)]
31
+ last_args.should eql some_paths
32
+ end
33
33
  runner.run(some_paths, options)
34
34
  end
35
35
 
36
36
  context "and coffeescript option is true" do
37
37
  it "passes the --compilers coffee:coffee-script option to mocha node" do
38
- Open3.should_receive(:popen3) do |*args|
39
- index_compilers = args.find_index "--compilers"
40
- index_compilers.should_not be nil
41
- args[index_compilers +1].should eql "coffee:coffee-script"
42
- end
43
- runner.run(some_paths, options.merge({ :coffeescript => true}))
38
+ Kernel.should_receive(:system) do |*args|
39
+ index_compilers = args.find_index "--compilers"
40
+ index_compilers.should_not be nil
41
+ args[index_compilers +1].should eql "coffee:coffee-script"
42
+ end
43
+ runner.run(some_paths, options.merge({ :coffeescript => true}))
44
44
  end
45
45
  end
46
46
 
47
47
  context "and coffeescript option is false" do
48
48
  it "does not pass the --compilers coffee:coffee-script option to mocha node" do
49
- Open3.should_receive(:popen3) do |*args|
50
- index_compilers = args.find_index "--compilers"
51
- if index_compilers != nil
52
- args[index_compilers +1].should_not match /coffee:coffee-script/
53
- end
54
- end
49
+ Kernel.should_receive(:system) do |*args|
50
+ index_compilers = args.find_index "--compilers"
51
+ if index_compilers != nil
52
+ args[index_compilers +1].should_not match /coffee:coffee-script/
53
+ end
54
+ end
55
55
  runner.run(some_paths, options.merge({ :coffeescript => false}))
56
56
  end
57
57
  end
58
58
 
59
59
  context "and livescript option is true" do
60
60
  it "passes the --compilers ls:LiveScript option to mocha node" do
61
- Open3.should_receive(:popen3) do |*args|
62
- index_compilers = args.find_index "--compilers"
63
- index_compilers.should_not be nil
64
- args[index_compilers +1].should eql "ls:LiveScript"
65
- end
66
- runner.run(some_paths, options.merge({ :livescript => true}))
61
+ Kernel.should_receive(:system) do |*args|
62
+ index_compilers = args.find_index "--compilers"
63
+ index_compilers.should_not be nil
64
+ args[index_compilers +1].should eql "ls:LiveScript"
65
+ end
66
+ runner.run(some_paths, options.merge({ :livescript => true}))
67
67
  end
68
68
  end
69
69
 
70
70
  context "and livescript option is false" do
71
71
  it "does not pass the --compilers ls:LiveScript option to mocha node" do
72
- Open3.should_receive(:popen3) do |*args|
73
- index_compilers = args.find_index "--compilers"
74
- if index_compilers != nil
75
- args[index_compilers +1].should_not match /ls:LiveScript/
76
- end
77
- end
72
+ Kernel.should_receive(:system) do |*args|
73
+ index_compilers = args.find_index "--compilers"
74
+ if index_compilers != nil
75
+ args[index_compilers +1].should_not match /ls:LiveScript/
76
+ end
77
+ end
78
78
  runner.run(some_paths, options.merge({ :livescript => false}))
79
79
  end
80
80
  end
81
81
 
82
82
  context "and both coffeescript and livescript option are true" do
83
83
  it "passes the --compilers coffee:coffee-script,ls:LiveScript option to mocha node" do
84
- Open3.should_receive(:popen3) do |*args|
85
- index_compilers = args.find_index "--compilers"
86
- index_compilers.should_not be nil
87
- args[index_compilers +1].should eql "coffee:coffee-script,ls:LiveScript"
88
- end
89
- runner.run(some_paths, options.merge({ :livescript => true, :coffeescript => true }))
84
+ Kernel.should_receive(:system) do |*args|
85
+ index_compilers = args.find_index "--compilers"
86
+ index_compilers.should_not be nil
87
+ args[index_compilers +1].should eql "coffee:coffee-script,ls:LiveScript"
88
+ end
89
+ runner.run(some_paths, options.merge({ :livescript => true, :coffeescript => true }))
90
90
  end
91
91
  end
92
92
 
93
93
  context "and color option is true" do
94
94
  it "passes the -c option to mocha node" do
95
- Open3.should_receive(:popen3) do |*args|
96
- args.should include "-c"
97
- end
95
+ Kernel.should_receive(:system) do |*args|
96
+ args.should include "-c"
97
+ end
98
98
  runner.run(some_paths, options.merge({ :color => true}))
99
99
  end
100
100
  end
101
101
 
102
102
  context "and color option is false" do
103
103
  it "passes the -C option to mocha node" do
104
- Open3.should_receive(:popen3) do |*args|
105
- args.should include "-C"
106
- end
104
+ Kernel.should_receive(:system) do |*args|
105
+ args.should include "-C"
106
+ end
107
107
  runner.run(some_paths, options.merge({ :color => false}))
108
108
  end
109
109
  end
110
110
 
111
111
  context "and globals option is set" do
112
112
  it "passes the --globals option to mocha node" do
113
- Open3.should_receive(:popen3) do |*args|
114
- args.should include("--globals", "Foo")
113
+ Kernel.should_receive(:system) do |*args|
114
+ args.should include("--globals", "Foo")
115
115
  # ensure ordering
116
116
  args[args.index("--globals") + 1].should eql("Foo")
117
- end
117
+ end
118
118
  runner.run(some_paths, options.merge({ :globals => ['Foo']}))
119
119
  end
120
120
  end
121
121
 
122
122
  context "and globals option is empty" do
123
123
  it "does not pass the --globals option to mocha node" do
124
- Open3.should_receive(:popen3) do |*args|
125
- args.should_not include "--globals"
126
- end
124
+ Kernel.should_receive(:system) do |*args|
125
+ args.should_not include "--globals"
126
+ end
127
127
  runner.run(some_paths, options.merge({ :globals => []}))
128
128
  end
129
129
  end
130
130
 
131
131
  context "and reporter option is set" do
132
132
  it "passes the --reporter option to mocha node" do
133
- Open3.should_receive(:popen3) do |*args|
133
+ Kernel.should_receive(:system) do |*args|
134
134
  args.should include("--reporter", "Foo")
135
135
  # ensure ordering
136
136
  args[args.index("--reporter") + 1].should eql("Foo")
@@ -141,7 +141,7 @@ describe Guard::MochaNode::Runner do
141
141
 
142
142
  context "and reporter option is not set" do
143
143
  it "does not pass the --reporter option to mocha node" do
144
- Open3.should_receive(:popen3) do |*args|
144
+ Kernel.should_receive(:system) do |*args|
145
145
  args.should_not include "--reporter"
146
146
  end
147
147
  runner.run(some_paths, options)
@@ -150,57 +150,57 @@ describe Guard::MochaNode::Runner do
150
150
 
151
151
  context "and recursive option is true" do
152
152
  it "passes the --recursive option to mocha node" do
153
- Open3.should_receive(:popen3) do |*args|
154
- args.should include "--recursive"
155
- end
153
+ Kernel.should_receive(:system) do |*args|
154
+ args.should include "--recursive"
155
+ end
156
156
  runner.run(some_paths, options.merge({ :recursive => true}))
157
157
  end
158
158
  end
159
159
 
160
160
  context "and recursive option is false" do
161
161
  it "does not pass the --recursive option to mocha node" do
162
- Open3.should_receive(:popen3) do |*args|
163
- args.should_not include "--recursive"
164
- end
162
+ Kernel.should_receive(:system) do |*args|
163
+ args.should_not include "--recursive"
164
+ end
165
165
  runner.run(some_paths, options.merge({ :recursive => false}))
166
166
  end
167
167
  end
168
168
 
169
169
  context "and require option is 'should'" do
170
170
  it "passes the '-r should' option to mocha node" do
171
- Open3.should_receive(:popen3) do |*args|
172
- require_index = args.find_index '-r'
173
- require_index.should_not eq nil
174
- args[require_index+1].should eql "should"
175
- end
171
+ Kernel.should_receive(:system) do |*args|
172
+ require_index = args.find_index '-r'
173
+ require_index.should_not eq nil
174
+ args[require_index+1].should eql "should"
175
+ end
176
176
  runner.run(some_paths, options.merge({ :require => 'should'}))
177
177
  end
178
178
  end
179
179
 
180
180
  context "and require option is ['should', 'chai']" do
181
181
  it "passes the '-r should -r chai' option to mocha node" do
182
- Open3.should_receive(:popen3) do |*args|
183
- args.each_with_index.
184
- reject{ |e,i| e != '-r' }.
185
- map{ |e,i| args[i+1] }.should eql ["should", "chai"]
182
+ Kernel.should_receive(:system) do |*args|
183
+ args.each_with_index.
184
+ reject{ |e,i| e != '-r' }.
185
+ map{ |e,i| args[i+1] }.should eql ["should", "chai"]
186
186
 
187
- end
187
+ end
188
188
  runner.run(some_paths, options.merge({ :require => ['should', 'chai'] }))
189
189
  end
190
190
  end
191
191
 
192
192
  context "and require option is nil" do
193
193
  it "does not pass the -r option to mocha node" do
194
- Open3.should_receive(:popen3) do |*args|
195
- args.should_not include "-r"
196
- end
194
+ Kernel.should_receive(:system) do |*args|
195
+ args.should_not include "-r"
196
+ end
197
197
  runner.run(some_paths, options.merge({ :require => nil}))
198
198
  end
199
199
  end
200
200
 
201
201
  it "returns IO object" do
202
202
  io_obj = double("io obj")
203
- Open3.stub(:popen3 => io_obj)
203
+ Kernel.stub(:system => io_obj)
204
204
  runner.run(some_paths, options).should eql io_obj
205
205
  end
206
206
 
@@ -19,32 +19,20 @@ describe Guard::MochaNode::SpecState do
19
19
  end
20
20
 
21
21
  describe "#update" do
22
- let(:io) { [
23
- double("stdin", :close => true),
24
- double("stdout", :close => true, :lines => [], :eof? => true),
25
- double("stderr", :close => true, :each => []),
26
- double("thread", :value => 0)
27
- ] }
28
22
  let(:some_paths) { %w(some paths) }
29
23
  let(:some_options) { double("some options") }
30
24
 
31
25
  before do
32
- runner.stub(:run => io)
26
+ runner.stub(:run => true)
33
27
  end
34
28
 
35
29
  it "runs the runner with the paths and options" do
36
- runner.should_receive(:run).with(some_paths, some_options).and_return(io)
30
+ runner.should_receive(:run).with(some_paths, some_options).and_return(true)
37
31
  state.update(some_paths, some_options)
38
32
  end
39
33
 
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
34
  context "when the runner process exit value is zero" do
46
35
  before do
47
- io[3].stub(:value => 0)
48
36
  state.update
49
37
  end
50
38
 
@@ -94,7 +82,7 @@ describe Guard::MochaNode::SpecState do
94
82
 
95
83
  context "when the runner process exit value is not zero" do
96
84
  before do
97
- io[3].stub(:value => 1)
85
+ runner.stub(:run => false)
98
86
  state.update(some_paths, some_options)
99
87
  end
100
88
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-mocha-node
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - dave@kapoq.com
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-13 00:00:00.000000000 Z
12
+ date: 2013-08-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard