Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use mocha for rescue tests.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5916 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit ba814a903386ce12ea5370f5c7df8ef9fb693612 1 parent 47f9958
@jeremy jeremy authored
Showing with 14 additions and 16 deletions.
  1. +14 −16 actionpack/test/controller/rescue_test.rb
View
30 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 @@ def raises
class RescueTest < Test::Unit::TestCase
- include FlexMock::TestCase
FIXTURE_PUBLIC = "#{File.dirname(__FILE__)}/../fixtures".freeze
def setup
@@ -30,10 +31,9 @@ def setup
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 @@ def test_rescue_action_locally_if_all_requests_local
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 @@ def test_rescue_action_locally_if_remote_addr_is_localhost
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 @@ def test_rescue_action_locally
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
Please sign in to comment.
Something went wrong with that request. Please try again.