From ba814a903386ce12ea5370f5c7df8ef9fb693612 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 13 Jan 2007 07:14:46 +0000 Subject: Use mocha for rescue tests. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5916 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/rescue_test.rb | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/rescue_test.rb b/actionpack/test/controller/rescue_test.rb index 91532ee0c2..c7e055a859 100644 --- a/actionpack/test/controller/rescue_test.rb +++ b/actionpack/test/controller/rescue_test.rb @@ -1,5 +1,7 @@ require File.dirname(__FILE__) + '/../abstract_unit' -require 'flexmock' + +# gem install mocha +require 'mocha' class RescueController < ActionController::Base def raises @@ -10,7 +12,6 @@ end class RescueTest < Test::Unit::TestCase - include FlexMock::TestCase FIXTURE_PUBLIC = "#{File.dirname(__FILE__)}/../fixtures".freeze def setup @@ -30,10 +31,9 @@ class RescueTest < Test::Unit::TestCase def test_rescue_action_locally_if_all_requests_local - stub = flexstub(@controller) - stub.should_receive(:local_request?).and_return(true) - stub.should_receive(:rescue_action_locally).with(@exception).once - stub.should_receive(:rescue_action_in_public).never + @controller.expects(:local_request?).never + @controller.expects(:rescue_action_locally).with(@exception) + @controller.expects(:rescue_action_in_public).never with_all_requests_local do @controller.send :rescue_action, @exception @@ -41,10 +41,9 @@ class RescueTest < Test::Unit::TestCase end def test_rescue_action_locally_if_remote_addr_is_localhost - stub = flexstub(@controller) - stub.should_receive(:local_request?).and_return(true) - stub.should_receive(:rescue_action_locally).with(@exception).once - stub.should_receive(:rescue_action_in_public).never + @controller.expects(:local_request?).returns(true) + @controller.expects(:rescue_action_locally).with(@exception) + @controller.expects(:rescue_action_in_public).never with_all_requests_local false do @controller.send :rescue_action, @exception @@ -52,10 +51,9 @@ class RescueTest < Test::Unit::TestCase end def test_rescue_action_in_public_otherwise - stub = flexstub(@controller) - stub.should_receive(:local_request?).and_return(false) - stub.should_receive(:rescue_action_in_public).with(@exception).once - stub.should_receive(:rescue_action_locally).never + @controller.expects(:local_request?).returns(false) + @controller.expects(:rescue_action_locally).never + @controller.expects(:rescue_action_in_public).with(@exception) with_all_requests_local false do @controller.send :rescue_action, @exception @@ -121,14 +119,14 @@ class RescueTest < Test::Unit::TestCase def test_local_request_when_remote_addr_is_localhost - flexstub(@controller).should_receive(:request).and_return(@request) + @controller.expects(:request).returns(@request).at_least_once with_remote_addr '127.0.0.1' do assert @controller.send(:local_request?) end end def test_local_request_when_remote_addr_isnt_locahost - flexstub(@controller).should_receive(:request).and_return(@request) + @controller.expects(:request).returns(@request) with_remote_addr '1.2.3.4' do assert !@controller.send(:local_request?) end -- cgit v1.2.3