spec/app_spec.rb in hara-0.3.0 vs spec/app_spec.rb in hara-0.4.0

- old
+ new

@@ -38,12 +38,12 @@ end end end before :each do - @handshake = FayeHandshake.new - @socket = FayeSocket.new + @handshake = FakeHandshake.new + @socket = FakeSocket.new @app = Hara::Application.new @handshake, @socket @socket.app = @app end after :each do @@ -57,38 +57,36 @@ @app.client_port.should.is_a? Integer @app.headers.should.is_a? Hash end it 'remote call actions' do - @app.process_msg(Hara.encode_msg(:hello, ' world')) + @socket.client_send(:hello, [' world']) msg = nil wait_until{msg = @socket.client_read} msg.should == 'hello world' end it 'close should close connection' do - @app.process_msg(Hara.encode_msg(:exit)) + @socket.client_send(:exit, []) wait_until{!@app.alive?} @socket.alive?.should == false @socket.close_info.should == [3333, 'Bye'] end it 'error remote call' do - @app.process_msg('a error call') + @socket.client_send(:hello, []) wait_until{!@app.alive?} - msg = @socket.client_read - msg.should == nil end it 'action_missing should work' do - @app.process_msg(Hara.encode_msg(:hello_world, 'hello', 'world')) + @socket.client_send(:hello_world, ['hello', 'world']) msg = nil wait_until{msg = @socket.client_read} - msg.should == [:action_missing, 'hello_world', ['hello', 'world']] + msg.should == ['action_missing', 'hello_world', ['hello', 'world']] end it 'callbacks should work' do - 2.times{ @app.process_msg(Hara.encode_msg(:hello, ' world'))} + 2.times{ @socket.client_send(:hello, [' world'])} states = @app.states sleep 0.2 @app.terminate wait_until{!@app.alive?} action_callbacks = [[:before_action, "hello", [" world"]], [:after_action, "hello", [" world"]]]