Sha256: 146b0c39064733a853d7e6d779f604a5f37dda61cb6acd53fa077366b1db0aba

Contents?: true

Size: 1.51 KB

Versions: 28

Compression:

Stored size: 1.51 KB

Contents

require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))

describe "heartbeat plugin" do 
  it "should return heartbeat response for heartbeat paths only" do
    app(:bare) do
      plugin :heartbeat
      route do |r|
        r.on 'a' do
          "a"
        end
      end
    end

    body('/a').must_equal 'a'
    status.must_equal 404
    status('/heartbeat').must_equal 200
    body('/heartbeat').must_equal 'OK'
  end

  it "should support custom heartbeat paths" do
    app(:bare) do
      plugin :heartbeat, :path=>'/heartbeat2'
      route do |r|
        r.on 'a' do
          "a"
        end
      end
    end

    body('/a').must_equal 'a'
    status.must_equal 404
    status('/heartbeat').must_equal 404
    status('/heartbeat2').must_equal 200
    body('/heartbeat2').must_equal 'OK'
  end

  it "should work when using sessions" do
    app(:bare) do
      use Rack::Session::Cookie, :secret=>'foo'
      plugin :heartbeat

      route do |r|
        session.clear
        r.on "a" do
          "a"
        end
      end
    end

    body('/a').must_equal 'a'
    status.must_equal 404
    status('/heartbeat').must_equal 200
    body('/heartbeat').must_equal 'OK'
  end

  it "should work when redirecting" do
    app(:bare) do
      plugin :heartbeat

      route do |r|
        r.on "a" do
          "a"
        end
        r.redirect '/a'
      end
    end

    body('/a').must_equal 'a'
    status.must_equal 302
    status('/heartbeat').must_equal 200
    body('/heartbeat').must_equal 'OK'
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
roda-2.9.0 spec/plugin/heartbeat_spec.rb
roda-2.8.0 spec/plugin/heartbeat_spec.rb
roda-2.7.0 spec/plugin/heartbeat_spec.rb
roda-2.6.0 spec/plugin/heartbeat_spec.rb
roda-2.5.1 spec/plugin/heartbeat_spec.rb
roda-2.5.0 spec/plugin/heartbeat_spec.rb
roda-2.4.0 spec/plugin/heartbeat_spec.rb
roda-2.3.0 spec/plugin/heartbeat_spec.rb