@@ -35,38 +35,15 @@ describe('Unit: Doctor Checks > Install', function () {
35
35
} ) ;
36
36
37
37
describe ( 'node version check' , function ( ) {
38
- it ( 'rejects if global bin is different than the one ghost is running from' , function ( ) {
39
- const execaStub = sinon . stub ( ) . returns ( { stdout : '/usr/local/bin' } ) ;
40
- const originalArgv = process . argv ;
41
- process . argv = [ 'node' , '/home/ghost/.nvm/versions/6.11.1/bin' ] ;
42
-
43
- const task = proxyquire ( modulePath , {
44
- execa : { shellSync : execaStub }
45
- } ) . tasks . nodeVersion ;
46
-
47
- return task ( ) . then ( ( ) => {
48
- expect ( false , 'error should be thrown' ) . to . be . true ;
49
- process . argv = originalArgv ;
50
- } ) . catch ( ( error ) => {
51
- process . argv = originalArgv ;
52
- expect ( error ) . to . be . an . instanceof ( errors . SystemError ) ;
53
- expect ( error . message ) . to . match ( / v e r s i o n o f G h o s t - C L I y o u a r e r u n n i n g w a s n o t i n s t a l l e d w i t h t h i s v e r s i o n o f N o d e ./ ) ;
54
- expect ( execaStub . calledOnce ) . to . be . true ;
55
- expect ( execaStub . calledWithExactly ( 'npm bin -g' , { preferLocal : false } ) ) . to . be . true ;
56
- } ) ;
57
- } ) ;
58
-
59
38
it ( 'rejects if node version is not in range' , function ( ) {
60
39
const cliPackage = {
61
40
engines : {
62
41
node : '0.10.0'
63
42
}
64
43
} ;
65
- const execaStub = sinon . stub ( ) . returns ( { stdout : process . argv [ 1 ] } ) ;
66
44
67
45
const task = proxyquire ( modulePath , {
68
- '../../../../package' : cliPackage ,
69
- execa : { shellSync : execaStub }
46
+ '../../../../package' : cliPackage
70
47
} ) . tasks . nodeVersion ;
71
48
72
49
return task ( ) . then ( ( ) => {
@@ -77,7 +54,6 @@ describe('Unit: Doctor Checks > Install', function () {
77
54
78
55
expect ( message ) . to . match ( / S u p p o r t e d : 0 .1 0 .0 / ) ;
79
56
expect ( message ) . to . match ( new RegExp ( `Installed: ${ process . versions . node } ` ) ) ;
80
- expect ( execaStub . calledOnce ) . to . be . true ;
81
57
} ) ;
82
58
} ) ;
83
59
@@ -87,19 +63,16 @@ describe('Unit: Doctor Checks > Install', function () {
87
63
node : process . versions . node // this future-proofs the test
88
64
}
89
65
} ;
90
- const execaStub = sinon . stub ( ) . returns ( { stdout : '/usr/local/bin' } ) ;
91
66
const originalArgv = process . argv ;
92
67
process . argv = [ 'node' , path . join ( __dirname , '../../../../bin/ghost' ) ] ;
93
68
94
69
const tasks = proxyquire ( modulePath , {
95
- '../../../../package' : cliPackage ,
96
- execa : { shellSync : execaStub }
70
+ '../../../../package' : cliPackage
97
71
} ) . tasks ;
98
72
const checkDirectoryStub = sinon . stub ( tasks , 'checkDirectoryAndAbove' ) . resolves ( ) ;
99
73
100
74
return tasks . nodeVersion ( { local : true } ) . then ( ( ) => {
101
75
process . argv = originalArgv ;
102
- expect ( execaStub . calledOnce ) . to . be . true ;
103
76
expect ( checkDirectoryStub . called ) . to . be . false ;
104
77
} ) ;
105
78
} ) ;
@@ -112,17 +85,14 @@ describe('Unit: Doctor Checks > Install', function () {
112
85
}
113
86
} ;
114
87
process . env = { GHOST_NODE_VERSION_CHECK : 'false' } ;
115
- const execaStub = sinon . stub ( ) . returns ( { stdout : process . argv [ 1 ] } ) ;
116
88
117
89
const tasks = proxyquire ( modulePath , {
118
- '../../../../package' : cliPackage ,
119
- execa : { shellSync : execaStub }
90
+ '../../../../package' : cliPackage
120
91
} ) . tasks ;
121
92
const checkDirectoryStub = sinon . stub ( tasks , 'checkDirectoryAndAbove' ) . resolves ( ) ;
122
93
123
94
return tasks . nodeVersion ( { local : true } ) . then ( ( ) => {
124
95
process . env = originalEnv ;
125
- expect ( execaStub . calledOnce ) . to . be . true ;
126
96
expect ( checkDirectoryStub . called ) . to . be . false ;
127
97
} ) ;
128
98
} ) ;
@@ -133,16 +103,13 @@ describe('Unit: Doctor Checks > Install', function () {
133
103
node : process . versions . node // this future-proofs the test
134
104
}
135
105
} ;
136
- const execaStub = sinon . stub ( ) . returns ( { stdout : process . argv [ 1 ] } ) ;
137
106
138
107
const tasks = proxyquire ( modulePath , {
139
- '../../../../package' : cliPackage ,
140
- execa : { shellSync : execaStub }
108
+ '../../../../package' : cliPackage
141
109
} ) . tasks ;
142
110
const checkDirectoryStub = sinon . stub ( tasks , 'checkDirectoryAndAbove' ) . resolves ( ) ;
143
111
144
112
return tasks . nodeVersion ( { local : true } ) . then ( ( ) => {
145
- expect ( execaStub . calledOnce ) . to . be . true ;
146
113
expect ( checkDirectoryStub . called ) . to . be . false ;
147
114
} ) ;
148
115
} ) ;
@@ -153,18 +120,15 @@ describe('Unit: Doctor Checks > Install', function () {
153
120
node : process . versions . node // this future-proofs the test
154
121
}
155
122
} ;
156
- const execaStub = sinon . stub ( ) . returns ( { stdout : process . argv [ 1 ] } ) ;
157
123
const platformStub = sinon . stub ( ) . returns ( 'darwin' ) ;
158
124
159
125
const tasks = proxyquire ( modulePath , {
160
126
'../../../../package' : cliPackage ,
161
- execa : { shellSync : execaStub } ,
162
127
os : { platform : platformStub }
163
128
} ) . tasks ;
164
129
const checkDirectoryStub = sinon . stub ( tasks , 'checkDirectoryAndAbove' ) . resolves ( ) ;
165
130
166
131
return tasks . nodeVersion ( { local : false } ) . then ( ( ) => {
167
- expect ( execaStub . calledOnce ) . to . be . true ;
168
132
expect ( checkDirectoryStub . called ) . to . be . false ;
169
133
} ) ;
170
134
} ) ;
@@ -175,18 +139,15 @@ describe('Unit: Doctor Checks > Install', function () {
175
139
node : process . versions . node // this future-proofs the test
176
140
}
177
141
} ;
178
- const execaStub = sinon . stub ( ) . returns ( { stdout : process . argv [ 1 ] } ) ;
179
142
const platformStub = sinon . stub ( ) . returns ( 'linux' ) ;
180
143
181
144
const tasks = proxyquire ( modulePath , {
182
145
'../../../../package' : cliPackage ,
183
- execa : { shellSync : execaStub } ,
184
146
os : { platform : platformStub }
185
147
} ) . tasks ;
186
148
const checkDirectoryStub = sinon . stub ( tasks , 'checkDirectoryAndAbove' ) . resolves ( ) ;
187
149
188
150
return tasks . nodeVersion ( { local : false , argv : { 'setup-linux-user' : false } } ) . then ( ( ) => {
189
- expect ( execaStub . calledOnce ) . to . be . true ;
190
151
expect ( checkDirectoryStub . called ) . to . be . false ;
191
152
} ) ;
192
153
} ) ;
@@ -197,18 +158,15 @@ describe('Unit: Doctor Checks > Install', function () {
197
158
node : process . versions . node // this future-proofs the test
198
159
}
199
160
} ;
200
- const execaStub = sinon . stub ( ) . returns ( { stdout : process . argv [ 1 ] } ) ;
201
161
const platformStub = sinon . stub ( ) . returns ( 'linux' ) ;
202
162
203
163
const tasks = proxyquire ( modulePath , {
204
164
'../../../../package' : cliPackage ,
205
- execa : { shellSync : execaStub } ,
206
165
os : { platform : platformStub }
207
166
} ) . tasks ;
208
167
const checkDirectoryStub = sinon . stub ( tasks , 'checkDirectoryAndAbove' ) . resolves ( ) ;
209
168
210
169
return tasks . nodeVersion ( { local : false , argv : { 'setup-linux-user' : true } } ) . then ( ( ) => {
211
- expect ( execaStub . calledOnce ) . to . be . true ;
212
170
expect ( checkDirectoryStub . calledOnce ) . to . be . true ;
213
171
expect ( checkDirectoryStub . calledWith ( process . argv [ 0 ] ) ) . to . be . true ;
214
172
} ) ;
0 commit comments