in rspec, I have a spec that looks something like this:
require 'spec_helper'
describe IncomingMailsController do
include Devise::TestHelpers
it "should find the correct text in the sample" do
sample_text = '100s of these'
target_text = 'find me'
.... ALL Kinds of stuff to process (30+ lines)
thread.content.should == 'find me'
end
end
Is there a way with rspec, to allow me to somehow use all that logic in one block? And then create 100s of it “xxxxx” do, and pass that a variable being the sample text?
Thanks
You can put the
ittest blocks inside a loop, and run through a collection of all the times you want to each for (in the example below those items are in thesearch_itemscollection)UPDATE
I saw on a comment to another answer in this threase that you have a directory with 100+ files of samples, you can get the list of filenames using Dir#glob. You can then use that in the loop to generate your
ittest cases.UPDATE 2
You might have to play with the full path of file_name but that should get you some of the way.