spec/symphony/tasks/sshscript_spec.rb
changeset 11 ffa70066522c
parent 4 3972315383b3
child 19 f31d60b04f8a
--- a/spec/symphony/tasks/sshscript_spec.rb	Wed May 28 11:45:41 2014 -0700
+++ b/spec/symphony/tasks/sshscript_spec.rb	Thu Jul 12 15:25:35 2018 -0700
@@ -1,17 +1,30 @@
 
 require_relative '../../helpers'
+require 'symphony/tasks/ssh'
 require 'symphony/tasks/sshscript'
 
 context Symphony::Task::SSHScript do
 
 	before( :each ) do
-		described_class.configure(
+		Symphony::Task::SSH.configure(
 			key:  '/tmp/sekrit.rsa',
 			user: 'symphony'
 		)
 	end
 
-	it_should_behave_like "an object with Configurability"
+
+	describe 'utility' do
+
+		it "can generate an appropriate tempfile name" do
+			instance = Class.new( described_class ).new( 'queue' )
+			tmpname = instance.send( :make_remote_filename, "fancy-script.tmpl" )
+			expect( tmpname ).to match( %r|^/tmp/fancy-script-[[:xdigit:]]{6}| )
+
+			tmpname = instance.send( :make_remote_filename, "fancy-script.tmpl", "/var/tmp" )
+			expect( tmpname ).to match( %r|/var/tmp/fancy-script-[[:xdigit:]]{6}| )
+		end
+	end
+
 
 	describe 'subclassed' do
 		let( :instance ) { Class.new(described_class).new('queue') }
@@ -30,7 +43,7 @@
 
 		before( :each ) do
 			allow( Inversion::Template ).to receive( :load ).and_return( template )
-			allow( Dir::Tmpname ).to receive( :make_tmpname ).and_return( "script_temp" )
+			allow( instance ).to receive( :make_remote_filename ).and_return( "/tmp/script_temp" )
 		end
 
 		it "aborts if there is no template in the payload" do