Sha256: e178519e29b8633889b8a17d42ac96ceaf09a189e48685d2fa99a1da496555f3

Contents?: true

Size: 1.8 KB

Versions: 4

Compression:

Stored size: 1.8 KB

Contents

require "action_controller/railtie"
require "rails/test_unit/railtie"
require 'fluoride-collector/rails'

describe Fluoride::Collector::Railtie do

  ENV["RAILS_ENV"] ||= 'test'

  def config(app)

  end

  let :rails_application do
    Class.new(::Rails::Application).tap do |app|
      app.configure do
        config.active_support.deprecation = :stderr
        config.eager_load = false
      end
      config(app)
      app.initialize!
    end
  end

  after :each do
    Rails.application = nil #because Rails has ideas of it's own, silly thing
  end

  it "should add exception collection to the middleware stack" do
    expect(rails_application.middleware.middlewares).to include(Fluoride::Collector::Middleware::CollectExceptions)
  end

  it "should add exchange collection to the middleware stack" do
    expect(rails_application.middleware.middlewares).to include(Fluoride::Collector::Middleware::CollectExchanges)
  end

  it "should put exchange collection at top of stack" do
    expect(rails_application.middleware.middlewares.first).to eq(Fluoride::Collector::Middleware::CollectExchanges)
  end

  describe "configured to use S3" do
    def config(app)
      app.configure do
        config.fluoride.store_to = :s3
        config.fluoride.bucket = "nowhere-really"
        config.fluoride.key_id = "testtest"
        config.fluoride.access_secrety = "donttellnobody"
      end
    end

    it "should put exchange collection at top of stack" do
      expect(rails_application.middleware.middlewares.first).to eq(Fluoride::Collector::Middleware::CollectExchanges)
    end

    it "should configured collector with S3Storage" do
      collector = rails_application.middleware.middlewares.first.build(proc{})
      expect(collector.config.persister("exchange", {})).to be_a(Fluoride::Collector::Storage::S3)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fluoride-collector-0.0.11 spec/railtie.rb
fluoride-collector-0.0.10 spec/railtie.rb
fluoride-collector-0.0.9 spec/railtie.rb
fluoride-collector-0.0.8 spec/railtie.rb