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

  • Home
  • SEARCH
  • 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 6535319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:21:34+00:00 2026-05-25T10:21:34+00:00

My tests look like this: <<< spec/models/user_shared.rb shared_examples_for a user do end <<< spec/models/worker_spec.rb

  • 0

My tests look like this:

<<< spec/models/user_shared.rb

shared_examples_for "a user" do
end

<<< spec/models/worker_spec.rb

require 'spec_helper'
require 'models/user_shared'

describe Worker do
  it_behaves_like "a user"
end

I can run rspec spec successfully. But autotest fails:

Exception encountered: #<ArgumentError: Shared example group 'a user' already exists>

This is, because the rspec command line generated by autotest includes the user_shared.rb:

/usr/local/rvm/rubies/ruby-1.9.2-p290/bin/ruby -rrubygems -S /usr/local/rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/bin/rspec --tty [...] '/path/to/project/spec/models/worker_spec.rb' '/path/to/project/spec/models/user_shared.rb'
Running tests with args ["--color", "--tty", [...], "/path/to/project/spec/models/worker_spec.rb", "/path/to/project/spec/models/user_shared.rb"]...
Done.

Exception encountered: #<ArgumentError: Shared example group 'a user' already exists>

When I remove the '/path/to/project/spec/models/user_shared.rb' from the command line and execute it by hand, it works.

Now, if I change my user_shared.rb to this:

<<< spec/models/user_shared.rb

if !@included then
  @included = true
  shared_examples_for "a user" do
  end
end

it works with the command line generated by autotest, too. But it is an ugly workaround.

Since rspec knows only “*_spec” files are testes, how can autotest be configured like this?

In my Gemfile I have the following (relevant to testing):

<<<< Gemfile

gem 'autotest'
gem 'autotest-rails'

group :test do
  gem 'rspec-rails', '>= 2.6.1'
  gem 'shoulda-matchers'
  gem 'factory_girl_rails', '>= 1.0.2'
  gem 'capybara', '>= 1.0.0'
  gem 'cucumber-rails', '>= 1.0.2'
  gem 'database_cleaner', '>= 0.6.7'
  gem 'spork', '>= 0.9.0.rc'
end
  • 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-25T10:21:35+00:00Added an answer on May 25, 2026 at 10:21 am

    Got it myself … reorganization of folder structure.

    • created new folder spec/shared/ and moved all examples in there
    • removed any require *_shared.rb from my examples
    • added Dir[Rails.root.join("spec/shared/**/*.rb")].each {|f| require f} to spec_helper.rb
    • tweaked autotest:

    .

    <<< .autotest
    
      at.add_mapping(%r%^spec/shared/.*rb%) { |_, _|
        Dir['spec/**/*_spec.rb'] # could be tweaked to just run tests that have this example
                                 # but for now I don't care - just run all tests
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My tests may look like this: module(some module); test(test A, ...); test(test B, ...);
In Python, I often have tests which look something like this: tests = [
The models I'm working with look like this: class ComplexAssertion < ActiveRecord::Base has_many :expression_groups
I run NCoverExploler, configure it, so command line look like this D:\Development\Projects\t.net\lib\NCover\NCover.Console.exe //reg //w
I have controller methods that look like this: class TestController < ApplicationController def testAction
I want to write tests for my app, though each time I look at
I did this tests and the results seems the count function scale linearly. I
I have an array like this: [234, 235 , 343, 445] I want to
I got a pretty simple parent/child relationship here, which looks like this: Email servers
Consider the following jasmine spec: describe(something.act(), function() { it(calls some function of my module,

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.