spec/spec_helper.rb in fluq-0.7.0 vs spec/spec_helper.rb in fluq-0.7.1
- old
+ new
@@ -3,10 +3,35 @@
require 'bundler/setup'
require 'rspec'
require 'fluq/testing'
-Dir[FluQ.root.join("../support/**/*.rb")].each {|f| require f }
FluQ.logger = Logger.new(FluQ.root.join("log", "fluq.log").to_s)
$LOAD_PATH.unshift FluQ.root.join('lib')
-Random.srand(1234)
\ No newline at end of file
+Random.srand(1234)
+
+module FluQ::SpecHelpers
+
+ def self.included(base)
+ super
+ base.instance_eval do
+ let(:reactor) { @_reactor ||= FluQ::Reactor.new }
+ end
+ end
+
+ def with_reactor(&block)
+ FluQ::Reactor.run do |reactor|
+ @_reactor = reactor
+ block.call(reactor)
+ EM.stop
+ end
+ end
+
+end
+
+RSpec.configure do |c|
+ c.include FluQ::SpecHelpers
+ c.after do
+ FileUtils.rm_rf FluQ.root.join("tmp").to_s
+ end
+end