title: Passing parameters to an rspec shared example
body: <p>I have a process that returns a result set that I want to test for validity using rspec. The process will return different results based on parameters but there are many examples that are common to all of them so I would like to create a set of common examples that I can run against all of them.</p>
  
  <p>I know that the preferred practice is to use let to build the result. The problem is that each process takes a minute or two to generate a result and I have probably 30 examples. With all of the permutations based on different parameters I am running about 500 examples.If I had to rebuild the result for each example the test would run more than a day.</p>
  
  <p>So instead I am building a result in a before(:all) block and assigning it to an attribute something like this:</p>
  
  <pre><code>RSpec.describe 'Test Description' do
    attr_reader :result
  
    before(:all)
      @result = build_result({some_parameters})
    end
  
    context 'Some context' do
      it 'Looks lik a result' do 
        expect(result.something).to ...
      end
  
      it 'Feels lik a result' do 
        expect(result.something).to ...
      end
    end
  end
  </code></pre>
  
  <p>Maybe there is a better way than using an attribute. I want to do something like this:</p>
  
  <pre><code>RSpec.describe 'Test Description' do
    attr_reader :result
  
    before(:all)
      @result = build_result({some_parameters})
    end
  
    context 'Some context' do
      it_behaves_like "A result" result
    end
  end
  </code></pre>
  
  <p>Using an attribute in this context fails. Is there a different way to do this?</p>