I&#39;m using restful_authentication in my app and I have&nbsp; the before filters in my application rhtml:<br><br>before_filter :login_required<br>around_filter :set_timezone<br>around_filter :catch_errors<br><br>Currently I have them commented out while rspec&#39;in but I&#39;ll need to add them in my specs.
<br><br><br>&nbsp; def create<br>&nbsp;&nbsp;&nbsp; @ticket = Ticket.new(params[:ticket])<br>&nbsp;&nbsp;&nbsp; @ticket.user = current_user<br>&nbsp;&nbsp;&nbsp; if @ticket.save<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; redirect_to tickets_path<br>&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; render new_ticket_path(params[:user_id])
<br>&nbsp; &nbsp; end<br>&nbsp; end<br><br>describe TicketsController, &quot;handling POST /tickets&quot; do<br>&nbsp;&nbsp; before do<br>&nbsp;&nbsp;&nbsp;&nbsp; @ticket = mock_model(Ticket, :save =&gt; true)<br>&nbsp;&nbsp;&nbsp;&nbsp; @current_user = mock_model(User)<br>&nbsp;&nbsp;&nbsp;&nbsp; @params = {}
<br>&nbsp;&nbsp; end<br>&nbsp;&nbsp; def do_post<br>&nbsp;&nbsp;&nbsp;&nbsp; post :create, :ticket =&gt; @params<br>&nbsp;&nbsp; end<br>&nbsp;&nbsp; it &quot;should create a new ticket and assign current user as ticket&#39;s user&quot; do<br>&nbsp;&nbsp;&nbsp;&nbsp; @ticket.should_receive(:new).with(@params).and_return(@ticket)
<br>&nbsp;&nbsp;&nbsp;&nbsp; assigns[:ticket].user.should equal(@current_user)<br>&nbsp;&nbsp;&nbsp;&nbsp; do_post<br>&nbsp;&nbsp; end<br>end<br><br>1)<br>NoMethodError in &#39;TicketsController handling POST /tickets should create a new ticket and assign current user as ticket&#39;s user&#39;
<br>You have a nil object when you didn&#39;t expect it!<br>You might have expected an instance of Array.<br>The error occurred while evaluating nil.include?<br>/Volumes/EXTERNAL/web/yellowticket/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/assigns_hash_proxy.rb:10:in `[]&#39;
<br>./spec/controllers/tickets_controller_spec.rb:14:<br><br><br>My guess is that I&#39;m not allow to do this: assigns[:ticket].user<br>How do I apple the assignment with current_user?<br>