Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8925173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:37:35+00:00 2026-06-15T07:37:35+00:00

I have a method in my ApplicationHelper that checks to see if there are

  • 0

I have a method in my ApplicationHelper that checks to see if there are any items in my basket

module ApplicationHelper
  def has_basket_items?
    basket = Basket.find(session[:basket_id])
    basket ? !basket.basket_items.empty? : false
  end
end

Here is my helper spec that I have to test this:

require 'spec_helper'

describe ApplicationHelper do
  describe 'has_basket_items?' do
    describe 'with no basket' do

      it "should return false" do
        helper.has_basket_items?.should be_false
      end

    end
  end
end

however when I run the test i get

SystemStackError: stack level too deep
/home/user/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/testing/test_process.rb:13:

From debugging this i see that session is being accessed in ActionDispatch::TestProcess from @request.session, and @request is nil. When i access the session from my request specs @request is an instance of ActionController::TestRequest.

My question is can I access the session object from a helper spec? If I can, how? And if I cant what is the best practice to test this method?

****UPDATE****

This was down to having include ActionDispatch::TestProcess in my factories. Removing this include sorts the problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:37:36+00:00Added an answer on June 15, 2026 at 7:37 am

    can I access the session object from a helper spec?

    Yes.

    module ApplicationHelper
      def has_basket_items?
        raise session.inspect
        basket = Basket.find(session[:basket_id])
        basket ? !basket.basket_items.empty? : false
      end
    end
    
    $ rspec spec/helpers/application_helper.rb
    
    Failure/Error: helper.has_basket_items?.should be_false
      RuntimeError:
        {}
    

    The session object is there and returns an empty hash.

    Try reviewing the backtrace in more detail to find the error. stack level too deep usually indicates recursion gone awry.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have method that returns module path of given class name def findModulePath(path, className):
I have method in my controller: def work_here @company = Company.find(params[:id]) current_user.work_apply(current_user, @company) redirect_to
I have the following helper method (app/helpers/application_helper.rb): module ApplicationHelper #Return a title on a
I've got the view helper method in my application helper: module ApplicationHelper def formatted_something(something)
I have method that returns Drawable , and if its Bitmap object is recycled
I have method that returned NSManagedObject and I don't know what kind of NSManagedObject
I have method in a class that I need to make sure is only
I've got some 3rd party beans that have method signatures that fit quite well
I have a method(say method1) that writes to database(sqlserver)and another method(say method2) that tries
I have this method on rails so that I have an image calling a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.