Sha256: 293b7f4a00fae62c4e9e635a096a5b8caedcad39fd7fb93264bbdb636e86052e

Contents?: true

Size: 1.46 KB

Versions: 10

Compression:

Stored size: 1.46 KB

Contents

require_relative "../spec_helper"

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

10 entries across 10 versions & 1 rubygems

Version Path
roda-3.9.0 spec/plugin/heartbeat_spec.rb
roda-3.8.0 spec/plugin/heartbeat_spec.rb
roda-3.7.0 spec/plugin/heartbeat_spec.rb
roda-3.6.0 spec/plugin/heartbeat_spec.rb
roda-3.5.0 spec/plugin/heartbeat_spec.rb
roda-3.4.0 spec/plugin/heartbeat_spec.rb
roda-3.3.0 spec/plugin/heartbeat_spec.rb
roda-3.2.0 spec/plugin/heartbeat_spec.rb
roda-3.1.0 spec/plugin/heartbeat_spec.rb
roda-3.0.0 spec/plugin/heartbeat_spec.rb