Sha256: c3b1032cf4010045a2356c27274f6c0bf71751fa3c50a82bedaeae7115f34ac6

Contents?: true

Size: 872 Bytes

Versions: 2

Compression:

Stored size: 872 Bytes

Contents

require 'spec_helper'

Goliath.env = :development

class ReloaderDev < Goliath::API
  use Goliath::Rack::Params
end

class ReloaderAlreadyLoaded < Goliath::API
  use ::Rack::Reloader, 0
  use Goliath::Rack::Params
end

class ReloaderProd < Goliath::API
end

describe "Reloader" do
  let(:err) { Proc.new { fail "API request failed" } }

  before(:each) { Goliath.env = :development }
  after(:each) { Goliath.env = :test }

  def count(klass)
    cnt = 0
    klass.middlewares.each do |mw|
      cnt += 1 if mw.first == ::Rack::Reloader
    end
    cnt
  end

  it 'adds reloader in dev mode' do
    expect(count(ReloaderDev)).to eq(1)
  end

  it "doesn't add if it's already there in dev mode" do
    expect(count(ReloaderAlreadyLoaded)).to eq(1)
  end

  it "doesn't add in prod mode" do
    Goliath.env = :production
    expect(count(ReloaderProd)).to eq(0)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
goliath-1.0.7 spec/integration/reloader_spec.rb
goliath-1.0.6 spec/integration/reloader_spec.rb