Skip to content

Commit

Permalink
fixed to_json on server side: it doesnt belong to activesupport anylo…
Browse files Browse the repository at this point in the history
…nger
  • Loading branch information
guilhermesilveira committed Aug 22, 2010
1 parent aa9ae8b commit 3172166
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 29 deletions.
61 changes: 32 additions & 29 deletions tests/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,35 @@ 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
#
# namespace :test do
# task :pegadinha_do_malandro do
# FakeServer.start_server_and_invoke_test('nothing')
# end
# end

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

namespace :test do
task :pegadinha_do_malandro do
FakeServer.start_server_and_invoke_test('spec')
end
task :server do
FakeServer.start_server_and_invoke_test('hahaha')
end
end
5 changes: 5 additions & 0 deletions tests/spec/requests/fake_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'sinatra'
require 'rack/conneg'
require 'active_support'
require 'json'

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

Expand All @@ -16,6 +17,10 @@
content_type negotiated_type
end

get "/favicon" do
Rack::Response.new('OK', 200).finish
end

get "/test/?" do
'OK'
end
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 3172166

Please sign in to comment.