提交 aee043de 编写于 作者: G Gaston Ramos 提交者: José Valim

- ActiveResource::HttpMock.respond_to

  do not replace the response with the same path but different method
- Fix typo
Signed-off-by: NJosé Valim <jose.valim@gmail.com>
上级 b9f8501f
......@@ -140,7 +140,7 @@ class HttpMockTest < ActiveSupport::TestCase
assert_equal 2, ActiveResource::HttpMock.responses.length
end
test "allows you to add replace the existing reponese with the same path" do
test "allows you to replace the existing reponse with the same request" do
ActiveResource::HttpMock.respond_to do |mock|
mock.send(:get, "/people/1", {}, "XML1")
end
......@@ -155,6 +155,19 @@ class HttpMockTest < ActiveSupport::TestCase
assert_equal 1, ActiveResource::HttpMock.responses.length
end
test "do not replace the response with the same path but different method" do
ActiveResource::HttpMock.respond_to do |mock|
mock.send(:get, "/people/1", {}, "XML1")
end
assert_equal 1, ActiveResource::HttpMock.responses.length
put_matz = ActiveResource::Request.new(:put, '/people/1', nil)
ok_response = ActiveResource::Response.new("", 200, {})
ActiveResource::HttpMock.respond_to({put_matz => ok_response}, false)
assert_equal 2, ActiveResource::HttpMock.responses.length
end
def request(method, path, headers = {}, body = nil)
if [:put, :post].include? method
@http.send(method, path, body, headers)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册