title: How to mock CSV foreach method in Rspec
body: <p>I have a method that uses CSV.foreach method.
  The data should look like that:</p>
  
  <p><code>1,0,0,1</code></p>
  
  <p><code>1,1,0,0</code></p>
  
  <p>I want to write a test which expects an error if I the number of elements is not the same in each line.</p>
  
  <p>Something like:</p>
  
  <pre><code>it "should raise an error if input file lines size differ" do
    expect { my_method(invalid_file_name) }.to raise_error
  end
  </code></pre>
  
  <p>How do I mock CSV's foreach method to return invalid input?</p>