Sha256: 1640ca8306ad4feec631ca40b09807ee22f6d80aeb75f29c4a28aa690526d824
Contents?: true
Size: 1.73 KB
Versions: 32
Compression:
Stored size: 1.73 KB
Contents
Dir.chdir File.join File.dirname(__FILE__), '../../' require './lib/flok' require './spec/env/etc' RSpec.describe "lib/services_compiler" do #Return a v8 instance of a compiled js file def compile fn, config compiler = Flok::ServicesCompiler js_src(fn) js_res = compiler.compile(js_src(fn), js_src(config)) ctx = V8::Context.new ctx.eval js_res return ctx, js_res end #Get the source for a file in ./service_compiler/*.rb def js_src fn Dir.chdir File.join(File.dirname(__FILE__), "service_compiler") do return File.read(fn+'.rb') end end it "Does fail to compile a controller with a non-existant type" do expect { compile "service_bad_type" }.to raise_exception end it "Can call compile method and get a copy of all the functions" do ctx, _ = compile "service0", "config0b" #on_wakeup res = ctx.eval("test_on_wakeup") expect(res).not_to eq(nil) #on_sleep res = ctx.eval("test_on_sleep") expect(res).not_to eq(nil) #on_connect res = ctx.eval("test_on_connect"); expect(res).not_to eq(nil) #on_disconnect res = ctx.eval("test_on_disconnect") expect(res).not_to eq(nil) #on_event res = ctx.eval("test_on_hello"); expect(res).not_to eq(nil) #on_handle_timer_events res = ctx.eval("test_handle_timer_events"); expect(res).not_to eq(nil) end it "Can call compile method with options" do ctx, js = compile "service1", "config2" expect(js).to include("23rntoheuh3nthoeunthn23th"); end #If SEND works, then all kernel macros should work it "Can compile with a SEND macro" do ctx, src = compile "service3", "config0b" expect(src).not_to include("SEND") expect(src).to include("_q.push") end end
Version data entries
32 entries across 32 versions & 1 rubygems