spec/app_spec.rb in hara-0.0.2 vs spec/app_spec.rb in hara-0.1.0

- old
+ new

@@ -5,18 +5,22 @@ Class.new Hara::App do def init @states = [] end - def before_process action, *args - @states << [:before_process, action, args] + def before_action action, *args + @states << [:before_action, action, args] end - def after_process action, *args - @states << [:after_process, action, args] + def after_action action, *args + @states << [:after_action, action, args] end + def after_process + @states << :after_process + end + def on_close @states << :closed end def action_missing action, *args @@ -76,10 +80,18 @@ @app = Hara::Application.new @socket sleep 0.1 until msg = @socket.client_read msg.should == 'hello world' end + it 'error remote call' do + @socket.client_send("a error call") + @app = Hara::Application.new @socket + sleep 0.1 while @app.alive? + msg = @socket.client_read + msg.should == nil + end + it 'action_missing should work' do @socket.client_send({action: :hello_world, args: ['hello', 'world']}.to_json) @app = Hara::Application.new @socket sleep 0.1 until msg = @socket.client_read msg.should == [:action_missing, 'hello_world', ['hello', 'world']] @@ -89,8 +101,9 @@ @app = Hara::Application.new @socket @socket.client_send({action: :hello, args: [' world']}.to_json) states = @app.states sleep 0.2 @app.halt - states.should == [:success, [:before_process, "hello", [" world"]], [:after_process, "hello", [" world"]],:closed] + sleep 0.1 while @app.alive? + states.should == [:success, [:before_action, "hello", [" world"]], [:after_action, "hello", [" world"]], :after_process,:closed] end end