Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Controller
- class ClientsController < ApplicationController
- def new
- @client = Client.new
- end
- end
- ## Unit test
- require File.dirname(__FILE__) + '/../test_helper'
- require_dependency 'clients_controller'
- # Re-raise errors caught by the controller.
- class ClientsController; def rescue_action(e) raise e end; end
- context "new client" do
- def setup
- @controller = ClientsController.new
- @session = ActionController::TestSession.new
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
- @controller.stubs(:logged_in?).returns(true)
- Client.expects(:new).returns(stub)
- end
- specify "should render new.rhtml" do
- # First try...
- # @response.template.expects(:render_file)
- # Failure: Cannot replace render_file because it is not defined in .
- # Failure: :render_file('** any **'): expected calls: 1, actual calls: 0
- # Second try...
- ActionView::Base.any_instance.expects(:render_file).with('clients/new', true, {})
- # Failure: Unexpected message :render_file('clients/new', true, {}) sent to #<Mocha::Mock: 30432780>
- # Failute: :render_file('clients/new', true, {}): expected calls: 1, actual calls: 0
- get :new
- end
- end
Add Comment
Please, Sign In to add comment