Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 72 lines (58 sloc) 2.197 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
require 'test_helper'

require 'outpost/scouts/http'

describe "basic application integration test" do
  class ExampleSuccess < Outpost::Application
    using Outpost::Scouts::Http => 'master http server' do
      options :host => 'localhost', :port => 9595
      report :up, :response_code => 200
    end
  end

  class ExampleWarning < Outpost::Application
    using Outpost::Scouts::Http => 'master http server' do
      options :host => 'localhost', :port => 9595, :path => '/warning'
      report :warning, :response_code => 402
    end
  end

  class ExampleFailure < Outpost::Application
    using Outpost::Scouts::Http => 'master http server' do
      options :host => 'localhost', :port => 9595, :path => '/fail'
      report :up, :response_code => 200
    end
  end

  class ExampleBodyFailure < Outpost::Application
    using Outpost::Scouts::Http => 'master http server' do
      options :host => 'localhost', :port => 9595, :path => '/fail'
      report :down, :response_body => {:equals => 'Omg fail'}
    end
  end

  class ExampleBodySuccess < Outpost::Application
    using Outpost::Scouts::Http => 'master http server' do
      options :host => 'localhost', :port => 9595, :path => '/'
      report :up, :response_body => {:match => /Up/}
    end
  end

  class ExampleBodyWarning < Outpost::Application
    using Outpost::Scouts::Http => 'master http server' do
      options :host => 'localhost', :port => 9595, :path => '/warning'
      report :warning, :response_body => {:equals => 'Omg need payment'}
    end
  end

  it "should report up when everything's ok" do
    assert_equal :up, ExampleSuccess.new.run
  end

  it "should report warning when there's a warning" do
    assert_equal :warning, ExampleWarning.new.run
  end

  it "should report failure when something's wrong" do
    assert_equal :down, ExampleFailure.new.run
  end

  it "should report success when body is okay" do
    assert_equal :up, ExampleBodySuccess.new.run
  end

  it "should report success when body have a warning" do
    assert_equal :warning, ExampleBodyWarning.new.run
  end

  it "should report failure when body is wrong" do
    assert_equal :down, ExampleBodyFailure.new.run
  end
end
Something went wrong with that request. Please try again.