Permalink
Browse files

Basic move tests to fakeweb

  • Loading branch information...
1 parent d1d733f commit cafba40f3a228cbdeeb87e1295f22e0d0a5c8eb4 @brain-geek committed Jan 12, 2012
View
@@ -10,6 +10,8 @@ group :test do
gem 'rack'
gem 'sinatra'
+ gem 'fakeweb'
+
gem 'minitest', '~> 2.0.2', :platforms => :ruby_18
gem 'ruby-debug', :platforms => :ruby_18
View
@@ -6,6 +6,7 @@ GEM
columnize (0.3.2)
daemons (1.1.0)
eventmachine (0.12.10)
+ fakeweb (1.3.0)
faraday (0.5.4)
addressable (~> 2.2.2)
multipart-post (~> 1.1.0)
@@ -55,6 +56,7 @@ PLATFORMS
ruby
DEPENDENCIES
+ fakeweb
mail
minitest (~> 2.0.2)
net-ping
@@ -3,11 +3,11 @@
require 'outpost/scouts/http'
describe "basic application integration test" do
- before(:each) do
- @server = Server.new
- @server.boot(TestApp)
- @server.wait_until_booted
- end
+ # before(:each) do
+ # @server = Server.new
+ # @server.boot(TestApp)
+ # @server.wait_until_booted
+ # end
class ExampleSuccess < Outpost::Application
using Outpost::Scouts::Http => 'master http server' do
@@ -3,11 +3,11 @@
require 'outpost/scouts'
describe "using more complex application integration test" do
- before(:each) do
- @server = Server.new
- @server.boot(TestApp)
- @server.wait_until_booted
- end
+ # before(:each) do
+ # @server = Server.new
+ # @server.boot(TestApp)
+ # @server.wait_until_booted
+ # end
class ExamplePingAndHttp < Outpost::Application
using Outpost::Scouts::Http => 'master http server' do
@@ -5,9 +5,9 @@
describe "creating outpost apps without subclassing" do
before(:each) do
- @server = Server.new
- @server.boot(TestApp)
- @server.wait_until_booted
+ # @server = Server.new
+ # @server.boot(TestApp)
+ # @server.wait_until_booted
Mail.defaults do
delivery_method :test
@@ -15,9 +15,9 @@ class RetrieveServerData < Outpost::Application
end
before(:each) do
- @server = Server.new
- @server.boot(TestApp)
- @server.wait_until_booted
+ # @server = Server.new
+ # @server.boot(TestApp)
+ # @server.wait_until_booted
@outpost = RetrieveServerData.new
@outpost.run
@@ -2,15 +2,28 @@
describe Outpost::Scouts::Tcp do
it "should set the time of ping in milliseconds" do
- @server = Server.new
- @server.boot(TestApp)
- @server.wait_until_booted
+ # @server = Server.new
+ # @server.boot(TestApp)
+ # @server.wait_until_booted
- config = config_stub(:port => 9595)
+ cls = Class.new do
+ def initialize(host, port, timeout)
+ end
+
+ def duration
+ 0.01
+ end
+
+ def ping?
+ true
+ end
+ end
+
+ config = config_stub(:port => 9595, :pinger => cls)
subject = Outpost::Scouts::Tcp.new "test", config
subject.execute
- assert subject.response_time < 100
+ assert subject.response_time.to_i < 100
end
it "should set the time to nil when it fails" do
View
@@ -8,8 +8,8 @@
require 'minitest/autorun'
# Integration test helpers
-require 'support/test_app'
-require 'support/server'
+# require 'support/test_app'
+# require 'support/server'
require 'support/stubs'
require 'support/nothing_raised'
@@ -21,3 +21,12 @@
include Support::Stubs
include Support::NothingRaised
+
+#moveme to other file!
+
+require 'fakeweb'
+
+FakeWeb.allow_net_connect = false
+FakeWeb.register_uri(:get, "http://localhost:9595", :body => 'Up and running!', :status => 200)
+FakeWeb.register_uri(:get, "http://localhost:9595/fail", :body => 'Omg fail', :status => 500)
+FakeWeb.register_uri(:get, "http://localhost:9595/warning", :body => 'Omg need payment', :status => 402)

0 comments on commit cafba40

Please sign in to comment.