Sha256: d8d519451bce16ae3efa16a415e3b82de2cc54673a73e3ddaad31570aceb2204

Contents?: true

Size: 1.64 KB

Versions: 9

Compression:

Stored size: 1.64 KB

Contents

require 'rollbar'

namespace :rollbar do
  desc "Verify your gem installation by sending a test exception to Rollbar"
  task :test => [:environment] do
    Rails.logger = defined?(ActiveSupport::TaggedLogging) ?
      ActiveSupport::TaggedLogging.new(Logger.new(STDOUT)) :
      Logger.new(STDOUT)

    Rails.logger.level = Logger::DEBUG
    Rollbar.configure do |config|
      config.logger = Rails.logger
    end

    class RollbarTestingException < RuntimeError; end

    unless Rollbar.configuration.access_token
      puts "Rollbar needs an access token configured. Check the README for instructions."
      exit
    end

    begin
      require './app/controllers/application_controller'
    rescue LoadError
    end

    unless defined?(ApplicationController)
      puts "No ApplicationController found, using ActionController::Base instead"
      class ApplicationController < ActionController::Base; end
    end

    puts "Setting up the controller."
    class ApplicationController
      prepend_before_filter :test_rollbar
      def test_rollbar
        puts "Raising RollbarTestingException to simulate app failure."
        raise RollbarTestingException.new, 'Testing rollbar with "rake rollbar:test". If you can see this, it works.'
      end

      def verify
      end

      def logger
        nil
      end
    end
    
    class RollbarTestController < ApplicationController; end

    Rails.application.routes_reloader.execute_if_updated
    Rails.application.routes.draw do
      match 'verify' => 'application#verify', :as => 'verify'
    end

    puts "Processing..."
    env = Rack::MockRequest.env_for("/verify")

    Rails.application.call(env)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rollbar-0.9.4 lib/rollbar/rake_tasks.rb
rollbar-0.9.3 lib/rollbar/rake_tasks.rb
rollbar-0.9.2 lib/rollbar/rake_tasks.rb
rollbar-0.9.1 lib/rollbar/rake_tasks.rb
rollbar-0.9.0 lib/rollbar/rake_tasks.rb
rollbar-0.8.3 lib/rollbar/rake_tasks.rb
rollbar-0.8.2 lib/rollbar/rake_tasks.rb
rollbar-0.8.1 lib/rollbar/rake_tasks.rb
rollbar-0.8.0 lib/rollbar/rake_tasks.rb