开发者

Copy resources with frank and cucumber

I have a iPhone project where i use frank and cucumber for acceptance te开发者_运维百科sting.

My application has a feature to collect files from the documents directory and index them in the applications database.

I want to test this feature with cucumber. But this means i have to copy files to the applications documents directory.

My questions are:

  • How do i dynamically make step definitions to copy files?
  • Where do place the resources before they get copied? In what folder structure?
  • How do i reach these files from my step definitions?

Thanks.


We created a helper function to do something like this for injecting images into the simulator gallery..

def init_simulator_images(num_images)
  (1..num_images.to_i).each do |n|
    target_file = "IMG_000#{n}.JPG"
    begin
      File.stat("#{ENV['simulator_media_path']}/#{target_file}")
    rescue Errno::ENOENT
      app_exec 'FEX_loadPhotoLibraryImage:', "test/#{target_file}"
    end
  end
end

and then on the native code side, we have a helper class called FEX_Helper to aid in anything where we need to modify the app at runtime (RubyMotion code but v. similar to objective-c except for the syntax):

def FEX_loadPhotoLibraryImage(imageStr)
  img = UIImage.imageNamed(imageStr)
  UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil)
end

Lastly the simulator media path is defined thusly:

def simulator_media_path
  "#{self.simulator_version_path}/Media/DCIM/100APPLE"
end

def simulator_path
  "/Users/#{self.user}/Library/Application\ Support/iPhone\ Simulator"
end

def simulator_version_path
  "#{self.simulator_path}/#{self.simulator_version}"
end

Hope that helps someone trying to inject files into the simulator for testing.

Mark

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜