Rails rspec visit devise, ActionView::Template::Error undefined application_helper method-Collection of common programming errors

Hi there great folks of stackoverflow, I’ve been working on this really simple app, of which I’m testing with rspec and capybara. I’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:

Failure/Error: visit new_user_session_path
ActionView::Template::Error:
   undefined method `full_title' for #

As you can see, I’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’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 it works 100% in the browser with no error at all and showing the correct title, but it just fails when running the tests. I’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:

Rspec file:

describe "new quote" do
    before do
        # For now do it manually
        visit new_user_session_path
        fill_in "Email", with: @user.email
        fill_in "Password", with: @user.password
        click_button "Sign in"

        visit new_quote_path
    end

    it { should have_content "Create a new quote" }

    describe "with valid information" do
        before do
            fill_in "new-quote", with: "This is a quote."
            click_button "Post!"
        end

        it { should have_content "This is a quote" }
    end
end

The part in which the method is called inside the application.html.erb file


application_helper.rb file

module ApplicationHelper

    # Returns the full title on a per-page basis
    def full_title page_title
        base_title = "PX"
        if page_title.empty?
            base_title
        else
            "#{page_title} | #{base_title}"
        end
    end

end

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:



Sign in


 resource_name, :url => session_path(resource_name)) do |f| %>
  
true %>

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!)

Originally posted 2013-11-09 22:10:47.