Skip to content

Commit

Permalink
Basic move tests to fakeweb
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Rozumey committed Jan 12, 2012
1 parent d1d733f commit cafba40
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 23 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Expand Up @@ -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)
Expand Down Expand Up @@ -55,6 +56,7 @@ PLATFORMS
ruby

DEPENDENCIES
fakeweb
mail
minitest (~> 2.0.2)
net-ping
Expand Down
10 changes: 5 additions & 5 deletions test/integration/basic_application_test.rb
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions test/integration/more_complex_test.rb
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/integration/no_subclassing_test.rb
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/integration/reporting_test.rb
Expand Up @@ -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
Expand Down
23 changes: 18 additions & 5 deletions test/outpost/scouts/tcp_test.rb
Expand Up @@ -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
Expand Down
13 changes: 11 additions & 2 deletions test/test_helper.rb
Expand Up @@ -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'

Expand All @@ -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.