diff --git a/Gemfile b/Gemfile index 3c945ab..a981c51 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/Gemfile.lock b/Gemfile.lock index eba24cf..46cb5c3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 diff --git a/test/integration/basic_application_test.rb b/test/integration/basic_application_test.rb index 0f94efd..452f3c9 100644 --- a/test/integration/basic_application_test.rb +++ b/test/integration/basic_application_test.rb @@ -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 diff --git a/test/integration/more_complex_test.rb b/test/integration/more_complex_test.rb index cb3311a..e0af97c 100644 --- a/test/integration/more_complex_test.rb +++ b/test/integration/more_complex_test.rb @@ -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 diff --git a/test/integration/no_subclassing_test.rb b/test/integration/no_subclassing_test.rb index 073ecbc..25c03e6 100644 --- a/test/integration/no_subclassing_test.rb +++ b/test/integration/no_subclassing_test.rb @@ -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 diff --git a/test/integration/reporting_test.rb b/test/integration/reporting_test.rb index ac75a5f..c037d06 100644 --- a/test/integration/reporting_test.rb +++ b/test/integration/reporting_test.rb @@ -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 diff --git a/test/outpost/scouts/tcp_test.rb b/test/outpost/scouts/tcp_test.rb index 81c1404..cf92ae6 100644 --- a/test/outpost/scouts/tcp_test.rb +++ b/test/outpost/scouts/tcp_test.rb @@ -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 diff --git a/test/test_helper.rb b/test/test_helper.rb index 63dcff5..cd3391c 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -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)