@@ -100,32 +100,35 @@ def set_script_params(path, _options = {})
100
100
end
101
101
102
102
it 'errors when not in a module' do
103
- expect { orch . task_name_from_path ( 'foo/nottasks/init.sh' ) } . to raise_error ( ArgumentError )
103
+ expect { orch . task_name_from_path ( 'foo/nottasks/init.sh' ) }
104
+ . to raise_error ( ArgumentError )
104
105
end
105
106
end
106
107
107
108
describe :_run_task do
108
109
it "executes a task on a host" do
109
110
mock_client
110
- expect ( orch . _run_task ( @taskpath , 'stdin' , @params ) . value ) . to eq ( @result . to_json )
111
+ expect ( orch . _run_task ( @taskpath , 'stdin' , @params ) . value )
112
+ . to eq ( @result . to_json )
111
113
end
112
114
113
115
it "returns a success" do
114
116
mock_client
115
- expect ( orch . _run_task ( @taskpath , 'stdin' , @params ) . class ) . to eq ( Bolt :: Node :: Success )
117
+ expect ( orch . _run_task ( @taskpath , 'stdin' , @params ) ) . to be_success
116
118
end
117
119
118
120
context "the task failed" do
119
121
before ( :each ) { @result_state = 'failed' }
120
122
121
123
it "returns a failure for failed" do
122
124
mock_client
123
- expect ( orch . _run_task ( @taskpath , 'stdin' , @params ) . class ) . to eq ( Bolt :: Node :: Failure )
125
+ expect ( orch . _run_task ( @taskpath , 'stdin' , @params ) ) . not_to be_success
124
126
end
125
127
126
128
it "adds an unkown exitcode when absent" do
127
129
mock_client
128
- expect ( orch . _run_task ( @taskpath , 'stdin' , @params ) . exit_code ) . to eq ( 'unknown' )
130
+ expect ( orch . _run_task ( @taskpath , 'stdin' , @params ) . exit_code )
131
+ . to eq ( 'unknown' )
129
132
end
130
133
131
134
it "uses the exitcode when present" do
@@ -149,7 +152,7 @@ def set_script_params(path, _options = {})
149
152
end
150
153
151
154
it 'it is a success' do
152
- expect ( orch . _run_command ( @command ) . class ) . to eq ( Bolt :: Node :: Success )
155
+ expect ( orch . _run_command ( @command ) ) . to be_success
153
156
end
154
157
155
158
it 'captures stderr' do
@@ -166,7 +169,7 @@ def set_script_params(path, _options = {})
166
169
bolt_task_client
167
170
end
168
171
it 'is a failure' do
169
- expect ( orch . _run_command ( @command ) . class ) . to eq ( Bolt :: Node :: Failure )
172
+ expect ( orch . _run_command ( @command ) ) . not_to be_success
170
173
end
171
174
172
175
it 'captures the exit_code' do
@@ -190,14 +193,15 @@ def set_script_params(path, _options = {})
190
193
describe :_upload do
191
194
it 'should write the file' do
192
195
Dir . mktmpdir ( nil , '/tmp' ) do |dir |
193
- source_path = File . join ( base_path , 'spec' , 'fixtures' , 'scripts' , 'success.sh' )
196
+ source_path = File . join ( base_path , 'spec' , 'fixtures' ,
197
+ 'scripts' , 'success.sh' )
194
198
dest_path = File . join ( dir , "success.sh" )
195
199
196
200
set_upload_params ( source_path , dest_path )
197
201
bolt_task_client
198
202
result = orch . _upload ( source_path , dest_path )
199
203
200
- expect ( result . class ) . to eq ( Bolt :: Node :: Success )
204
+ expect ( result ) . to be_success
201
205
202
206
source_mode = File . stat ( source_path ) . mode
203
207
dest_mode = File . stat ( dest_path ) . mode
@@ -213,7 +217,7 @@ def set_script_params(path, _options = {})
213
217
describe :_run_script do
214
218
context "the script succeeds" do
215
219
let ( :script_path ) do
216
- File . expand_path ( File . join ( base_path , 'spec' , 'fixtures' , 'scripts' , 'success.sh' ) )
220
+ File . join ( base_path , 'spec' , 'fixtures' , 'scripts' , 'success.sh' )
217
221
end
218
222
219
223
before ( :each ) do
@@ -222,7 +226,7 @@ def set_script_params(path, _options = {})
222
226
end
223
227
224
228
it 'is a success' do
225
- expect ( orch . _run_script ( script_path ) . class ) . to eq ( Bolt :: Node :: Success )
229
+ expect ( orch . _run_script ( script_path ) ) . to be_success
226
230
end
227
231
228
232
it 'captures stdout' do
@@ -238,7 +242,7 @@ def set_script_params(path, _options = {})
238
242
239
243
context "when the script fails" do
240
244
let ( :script_path ) do
241
- File . expand_path ( File . join ( base_path , 'spec' , 'fixtures' , 'scripts' , 'failure.sh' ) )
245
+ File . join ( base_path , 'spec' , 'fixtures' , 'scripts' , 'failure.sh' )
242
246
end
243
247
244
248
before ( :each ) do
@@ -247,7 +251,7 @@ def set_script_params(path, _options = {})
247
251
end
248
252
249
253
it 'returns a failure' do
250
- expect ( orch . _run_script ( script_path ) . class ) . to eq ( Bolt :: Node :: Failure )
254
+ expect ( orch . _run_script ( script_path ) ) . not_to be_success
251
255
end
252
256
253
257
it 'captures exit_code' do
0 commit comments