title: RSpec: DRY way to test a set of values
body: <p>I have a <code>vote</code> model, which has a class method called <code>score</code>. Basically, I created a mathematical equation in a spreadsheet, and am attempting to reproduce this in ruby. However, my first go isn't working, so I really need to start adding a ton more tests.</p>
  
  <p>The way I'd like to go about testing this is to take a stack of input and output values from my spreadsheet and test them each. So basically, the tests could be construed to look like this:</p>
  
  <pre><code> inputs = [a,b,c] ... score.should == x
   inputs = [a,b,c,d] ... score.should == y
   inputs = [c,d] .... score.should == z
  </code></pre>
  
  <p>However, the shortest way I've actually found to write this in RSpec is giving an example for each case, approximately like this (simplified example, but should give you the idea):</p>
  
  <pre><code>it "should have a score of X" do
    test_object = Votable.new(...)
    @user1.vote.create(:value=&gt;##, :votable=&gt;test_object)
    @user2.vote.create(:value=&gt;##, :votable=&gt;test_object)
    @user3.vote.create(:value=&gt;##, :votable=&gt;test_object)
    test_object.votes.score.should == X
  end
  </code></pre>
  
  <p>So, the above works, but its a load of text for each example case, and to iron out the kinks and provide good test coverage I'd like to run about 20 or so test cases.</p>
  
  <p>So, seriously, there must be a simpler way to set this up one time and then test a bunch of possible input/output combinations, right? Can anyone suggest a DRY way to do this kind of test in RSpec?</p>
  
  <p>Thanks!</p>