Sha256: 3fb2c1d137db55f99812e2166ffedf41ed2d79f1321d435d9bfb79fd9e7450b4

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

$:.unshift File.expand_path(File.dirname(__FILE__) + '/lib')
$:.unshift File.expand_path(File.dirname(__FILE__) + '/spec')

TEST = true

require 'rubygems'
require 'em-spec/rspec'
require 'larynx'

LARYNX_LOGGER = Logger.new(STDOUT)
RESPONSES = {}
Dir['spec/fixtures/*.rb'].each {|file| require file }

class TestCallHandler < Larynx::CallHandler
  attr_accessor :sent_data, :session, :state, :queue, :input, :timers

  def send_data(msg)
    @sent_data = msg
  end

  def send_response(response)
    request = ::RESPONSES[response]
    receive_request(request[:header], request[:content])
  end

  def log(msg)
    (@log ||= '') << msg
  end
end

module SpecHelper
  def should_be_called(times=1, &block)
    proc = mock('Proc should be called')
    proc.should_receive(:call).exactly(times).times.instance_eval(&(block || lambda {}))
    lambda { |*args| proc.call(*args) }
  end

  def should_not_be_called(&block)
    proc = mock('Proc should not be called')
    proc.should_not_receive(:call).instance_eval(&(block || lambda {}))
    lambda { |*args| proc.call(*args) }
  end
end

Spec::Runner.configure do |config|
  config.include SpecHelper, EM::SpecHelper
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
larynx-0.1.2 spec/spec_helper.rb
larynx-0.1.1 spec/spec_helper.rb
larynx-0.1.0 spec/spec_helper.rb