Sha256: e3f1fb2840e263f022265407e7bb823c28c604f737dbcead63e8b5d2c3f75b46

Contents?: true

Size: 1.39 KB

Versions: 5

Compression:

Stored size: 1.39 KB

Contents

require File.dirname(__FILE__) + '/gems'

Puggernaut::Gems.activate %w(sinatra)

require 'sinatra/base'

$:.unshift File.expand_path('../../', __FILE__)

require 'puggernaut/client'

class SpecServer < Sinatra::Base
  
  set :environment, :test
  set :root, File.expand_path("../../../", __FILE__)
  set :public, "#{root}/public"
  set :logging, true
  set :static, true
  
  get '/pulse' do
    'OK'
  end
  
  get '/' do
    redirect '/spec.html'
  end
  
  get '/single' do
    begin
      client = Puggernaut::Client.new("localhost:8001")
      client.push :single => "single message"
      client.close
    rescue Exception => e
      e.message
    end
  end
  
  get '/multiple' do
    begin
      client = Puggernaut::Client.new("localhost:8001")
      client.push :multiple => [ "multiple message 1", "multiple message 2" ]
      client.close
    rescue Exception => e
      e.message
    end
  end
  
  get '/last/:count' do
    begin
      client = Puggernaut::Client.new("localhost:8001")
      client.push :last => "last message #{params[:count]}"
      client.close
    rescue Exception => e
      e.message
    end
  end
  
  get '/multiple/channels' do
    begin
      client = Puggernaut::Client.new("localhost:8001")
      client.push :single => "single message", :multiple => [ "multiple message 1", "multiple message 2" ]
      client.close
    rescue Exception => e
      e.message
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
puggernaut-0.1.5 lib/puggernaut/spec_server.rb
puggernaut-0.1.4 lib/puggernaut/spec_server.rb
puggernaut-0.1.3 lib/puggernaut/spec_server.rb
puggernaut-0.1.2 lib/puggernaut/spec_server.rb
puggernaut-0.1.0 lib/puggernaut/spec_server.rb