spec/spec_helper.rb in hara-0.2.2 vs spec/spec_helper.rb in hara-0.3.0
- old
+ new
@@ -1,6 +1,6 @@
-require 'hara/base'
+require 'hara'
Celluloid.logger = nil
def wait_until wait_time = 3
timeout wait_time do
@@ -31,25 +31,37 @@
def get_peername
defined?(JRuby) ? @jruby_peername : @mri_peername
end
+ def alive= alive
+ @alive = alive
+ end
+
def alive?
@alive
end
def close code = nil, body = nil
if @alive
@close_info = [code, body]
@alive = false
- @app.terminate!
+ @app.terminate! if @app
end
end
def send message
@client_messages << message
end
def client_read
@client_messages.shift
+ end
+
+ [:onclose, :onmessage, :onopen].each do |method|
+ attribute = "#{method}_block".to_sym
+ attr_accessor attribute
+ define_method method do |&blk|
+ __send__ "#{attribute}=", blk
+ end
end
end