ruby - How to test obtaining a list of files within a directory using RSpec? -


I am very new in the world of RSPC. I am writing a RubyZam which works with a list of files within a specified directory and any sub-directory, especially, it will use Find.find and later files for output To the array.

I want to write a spec for testing this behavior but in reality it is not known where to insert the directory of the files and start in the exchange for Find.find and so on. It is very few that I've done so far:

  It should be returned "Any help greatly appreciated!   

">

I do not think you need to check the library, but if You have a method

  def file_names files = [] Find.find (Dir.pwd) {| file | file & lt; & lt; file} ........ End  

You can return a list of files such as

  A list of files within can tap the search method "specified directory" Find.stub! " (Search:) .and_return (['file1', 'file2']) @ object.file_names end  

or if you want to set expectations, you

  can "return a list of files within the specified directory" Find.should_receive (: find) .and_return (['file1', 'file2']) @ item. End of file_name  

Comments