Skip to content

Commit

Permalink
Start server once in Rake task
Browse files Browse the repository at this point in the history
(And actually kill it again)
  • Loading branch information
mark-rushakoff committed Apr 6, 2012
1 parent a352e20 commit 0a90976
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
14 changes: 13 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
#!/usr/bin/env rake

require 'rubygems'
require 'bundler'
Bundler.require
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = 'spec/*_spec.rb'
t.verbose = true
end

task :default => :spec
def start_server
require 'spec_helper'
OpsHelper::start_server_once
end

task :start_server_and_run_specs do
start_server
Rake::Task['spec'].execute
end

task :default => :start_server_and_run_specs
7 changes: 4 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ def start_server_once
return if @started
@started = true
assert_has_phantomjs
start_server
server_pid = start_server
ensure_server_started
at_exit do
Process.kill('TERM', server_pid)
end
end

def assert_has_phantomjs
Expand Down Expand Up @@ -53,8 +56,6 @@ def ensure_server_started
end
end

OpsHelper::start_server_once

shared_examples_for 'correct failures' do
it 'fails when no url is given' do
%x{phantomjs #{script}}
Expand Down

0 comments on commit 0a90976

Please sign in to comment.