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.29.0 spec/plugin/heartbeat_spec.rb
roda-2.28.0 spec/plugin/heartbeat_spec.rb
roda-2.27.0 spec/plugin/heartbeat_spec.rb
roda-2.26.0 spec/plugin/heartbeat_spec.rb
roda-2.25.0 spec/plugin/heartbeat_spec.rb
roda-2.24.0 spec/plugin/heartbeat_spec.rb
roda-2.23.0 spec/plugin/heartbeat_spec.rb
roda-2.22.0 spec/plugin/heartbeat_spec.rb
roda-2.21.0 spec/plugin/heartbeat_spec.rb
roda-2.20.0 spec/plugin/heartbeat_spec.rb
roda-2.19.0 spec/plugin/heartbeat_spec.rb
roda-2.18.0 spec/plugin/heartbeat_spec.rb
roda-2.17.0 spec/plugin/heartbeat_spec.rb
roda-2.16.0 spec/plugin/heartbeat_spec.rb
roda-2.15.0 spec/plugin/heartbeat_spec.rb
roda-2.14.0 spec/plugin/heartbeat_spec.rb
roda-2.13.0 spec/plugin/heartbeat_spec.rb
roda-2.12.0 spec/plugin/heartbeat_spec.rb
roda-2.11.0 spec/plugin/heartbeat_spec.rb
roda-2.10.0 spec/plugin/heartbeat_spec.rb