test/unit/client_tests.rb in and-son-0.8.0 vs test/unit/client_tests.rb in and-son-0.9.0

- old
+ new

@@ -124,10 +124,12 @@ desc "TestClient" setup do @name = Factory.string @params = { Factory.string => Factory.string } + Assert.stub(Sanford::Protocol.msg_body, :encode){ |r| @encoded_request = r } + @client = AndSon::TestClient.new(@host, @port) end subject{ @client } should have_readers :calls, :responses @@ -145,11 +147,11 @@ assert_equal [], subject.before_call_procs assert_equal [], subject.after_call_procs end should "know its call runner" do - subject + assert_equal subject, subject.call_runner end should "store each call made in its `calls`" do assert_equal [], subject.calls subject.call(@name, @params) @@ -170,9 +172,15 @@ should "yield a stored response using `call` with a block" do yielded = nil subject.call(@name, @params){ |response| yielded = response } exp = subject.responses.get(@name, @params) assert_equal exp.protocol_response, yielded + end + + should "build and encode a request when called" do + subject.call(@name, @params) + exp = Sanford::Protocol::Request.new(@name, @params).to_hash + assert_equal exp, @encoded_request end should "run before call procs" do subject.params({ Factory.string => Factory.string }) yielded_name = nil