module GivenFilesystemSpecHelpers
Public Class Methods
included(example_group)
click to toggle source
# File lib/given_filesystem/spec_helpers.rb, line 24 def self.included(example_group) example_group.extend(self) end
Public Instance Methods
given_directory(directory_name = nil) { || ... }
click to toggle source
# File lib/given_filesystem/spec_helpers.rb, line 40 def given_directory directory_name = nil check_initialization if block_given? path = @__given_filesystem.directory directory_name do yield end else path = @__given_filesystem.directory directory_name end path end
given_directory_from_data(directory_name, options = {})
click to toggle source
# File lib/given_filesystem/spec_helpers.rb, line 52 def given_directory_from_data directory_name, options = {} check_initialization path = @__given_filesystem.directory_from_data directory_name, options[:from] end
given_dummy_file(file_name = nil)
click to toggle source
# File lib/given_filesystem/spec_helpers.rb, line 65 def given_dummy_file file_name = nil check_initialization @__given_filesystem.file file_name end
given_file(file_name, options = {})
click to toggle source
# File lib/given_filesystem/spec_helpers.rb, line 57 def given_file file_name, options = {} check_initialization if !options[:from] options[:from] = file_name end @__given_filesystem.file file_name, options end
use_given_filesystem(options = {})
click to toggle source
# File lib/given_filesystem/spec_helpers.rb, line 28 def use_given_filesystem options = {} around do |example| @__given_filesystem = GivenFilesystem.new example.run if !options[:keep_files] @__given_filesystem.cleanup end end end
Private Instance Methods
check_initialization()
click to toggle source
# File lib/given_filesystem/spec_helpers.rb, line 72 def check_initialization if !@__given_filesystem raise "Call use_given_filesystem before calling other methods" end end