아래 응용 프로그램은 일부 데이터를 db에 저장하므로 제대로 저장하는지 테스트하고 싶습니다. 반응기 callback
돌아 가기 전에 끝나는 때문에em-mongo + Goliath를 테스트하는 방법은 무엇입니까?
require 'goliath'
class App < Goliath::API
def response(env)
db = EM::Mongo::Connection.new('localhost').db('hello')
db.collection('coll').insert({'identifier => 1'})
[204, {}, {}]
end
end
require 'goliath/test_helper'
Goliath.env = :test
describe App do
include Goliath::TestHelper
it do
with_api(described_class) do
get_request do |req|
db = EM::Mongo::Connection.new('localhost').db('hello')
db.collection('coll').first.callback do |rec|
rec['identifier'].should == 100
end
end
end
end
end
상기 스펙 통과한다. 모든 사양에 대한 반응을 시작하는 것이 좋습니다 경우 잘 모르겠어요하지만
EM.run do
db = EM::Mongo::Connection.new('localhost').db('hello')
db.collection('coll').first.callback do |rec|
rec['identifier'].should == 100
EM.stop
end
end
: 나는 약을 수동으로 같은 반응을 시작 생각했다. 도와주세요?
그게 효과가 있습니다. 관련없는 메모에서, 귀하의 블로그에서 많은 것을 배웠습니다. –