title: Rspec: testing looping arrays , input = [] , output =[] for custom classes. ruby
body: <p>I'm trying to speed up my tests development using the examples I use to develop the function in the output.</p>
  
  <p>I have two arrays: Input and output.</p>
  
  <p><code>function(input[0]) == output[0]</code>.</p>
  
  <p>The loop is working, but it gets stuck in the last index. example: if input.length = 10 it always do function(input[10]) == output[10].</p>
  
  <pre><code>describe "multiple_chords" do
    input = ["A7 DMaj79", "E-7 A7", "D-7 G7", "Bb-7b5 Eb7b9" , "Bb-7b5 Eb7", "G7 A7", "D-7b5 G7b9", "D-79 G#7913"]
    output = [[{"root"=&gt;"A", "def"=&gt;"7"}, {"root"=&gt;"D", "def"=&gt;"Maj7"}], [{"root"=&gt;"E", "def"=&gt;"-7"}, {"root"=&gt;"A", "def"=&gt;"7"}], [{"root"=&gt;"D", "def"=&gt;"-7"}, {"root"=&gt;"G", "def"=&gt;"7"}], [{"root"=&gt;"Bb", "def"=&gt;"-7b5"}, {"root"=&gt;"Eb", "tensions"=&gt;"b9", "def"=&gt;"7"}], [{"root"=&gt;"Bb", "def"=&gt;"-7b5"}, {"root"=&gt;"Eb", "def"=&gt;"7"}], [{"root"=&gt;"G", "def"=&gt;"7"}, {"root"=&gt;"A", "def"=&gt;"7"}], [{"root"=&gt;"D", "def"=&gt;"-7b5"}, {"root"=&gt;"G", "tensions"=&gt;"b9", "def"=&gt;"7"}], [{"root"=&gt;"D", "tensions"=&gt;"9", "def"=&gt;"-7"}, {"root"=&gt;"G#", "tensions"=&gt;["9", "13"], "def"=&gt;"7"}]]
  
    for i in 0..input.length-1
      it "analyzes correctly #{input[i]}" do
        expect(IpmChords::multiple_chords(input[i])).to eq(output[i])
      end
    end
  end
  </code></pre>
  
  <p>The output in the console is:</p>
  
  <pre><code> 6) IpmChords multiple_chords analyzes correctly Bb-7b5 Eb7
   Failure/Error: expect(IpmChords::multiple_chords(input[i])).to eq(output[i])
  
     expected: [{"root"=&gt;"D", "tensions"=&gt;"9", "def"=&gt;"-7"}, {"root"=&gt;"G#", "tensions"=&gt;["9", "13"], "def"=&gt;"7"}]
          got: [{"root"=&gt;"D", "tensions"=&gt;"9", "def"=&gt;"-7"}, {"root"=&gt;"G#", "tensions"=&gt;"13", "def"=&gt;""}]
  
     (compared using ==)
  
     Diff:
     @@ -1,3 +1,3 @@
      [{"root"=&gt;"D", "tensions"=&gt;"9", "def"=&gt;"-7"},
     - {"root"=&gt;"G#", "tensions"=&gt;["9", "13"], "def"=&gt;"7"}]
     + {"root"=&gt;"G#", "tensions"=&gt;"13", "def"=&gt;""}]
  
   # ./spec/ipm_classes/ipm_chords_ipm_class_spec.rb:28:in `block (4 levels) in &lt;top (required)&gt;'
  
  7) IpmChords multiple_chords analyzes correctly E-7 A7
   Failure/Error: expect(IpmChords::multiple_chords(input[i])).to eq(output[i])
  
     expected: [{"root"=&gt;"D", "tensions"=&gt;"9", "def"=&gt;"-7"}, {"root"=&gt;"G#", "tensions"=&gt;["9", "13"], "def"=&gt;"7"}]
          got: [{"root"=&gt;"D", "tensions"=&gt;"9", "def"=&gt;"-7"}, {"root"=&gt;"G#", "tensions"=&gt;"13", "def"=&gt;""}]
  
     (compared using ==)
  
     Diff:
     @@ -1,3 +1,3 @@
      [{"root"=&gt;"D", "tensions"=&gt;"9", "def"=&gt;"-7"},
     - {"root"=&gt;"G#", "tensions"=&gt;["9", "13"], "def"=&gt;"7"}]
     + {"root"=&gt;"G#", "tensions"=&gt;"13", "def"=&gt;""}]
  </code></pre>
  
  <p>You can see it is always evaluating the same array index, but the test name is changing for each loop iteration: </p>
  
  <pre><code>6) IpmChords multiple_chords analyzes correctly Bb-7b5 Eb7
  7) IpmChords multiple_chords analyzes correctly E-7 A7
  </code></pre>
  
  <p>I think it will be a great time saver, and it should work, no??
  Hope you can help me.
  Thanks</p>