spec/command_spec.rb in dev_tasks-1.0.27 vs spec/command_spec.rb in dev_tasks-1.0.28
- old
+ new
@@ -1,80 +1,80 @@
-require_relative '../lib/command.rb'
-
-describe Command do
- it "should be able to execute ruby --version command" do
- cmd=Command.new("ruby --version")
- # Timeout
- expect(cmd[:timeout]).to eq(0)
- cmd[:timeout]=3000
- expect(cmd[:timeout]).to eq(3000)
-
- # Directory
- expect(cmd[:directory]).to eq("")
- cmd[:directory] = File.dirname(__FILE__)
- expect(cmd[:directory]).to eq(File.dirname(__FILE__))
-
- # ExitCode
- expect(cmd[:exit_code]).to eq(0)
- cmd[:exit_code] = 1
- expect(cmd[:exit_code]).to eq(1)
-
- # Input
- expect(cmd[:input]).to eq("ruby --version")
- cmd2 = Command.new('')
- expect(cmd2[:input]).to eq('')
-
- # Output
- expect(cmd[:output]).to eq('')
- cmd[:output]='test'
- expect(cmd[:output]).to eq('test')
-
- # Error
- expect(cmd[:error]).to eq('')
- cmd[:error]='error_test'
- expect(cmd[:error]).to eq('error_test')
-
- # MachineName
- expect(cmd[:machine_name]).to eq('')
- cmd[:machine_name]='machine_name_test'
- expect(cmd[:machine_name]).to eq('machine_name_test')
-
- # UserName
- expect(cmd[:user_name]).to eq('')
- cmd[:user_name]='user_name_test'
- expect(cmd[:user_name]).to eq('user_name_test')
-
- # StartTime
- expect(cmd[:start_time]).to eq(nil)
- cmd[:start_time]=Time.now
- expect(cmd[:start_time]).not_to eq(nil)
-
- # EndTime
- expect(cmd[:end_time]).to eq(nil)
- cmd[:end_time]=Time.now
- expect(cmd[:end_time]).not_to eq(nil)
-
- end
-
- it "should be able to write to/load from JSON" do
- cmd=Command.new("ruby --version")
- expect(cmd[:timeout]).to eq(0)
- expect(cmd[:input]).to eq("ruby --version")
- cmd2=Command.new(JSON.parse(cmd.to_json))
- expect(cmd2[:timeout]).to eq(0)
- expect(cmd2[:input]).to eq("ruby --version")
- end
-
- it "should be able to execute rake command in specific directory" do
- dir="#{DEV[:dev_root]}/tmp/rake_test"
- FileUtils.mkdir_p(dir) if(!File.exists?(dir))
- File.open("#{dir}/rakefile.rb","w") { |f|
- f.puts "task :default do"
- f.puts " puts 'rake_test'"
- f.puts "end"
- }
- cmd=Command.new("rake")
- cmd[:directory]=dir
- cmd.execute
- expect(cmd[:output].include?('rake_test')).to eq(true)
- end
+require_relative '../lib/command.rb'
+
+describe Command do
+ it "should be able to execute ruby --version command" do
+ cmd=Command.new("ruby --version")
+ # Timeout
+ expect(cmd[:timeout]).to eq(0)
+ cmd[:timeout]=3000
+ expect(cmd[:timeout]).to eq(3000)
+
+ # Directory
+ expect(cmd[:directory]).to eq("")
+ cmd[:directory] = File.dirname(__FILE__)
+ expect(cmd[:directory]).to eq(File.dirname(__FILE__))
+
+ # ExitCode
+ expect(cmd[:exit_code]).to eq(0)
+ cmd[:exit_code] = 1
+ expect(cmd[:exit_code]).to eq(1)
+
+ # Input
+ expect(cmd[:input]).to eq("ruby --version")
+ cmd2 = Command.new('')
+ expect(cmd2[:input]).to eq('')
+
+ # Output
+ expect(cmd[:output]).to eq('')
+ cmd[:output]='test'
+ expect(cmd[:output]).to eq('test')
+
+ # Error
+ expect(cmd[:error]).to eq('')
+ cmd[:error]='error_test'
+ expect(cmd[:error]).to eq('error_test')
+
+ # MachineName
+ expect(cmd[:machine_name]).to eq('')
+ cmd[:machine_name]='machine_name_test'
+ expect(cmd[:machine_name]).to eq('machine_name_test')
+
+ # UserName
+ expect(cmd[:user_name]).to eq('')
+ cmd[:user_name]='user_name_test'
+ expect(cmd[:user_name]).to eq('user_name_test')
+
+ # StartTime
+ expect(cmd[:start_time]).to eq(nil)
+ cmd[:start_time]=Time.now
+ expect(cmd[:start_time]).not_to eq(nil)
+
+ # EndTime
+ expect(cmd[:end_time]).to eq(nil)
+ cmd[:end_time]=Time.now
+ expect(cmd[:end_time]).not_to eq(nil)
+
+ end
+
+ it "should be able to write to/load from JSON" do
+ cmd=Command.new("ruby --version")
+ expect(cmd[:timeout]).to eq(0)
+ expect(cmd[:input]).to eq("ruby --version")
+ cmd2=Command.new(JSON.parse(cmd.to_json))
+ expect(cmd2[:timeout]).to eq(0)
+ expect(cmd2[:input]).to eq("ruby --version")
+ end
+
+ it "should be able to execute rake command in specific directory" do
+ dir="#{DEV[:dev_root]}/tmp/rake_test"
+ FileUtils.mkdir_p(dir) if(!File.exists?(dir))
+ File.open("#{dir}/rakefile.rb","w") { |f|
+ f.puts "task :default do"
+ f.puts " puts 'rake_test'"
+ f.puts "end"
+ }
+ cmd=Command.new("rake")
+ cmd[:directory]=dir
+ cmd.execute
+ expect(cmd[:output].include?('rake_test')).to eq(true)
+ end
end
\ No newline at end of file