{"id":739,"date":"2022-08-30T15:06:22","date_gmt":"2022-08-30T15:06:22","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/rails-rspec-visit-devise-actionviewtemplateerror-undefined-application_helper-method-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:06:22","modified_gmt":"2022-08-30T15:06:22","slug":"rails-rspec-visit-devise-actionviewtemplateerror-undefined-application_helper-method-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/rails-rspec-visit-devise-actionviewtemplateerror-undefined-application_helper-method-collection-of-common-programming-errors\/","title":{"rendered":"Rails rspec visit devise, ActionView::Template::Error undefined application_helper method-Collection of common programming errors"},"content":{"rendered":"<p>Hi there great folks of stackoverflow, I&#8217;ve been working on this really simple app, of which I&#8217;m testing with rspec and capybara. I&#8217;m also using devise for authentication and user creation. Everything has been working fine until I wrote a little test in which I had to sign in the user. The problem is that Rspec gives me the following error:<\/p>\n<pre><code>Failure\/Error: visit new_user_session_path\nActionView::Template::Error:\n   undefined method `full_title' for #\n<\/code><\/pre>\n<p>As you can see, I&#8217;m getting an ActionView error telling me that my full_title method (which is a method in my application_helper.rb file for setting the full_title, which is called on the application.html.erb file) is undefined. I don&#8217;t know whats wrong and it seems to be failing only when visiting a Devise route path. It is important for me to tell you guys that <strong>it works 100% in the browser with no error at all and showing the correct title, but it just fails when running the tests<\/strong>. I&#8217;ve been searching for the answer and after hours of no luck I just had to see if somebody could help me. Here is my code:<\/p>\n<p>Rspec file:<\/p>\n<pre><code>describe \"new quote\" do\n    before do\n        # For now do it manually\n        visit new_user_session_path\n        fill_in \"Email\", with: @user.email\n        fill_in \"Password\", with: @user.password\n        click_button \"Sign in\"\n\n        visit new_quote_path\n    end\n\n    it { should have_content \"Create a new quote\" }\n\n    describe \"with valid information\" do\n        before do\n            fill_in \"new-quote\", with: \"This is a quote.\"\n            click_button \"Post!\"\n        end\n\n        it { should have_content \"This is a quote\" }\n    end\nend\n<\/code><\/pre>\n<p>The part in which the method is called inside the <strong>application.html.erb<\/strong> file<\/p>\n<pre><code>\n<\/code><\/pre>\n<p><strong>application_helper.rb<\/strong> file<\/p>\n<pre><code>module ApplicationHelper\n\n    # Returns the full title on a per-page basis\n    def full_title page_title\n        base_title = \"PX\"\n        if page_title.empty?\n            base_title\n        else\n            \"#{page_title} | #{base_title}\"\n        end\n    end\n\nend\n<\/code><\/pre>\n<p>It might be good to note that I generated the devise views so I could modify some things from the default views. The new_user_session_path view:<\/p>\n<pre><code>\n\n<\/code><\/pre>\n<h2><code>Sign in<\/code><\/h2>\n<pre>\n\n resource_name, :url =&gt; session_path(resource_name)) do |f| %&gt;\n  <br \/>\n   true %&gt;\n\n  <br \/>\n  \n\n  \n     \n  \n\n  \n\n\n\n<\/pre>\n<p><code>Hopefully I've made my self as clear as possible, and I hope somebody can help me, thanks in advanced! (I hope it isn't something horribly simple!)<\/code><\/p>\n<p id=\"rop\"><small>Originally posted 2013-11-09 22:10:47. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>Hi there great folks of stackoverflow, I&#8217;ve been working on this really simple app, of which I&#8217;m testing with rspec and capybara. I&#8217;m also using devise for authentication and user creation. Everything has been working fine until I wrote a little test in which I had to sign in the user. The problem is that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,1],"tags":[],"class_list":["post-739","post","type-post","status-publish","format-standard","hentry","category-capybara","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/739","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=739"}],"version-history":[{"count":1,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/739\/revisions"}],"predecessor-version":[{"id":8759,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/739\/revisions\/8759"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=739"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=739"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=739"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}