Module: GivenFilesystemSpecHelpers
- Defined in:
- lib/given_filesystem/spec_helpers.rb
Class Method Summary collapse
Instance Method Summary collapse
- #given_directory(directory_name = nil) ⇒ Object
- #given_directory_from_data(directory_name, options = {}) ⇒ Object
- #given_dummy_file(file_name = nil) ⇒ Object
- #given_file(file_name, options = {}) ⇒ Object
- #use_given_filesystem(options = {}) ⇒ Object
Class Method Details
.included(example_group) ⇒ Object
24 25 26 |
# File 'lib/given_filesystem/spec_helpers.rb', line 24 def self.included(example_group) example_group.extend(self) end |
Instance Method Details
#given_directory(directory_name = nil) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# 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 = {}) ⇒ Object
52 53 54 55 |
# File 'lib/given_filesystem/spec_helpers.rb', line 52 def given_directory_from_data directory_name, = {} check_initialization path = @__given_filesystem.directory_from_data directory_name, [:from] end |
#given_dummy_file(file_name = nil) ⇒ Object
65 66 67 68 |
# 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 = {}) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/given_filesystem/spec_helpers.rb', line 57 def given_file file_name, = {} check_initialization if ![:from] [:from] = file_name end @__given_filesystem.file file_name, end |
#use_given_filesystem(options = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/given_filesystem/spec_helpers.rb', line 28 def use_given_filesystem = {} around do |example| @__given_filesystem = GivenFilesystem.new example.run if ![:keep_files] @__given_filesystem.cleanup end end end |