diff options
author | Josh Bassett <josh.bassett@gmail.com> | 2011-01-18 19:21:16 +1100 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2011-02-09 19:25:53 -0200 |
commit | 056be15212a8645d17534f993c1e89bd2dcf7df9 (patch) | |
tree | fedf74cb130c48e99f09942bd9bfa838f156bde0 /activeresource/test | |
parent | ad31549ab3044afc336c05243481c0f663689584 (diff) | |
download | rails-056be15212a8645d17534f993c1e89bd2dcf7df9.tar.gz rails-056be15212a8645d17534f993c1e89bd2dcf7df9.tar.bz2 rails-056be15212a8645d17534f993c1e89bd2dcf7df9.zip |
Fixed a bug where ActiveResource::HttpMock would not replace an existing response when passing a block to the respond_to method.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'activeresource/test')
-rw-r--r-- | activeresource/test/cases/http_mock_test.rb | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/activeresource/test/cases/http_mock_test.rb b/activeresource/test/cases/http_mock_test.rb index 82b5e60c77..43cf5f5ef0 100644 --- a/activeresource/test/cases/http_mock_test.rb +++ b/activeresource/test/cases/http_mock_test.rb @@ -140,7 +140,19 @@ class HttpMockTest < ActiveSupport::TestCase assert_equal 2, ActiveResource::HttpMock.responses.length end - test "allows you to replace the existing reponse with the same request" do + test "allows you to replace the existing reponse with the same request by calling a block" do + ActiveResource::HttpMock.respond_to do |mock| + mock.send(:get, "/people/1", {}, "XML1") + end + assert_equal 1, ActiveResource::HttpMock.responses.length + + ActiveResource::HttpMock.respond_to(false) do |mock| + mock.send(:get, "/people/1", {}, "XML2") + end + assert_equal 1, ActiveResource::HttpMock.responses.length + end + + test "allows you to replace the existing reponse with the same request by passing pairs" do ActiveResource::HttpMock.respond_to do |mock| mock.send(:get, "/people/1", {}, "XML1") end @@ -151,11 +163,22 @@ class HttpMockTest < ActiveSupport::TestCase ok_response = ActiveResource::Response.new(matz, 200, {}) ActiveResource::HttpMock.respond_to({get_matz => ok_response}, false) + assert_equal 1, ActiveResource::HttpMock.responses.length + end + test "do not replace the response with the same path but different method by calling a block" do + ActiveResource::HttpMock.respond_to do |mock| + mock.send(:get, "/people/1", {}, "XML1") + end assert_equal 1, ActiveResource::HttpMock.responses.length + + ActiveResource::HttpMock.respond_to(false) do |mock| + mock.send(:put, "/people/1", {}, "XML2") + end + assert_equal 2, ActiveResource::HttpMock.responses.length end - test "do not replace the response with the same path but different method" do + test "do not replace the response with the same path but different method by passing pairs" do ActiveResource::HttpMock.respond_to do |mock| mock.send(:get, "/people/1", {}, "XML1") end |