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 7552341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:44:12+00:00 2026-05-30T10:44:12+00:00

I have a shared context in the /spec/support directory. This is called for every

  • 0

I have a shared context in the /spec/support directory. This is called for every example now, not only for those which include it. Is there something special about the support directory and where should I place it if I don’t want to run it on every example?

Here is the context-file:

require 'spec_helper'

shared_context "timeout context", :timeout do

  around(:each) do |example|
    timeout = example.metadata[:timeout] || 1.second
    Rails.logger.debug "timeout #{timeout} sec for: #{example.metadata[:example_group][:file_path].gsub(/.*?\/spec\//, '')}"
    Timeout::timeout(timeout) {
      example.run
    }
  end

end

Is this issue maybe related to the around(:each)?

  • 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-05-30T10:44:14+00:00Added an answer on May 30, 2026 at 10:44 am

    Seems a little bit like the around block is the culprit, so I added the following to a file in the folder /rspec/support/:

    RSpec.configure do |config|
      config.around(:each) do |example|
        if (example.metadata[:timeout])
          timeout = example.metadata[:timeout] || 1.second
          Rails.logger.debug "timeout #{timeout} sec for: #{example.metadata.full_description}"
          Timeout::timeout(timeout) do
            example.run
          end
        else
          example.run
        end
      end
    end
    

    and call my specs now with:

    describe 'explicit timeout of 5 seconds', :timeout => 5.seconds do
    end
    describe 'implicit timeout of 1 second', :timeout do
    end
    describe 'no timeout' do
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read this helpful post : SharedPreferences.onSharedPreferenceChangeListener not being called consistently However I
In .net we are not allowed to have shared function/methods in abstract classes and
I have created a multi module maven project. Now I have shared the project
i have shared the header file containing class definition of a Context Free grammar
I have a webapp in which I define the basic dispatcher-servlet context in web.xml
I have a chunk of shared memory containing some data. Reading / writing this
Let's say I have a python script which loads a shared library (SL) through
I have made a shared preference activity that store the user settings, now i
I have a core project which I'm building as a shared library. In one
For several applications I made for my current client I have shared user accounts.

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.