Sha256: 33ef931d8efac83f29338f1804498a3aec1699a9dbede09444b4bdd25c781a4e

Contents?: true

Size: 1.54 KB

Versions: 29

Compression:

Stored size: 1.54 KB

Contents

require 'ratchetio'

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

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

    require './app/controllers/application_controller'

    class RatchetioTestingException < RuntimeError; end

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

    unless defined?(ApplicationController)
      puts "No ApplicationController found"
      exit
    end

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

      def verify
      end

      def logger
        nil
      end
    end
    
    class RatchetioTestController < 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

29 entries across 29 versions & 1 rubygems

Version Path
ratchetio-0.7.0 lib/ratchetio/rake_tasks.rb
ratchetio-0.6.3 lib/ratchetio/rake_tasks.rb
ratchetio-0.6.1 lib/ratchetio/rake_tasks.rb
ratchetio-0.6.0 lib/ratchetio/rake_tasks.rb
ratchetio-0.5.5 lib/ratchetio/rake_tasks.rb
ratchetio-0.5.3 lib/ratchetio/rake_tasks.rb
ratchetio-0.5.2 lib/ratchetio/rake_tasks.rb
ratchetio-0.5.1 lib/ratchetio/rake_tasks.rb
ratchetio-0.5.0 lib/ratchetio/rake_tasks.rb
ratchetio-0.4.11 lib/ratchetio/rake_tasks.rb
ratchetio-0.4.10 lib/ratchetio/rake_tasks.rb
ratchetio-0.4.9 lib/ratchetio/rake_tasks.rb
ratchetio-0.4.8 lib/ratchetio/rake_tasks.rb
ratchetio-0.4.7 lib/ratchetio/rake_tasks.rb
ratchetio-0.4.6 lib/ratchetio/rake_tasks.rb
ratchetio-0.4.5 lib/ratchetio/rake_tasks.rb
ratchetio-0.4.4 lib/ratchetio/rake_tasks.rb
ratchetio-0.4.3 lib/ratchetio/rake_tasks.rb
ratchetio-0.4.2 lib/ratchetio/rake_tasks.rb
ratchetio-0.4.1 lib/ratchetio/rake_tasks.rb