title: Data providers for Rails testing
body: <p>New to both Ruby and Rails, working on an app using <code>Test::Unit</code>. I come from a background in PHP and PHPUnit, where they provide formal structure for <a href="http://phpunit.de/manual/current/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.data-providers" rel="nofollow"><code>data providers</code></a>: you define a nested array/hash of arguments in one method, then loop a single test through it, swapping the arguments on each pass. It's a concise way to repeatedly test the the same event with different parameters.</p>
  
  <p>The only solution I have found thus far is to replicate the concept manually, inside a single test:</p>
  
  <pre><code>test "should properly do something" do
    provider = [
      {:var1 =&gt; 'foo',     :var2 =&gt; 'bar', :expected =&gt; true},
      {:var1 =&gt; 'foo',     :var2 =&gt; 'baz', :expected =&gt; true},
      {:var1 =&gt; 'invalid', :var2 =&gt; 'bar', :expected =&gt; false},
      # ...
    ]
    provider.each do |t|
      assert_equal(t.expected, SomeObject.some_method(t.var1, t.var2))
    end
  end
  </code></pre>
  
  <p>This doesn't give me as much useful test output, since it can't discern which loop actually fails in the event of an error. </p>
  
  <p>Is there a better way to do this?</p>