Note that there are some explanatory texts on larger screens.

plurals
  1. POrails test error with devise application
    text
    copied!<p>When i has added devise module to my rails application my tests thwors error </p> <pre><code> 73) Error: test_should_update_task(TasksControllerTest): ActionView::Template::Error: undefined method `authenticate' for nil:NilClass /home/razor/.gem/ruby/1.9.1/gems/devise-2.1.2/lib/devise/controllers/helpers.rb:56:in `current_user' /home/razor/.gem/ruby/1.9.1/gems/devise-2.1.2/lib/devise/controllers/helpers.rb:52:in `user_signed_in?' /home/razor/.gem/ruby/1.9.1/gems/actionpack-3.2.6/lib/abstract_controller/helpers.rb:53:in `user_signed_in?' /home/razor/work/judgement/app/views/layouts/application.html.erb:11:in `_app_views_layouts_application_html_erb___67557477041607610_29516700' /home/razor/.gem/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_view/template.rb:145:in `block in render' /home/razor/.gem/ruby/1.9.1/gems/activesupport-3.2.6/lib/active_support/notifications.rb:123:in `block in instrument' /home/razor/.gem/ruby/1.9.1/gems/activesupport-3.2.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument' /home/razor/.gem/ruby/1.9.1/gems/activesupport-3.2.6/lib/active_support/notifications.rb:123:in `instrument' /home/razor/.gem/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_view/template.rb:143:in `render' /home/razor/.gem/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_view/renderer/template_renderer.rb:59:in `render_with_layout' /home/razor/.gem/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_view/renderer/template_renderer.rb:45:in `render_template' /home/razor/.gem/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_view/renderer/template_renderer.rb:18:in `render' /home/razor/.gem/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_view/renderer/renderer.rb:36:in `render_template' /home/razor/.gem/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_view/renderer/renderer.rb:17:in `render' /home/razor/.gem/ruby/1.9.1/gems/actionpack-3.2.6/lib/abstract_controller/rendering.rb:110:in `_render_template' /home/razor/.gem/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_controller/metal/streaming.rb:225:in `_render_template' /home/razor/.gem/ruby/1.9.1/gems/actionpack-3.2.6/lib/abstract_controller/rendering.rb:103:in `render_to_body' /home/razor/.gem/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_controller/metal/renderers.rb:28:in `render_to_body' /home/razor/.gem/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_controller/metal/compatibility.rb:50:in `render_to_body' /home/razor/.gem/ruby/1.9.1/gems/actionpack-3.2.6/lib/abstract_controller/rendering.rb:88:in `render' /home/razor/.gem/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_controller/metal/rendering.rb:16:in `render' /home/razor/.gem/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render' /home/razor/.gem/ruby/1.9.1/gems/activesupport-3.2.6/lib/active_support/core_ext/benchmark.rb:5:in `block in ms' 93 tests, 36 assertions, 0 failures, 73 errors, 0 skips Errors running test:functionals! #&lt;RuntimeError: Command failed with status (73): [/usr/bin/ruby19 -I"lib:test" -I"/usr/lib64...]&gt; </code></pre> <p>where the application.html.erb is </p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Judgement&lt;/title&gt; &lt;%= stylesheet_link_tag "application", :media =&gt; "all" %&gt; &lt;%= javascript_include_tag "application" %&gt; &lt;%= csrf_meta_tags %&gt; &lt;/head&gt; &lt;body&gt; &lt;nav&gt; &lt;% if user_signed_in? then %&gt; &lt;%= link_to "You are #{current_user.email}", edit_user_registration_path %&gt; &lt;%= link_to "Exit", destroy_user_session_path, { :method =&gt; :delete, :confirm =&gt; "Are you sure"} %&gt; &lt;% else %&gt; &lt;%= link_to "Sign In", new_user_session_path %&gt; &lt;%= link_to "Register", new_user_registration_path %&gt; &lt;% end %&gt; &lt;/nav&gt; &lt;%= yield %&gt; &lt;div class="notice"&gt; &lt;%= notice %&gt; &lt;/div&gt; &lt;div class="alert"&gt; &lt;%= alert %&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>So this looks like error because "user_signed_in?" helper. But i can not understand what is the point of error. </p> <p>I am not very familiar with all Rails magic.</p> <p>UPD: SOLVED</p> <p>I was must to add</p> <pre><code>class ActionController::TestCase include Devise::TestHelpers end </code></pre> <p>to my test/test_helper.rb</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload