Skip to content

Commit

Permalink
starting the fake server prior to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermesilveira committed Aug 22, 2010
1 parent a6f1c9e commit ca09887
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
2 changes: 2 additions & 0 deletions tests/Gemfile
Expand Up @@ -25,6 +25,8 @@ gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'restfulie', '1.0.0.beta.1'

group :test, :development do
gem "sinatra"
gem "rack-conneg"
gem "rspec-rails", ">= 2.0.0.beta.19"
end

Expand Down
6 changes: 6 additions & 0 deletions tests/Gemfile.lock
Expand Up @@ -44,6 +44,8 @@ GEM
nokogiri (1.4.3.1)
polyglot (0.3.1)
rack (1.2.1)
rack-conneg (0.1.4)
rack (>= 1.0)
rack-mount (0.6.9)
rack (>= 1.0.0)
rack-test (0.5.4)
Expand Down Expand Up @@ -80,6 +82,8 @@ GEM
rspec-rails (2.0.0.beta.19)
rspec (= 2.0.0.beta.19)
webrat (>= 0.7.2.beta.1)
sinatra (1.0)
rack (>= 1.0)
sqlite3-ruby (1.3.1)
thor (0.14.0)
treetop (1.4.8)
Expand All @@ -94,7 +98,9 @@ PLATFORMS
ruby

DEPENDENCIES
rack-conneg
rails (= 3.0.0.rc)
restfulie (= 1.0.0.beta.1)
rspec-rails (>= 2.0.0.beta.19)
sinatra
sqlite3-ruby
25 changes: 25 additions & 0 deletions tests/Rakefile
Expand Up @@ -5,3 +5,28 @@ require File.expand_path('../config/application', __FILE__)
require 'rake'

Tests::Application.load_tasks

module FakeServer
def self.wait_server(port=3000)
(1..15).each do
begin
Net::HTTP.get(URI.parse("http://localhost:#{port}/"))
return
rescue
sleep 1
end
end
raise "Waited for the server but it did not finish"
end

def self.start_server_and_invoke_test(task_name)
IO.popen("ruby ./spec/requests/fake_server.rb") do |pipe|
wait_server(4567)
Rake::Task[task_name].invoke
Process.kill 'INT', pipe.pid
end
end

end

FakeServer.start_server_and_invoke_test('nothing')
Expand Up @@ -3,7 +3,7 @@
require 'rack/conneg'
require 'active_support'

require File.join(File.dirname(__FILE__),'..','lib','data_helper')
require File.join(File.dirname(__FILE__),'..','support','data_helper')

use(Rack::Conneg) do |conneg|
conneg.set :accept_all_extensions, false
Expand Down

0 comments on commit ca09887

Please sign in to comment.