[rspec-users] dynamic tests possible?

David Chelimsky dchelimsky at gmail.com
Wed Aug 18 12:38:32 EDT 2010

On Aug 18, 2010, at 11:31 AM, rogerdpack wrote:

> Sorry if this is a newbie question, but here goes.
> I was wondering if the following is somehow possible:
>  for file in Dir['*.bmp']

Use this instead:

Dir["*.bmp"].each do |file| 
>    it "should be able to parse #{file}" do
>      p file
>      # test this file
>    end
>  end
> Currently rspec seems to evaluate the blocks after the fact, leading
> to "file" always being the last file in the list.
> I was unsure how to pass a parameter into an "it" block.
> Thoughts?
> Thanks.
> -r

More information about the rspec-users mailing list