Sha256: eb5aae443827fe034210d64ecec83426aa0e159f56272487e4235f3ea1e21f29

Contents?: true

Size: 732 Bytes

Versions: 323

Compression:

Stored size: 732 Bytes

Contents

require 'tmpdir'

include FileUtils

# Prepares temporary fixture-directories and
# cleans them afterwards.
#
# @param [Fixnum] number_of_directories the number of fixture-directories to make
#
# @yield [path1, path2, ...] the empty fixture-directories
# @yieldparam [String] path the path to a fixture directory
#
def fixtures(number_of_directories = 1)
  current_pwd = pwd
  paths = 1.upto(number_of_directories).map do
    File.expand_path(File.join(pwd, "spec/.fixtures/#{Time.now.to_f.to_s.sub('.', '') + rand(9999).to_s}"))
  end

  # Create the dirs
  paths.each { |p| mkdir_p(p) }

  cd(paths.first) if number_of_directories == 1

  yield(*paths)

ensure
  cd current_pwd
  paths.map { |p| rm_rf(p) if File.exists?(p) }
end

Version data entries

323 entries across 224 versions & 13 rubygems

Version Path
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/fixtures_helper.rb
brakeman-4.4.0 bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/fixtures_helper.rb
brakeman-4.3.1 bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/fixtures_helper.rb
brakeman-4.3.0 bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/fixtures_helper.rb
brakeman-4.2.1 bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/fixtures_helper.rb
brakeman-4.2.0 bundle/ruby/2.3.0/gems/sass-3.4.25/vendor/listen/spec/support/fixtures_helper.rb
brakeman-4.1.1 bundle/ruby/2.3.0/gems/sass-3.4.25/vendor/listen/spec/support/fixtures_helper.rb
brakeman-4.1.0 bundle/ruby/2.3.0/gems/sass-3.4.25/vendor/listen/spec/support/fixtures_helper.rb
brakeman-4.0.1 bundle/ruby/2.3.0/gems/sass-3.4.25/vendor/listen/spec/support/fixtures_helper.rb
brakeman-4.0.1.pre1 bundle/ruby/2.3.0/gems/sass-3.4.25/vendor/listen/spec/support/fixtures_helper.rb
brakeman-4.0.0 bundle/ruby/2.3.0/gems/sass-3.4.25/vendor/listen/spec/support/fixtures_helper.rb
brakeman-3.7.2 bundle/ruby/2.3.0/gems/sass-3.4.25/vendor/listen/spec/support/fixtures_helper.rb
brakeman-3.7.1 bundle/ruby/2.3.0/gems/sass-3.4.25/vendor/listen/spec/support/fixtures_helper.rb
sass-3.4.25 vendor/listen/spec/support/fixtures_helper.rb
brakeman-3.7.0 bundle/ruby/2.3.0/gems/sass-3.4.24/vendor/listen/spec/support/fixtures_helper.rb
brakeman-3.6.2 bundle/ruby/2.3.0/gems/sass-3.4.24/vendor/listen/spec/support/fixtures_helper.rb
sass-3.4.24 vendor/listen/spec/support/fixtures_helper.rb
brakeman-3.6.1 bundle/ruby/2.3.0/gems/sass-3.4.23/vendor/listen/spec/support/fixtures_helper.rb
brakeman-3.6.0 bundle/ruby/2.3.0/gems/sass-3.4.23/vendor/listen/spec/support/fixtures_helper.rb
brakeman-3.5.0 bundle/ruby/2.3.0/gems/sass-3.4.23/vendor/listen/spec/support/fixtures_helper.rb