Permalink
Browse files

capture output into log

  • Loading branch information...
1 parent 69169a9 commit 87e9fa50ddcede07f68c6ae7e45607353a826a57 @tpitale committed Sep 15, 2011
Showing with 6 additions and 7 deletions.
  1. +0 −1 lib/server.rb
  2. +1 −1 models/project.rb
  3. +5 −5 spec/models/project_spec.rb
View
@@ -31,7 +31,6 @@
deploy_complete = lambda { |*args|
puts "Deploy Complete!"
- p args
websocket.send({'status' => 'complete', 'log' => args.first}.to_json)
}
View
@@ -37,7 +37,7 @@ def log_filename(stage)
def deploy_to(stage)
if stages.include?(stage)
- deploy_logs = system("cap -S stage=#{stage} -f Capfile -f #{deploy_path} -f #{deploy_path(stage)} -n deploy")
+ deploy_logs = `cap -S stage=#{stage} -f Capfile -f #{deploy_path} -f #{deploy_path(stage)} -n deploy 2>&1`
File.open(log_filename(stage), 'w') {|f| f.write(deploy_logs)}
end
end
@@ -36,23 +36,23 @@
it "deploys to a given stage" do
File.stubs(:open).yields(stub(:write))
@project.stubs(:stages).returns(["staging"])
- @project.stubs(:system).returns("a log of data")
+ @project.stubs(:`).returns("a log of data")
@project.deploy_to("staging")
- @project.should have_received(:system).with("cap -S stage=staging -f Capfile -f /projects/opower/deploy.rb -f /projects/opower/deploy/staging.rb -n deploy")
+ @project.should have_received(:`).with("cap -S stage=staging -f Capfile -f /projects/opower/deploy.rb -f /projects/opower/deploy/staging.rb -n deploy 2>&1")
end
it "doesn't deploy to an unknown stage" do
@project.stubs(:stages).returns(["staging"])
- @project.stubs(:system)
+ @project.stubs(:`)
@project.deploy_to("production")
- @project.should have_received(:system).never
+ @project.should have_received(:`).never
end
it "writes the deploy log returned to a logfile" do
file = stub(:write)
File.stubs(:open).yields(file)
@project.stubs(:stages).returns(["staging"])
- @project.stubs(:system).returns("log log log")
+ @project.stubs(:`).returns("log log log")
@project.deploy_to("staging")
file.should have_received(:write).with("log log log")
end

0 comments on commit 87e9fa5

Please sign in to comment.