title: How to run rspec tests in different configurations
body: <p><em>My problem must have been already solved but I can't find it.</em> </p>
  
  <p>I have tests/examples in various describe blocks, in different files. These tests can run in three different configurations phone, tablet and desktop. What is the best practice to group by tests so that I can run them together or standalone. </p>
  
  <p>I tried following <a href="https://www.relishapp.com/rspec/rspec-core/v/2-0/docs/example-groups/shared-example-group" rel="nofollow">shared_example</a> approach</p>
  
  <pre><code>shared_examples 'tests' do |form_factor|
     it 'example 1' do 
     end
     it 'example 2' do 
     end
     it 'example 3' do 
     end
  end
  </code></pre>
  
  <p>in another file</p>
  
  <pre><code> shared_examples 'tests' do |form_factor|
      it 'example 1' do 
      end
      it 'example 2' do 
      end
   end
  </code></pre>
  
  <p>But this approach does not work with tests in another file. As soon as I add another shared_examples block in another file I get </p>
  
  <pre><code>WARNING: Shared example group 'tests' has been previously defined at:
    /1_spec.rb:3
  ...and you are now defining it at:
    /2_spec.rb:2
  The new definition will overwrite the original one.
  </code></pre>
  
  <p>I also tried the approach of going with environment variables but passing all these on command line like this</p>
  
  <pre><code>FORM_FACTOR=phone rspec .
  FORM_FACTOR=table rspec . 
  </code></pre>
  
  <p>seems unwieldy. Suggestions? My objective is to be able to pass in different form_factors or run all of them. So if I do something like</p>
  
  <blockquote>
    <p>rspec run_all</p>
  </blockquote>
  
  <p>all  the form factors should be passed and run all three tests
  and if I send in </p>
  
  <blockquote>
    <p>rspec run_phone</p>
  </blockquote>
  
  <p>only phone should be send in</p>