Skip to content

Commit

Permalink
dont wait more than you should
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermesilveira committed Jun 11, 2010
1 parent 4b34310 commit 15242e8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Rakefile
Expand Up @@ -42,7 +42,7 @@ end

def execute_process(name)
sh "ruby ./spec/units/client/#{name}.rb &"
sleep 15
wait_server 4567
%x(ps -ef | grep #{name}).split[1]
end

Expand All @@ -51,24 +51,24 @@ def process(name)
end

def start_server_and_invoke_test(task_name)
kill_server "fake_server"
pid = process "fake_server"
puts "fake_server pid >>>> #{pid}"
Rake::Task[task_name].invoke
sh "kill -9 #{pid}"
kill_server "fake_server"
end

def kill_server
c = `(ps -ef | grep 'script/server')`.split(/\n/)
def kill_server(where)
c = `(ps -ef | grep '#{where}')`.split(/\n/)
c.each do |line|
pid = line.split[1]
system "kill -9 #{pid}"
end
end

def wait_server
def wait_server(port=3000)
(1..15).each do
begin
Net::HTTP.get(URI.parse('http://localhost:3000/'))
Net::HTTP.get(URI.parse("http://localhost:#{port}/"))
return
rescue
sleep 1
Expand Down Expand Up @@ -151,12 +151,12 @@ namespace :test do

desc "runs all example tests"
task :examples do
kill_server
kill_server "script/server"
enter_dir = "cd full-examples/rest_from_scratch/part_3"
system "#{enter_dir} && rake db:reset db:seed && script/server -d"
wait_server
system "#{enter_dir} && rake spec"
kill_server
kill_server "script/server"
end

end
Expand Down
1 change: 1 addition & 0 deletions spec/units/client/base_spec.rb
Expand Up @@ -24,6 +24,7 @@ class Song
a_song.id.should == 'http://localhost:4567/songs_1'
end


it 'should load top ten songs' do
top_ten_songs = @songs_from_class.links.top_ten.get!
top_ten_songs.response.code.should == 200
Expand Down

0 comments on commit 15242e8

Please sign in to comment.