Class: CLIntegracon::FileTreeSpecContext
- Inherits:
-
Object
- Object
- CLIntegracon::FileTreeSpecContext
- Defined in:
- lib/CLIntegracon/file_tree_spec_context.rb
Attributes collapse
-
#after_dir ⇒ Pathname
The relative path from a concrete spec directory to the directory containing the expected files after the execution.
-
#before_dir ⇒ Pathname
The relative path from a concrete spec directory to the directory containing the input files, which will be available at execution.
-
#include_hidden_files ⇒ Bool
(also: #include_hidden_files?)
Whether to include hidden files, when searching directories (true by default).
-
#spec_path ⇒ Pathname
The relative path to the integration specs.
-
#special_paths ⇒ Hash<String,Block>
The special paths of files, where an individual file diff handling is needed.
-
#temp_path ⇒ Pathname
The relative path to the directory containing the produced files after the execution.
-
#transform_paths ⇒ Hash<String,Block>
The special paths of files, which need to be transformed in a better comparable form.
Initializer collapse
-
#initialize(properties = {}) ⇒ FileTreeSpecContext
constructor
“Designated” initializer.
Helper collapse
-
.nop ⇒ Proc
This value is used for ignored paths.
DSL-like Setter collapse
-
#has_special_handling_for(*file_paths, &block) ⇒ Object
Registers a block for special handling certain files, matched with globs.
-
#ignores(*file_path) ⇒ Object
Copies the before subdirectory of the given tests folder in the temporary directory.
-
#transform_produced(*file_paths, &block) ⇒ Object
Registers a block for special handling certain files, matched with globs.
Interaction collapse
-
#prepare! ⇒ Object
Prepare the temporary directory and the attribute #temp_path itself.
-
#spec(spec_folder) ⇒ FileTreeSpec
Get a specific spec with given folder to run it.
Constructor Details
#initialize(properties = {}) ⇒ FileTreeSpecContext
“Designated” initializer
59 60 61 62 63 64 65 66 67 |
# File 'lib/CLIntegracon/file_tree_spec_context.rb', line 59 def initialize(properties={}) self.spec_path = properties[:spec_path] || '.' self.temp_path = properties[:temp_path] || 'tmp' self.before_dir = properties[:before_dir] || 'before' self.after_dir = properties[:after_dir] || 'after' self.transform_paths = {} self.special_paths = {} self.include_hidden_files = true end |
Instance Attribute Details
#after_dir ⇒ Pathname
Returns The relative path from a concrete spec directory to the directory containing the expected files after the execution.
22 23 24 |
# File 'lib/CLIntegracon/file_tree_spec_context.rb', line 22 def after_dir @after_dir end |
#before_dir ⇒ Pathname
Returns The relative path from a concrete spec directory to the directory containing the input files, which will be available at execution.
17 18 19 |
# File 'lib/CLIntegracon/file_tree_spec_context.rb', line 17 def before_dir @before_dir end |
#include_hidden_files ⇒ Bool Also known as:
Returns whether to include hidden files, when searching directories (true by default).
42 43 44 |
# File 'lib/CLIntegracon/file_tree_spec_context.rb', line 42 def include_hidden_files @include_hidden_files end |
#spec_path ⇒ Pathname
Returns The relative path to the integration specs.
12 13 14 |
# File 'lib/CLIntegracon/file_tree_spec_context.rb', line 12 def spec_path @spec_path end |
#special_paths ⇒ Hash<String,Block>
Returns the special paths of files, where an individual file diff handling is needed.
38 39 40 |
# File 'lib/CLIntegracon/file_tree_spec_context.rb', line 38 def special_paths @special_paths end |
#temp_path ⇒ Pathname
Attention: This path will been deleted before running to ensure a clean sandbox for testing.
Returns The relative path to the directory containing the produced files after the execution. This must not be the same as the before_dir or the after_dir.
30 31 32 |
# File 'lib/CLIntegracon/file_tree_spec_context.rb', line 30 def temp_path @temp_path end |
#transform_paths ⇒ Hash<String,Block>
Returns the special paths of files, which need to be transformed in a better comparable form.
34 35 36 |
# File 'lib/CLIntegracon/file_tree_spec_context.rb', line 34 def transform_paths @transform_paths end |
Class Method Details
.nop ⇒ Proc
This value is used for ignored paths
78 79 80 |
# File 'lib/CLIntegracon/file_tree_spec_context.rb', line 78 def self.nop @nop ||= Proc.new {} end |
Instance Method Details
#has_special_handling_for(*file_paths, &block) ⇒ Object
Registers a block for special handling certain files, matched with globs. Registered file paths will be excluded from default comparison by ‘diff`. Multiple special handlers can match a single file.
141 142 143 144 145 |
# File 'lib/CLIntegracon/file_tree_spec_context.rb', line 141 def has_special_handling_for(*file_paths, &block) file_paths.each do |file_path| self.special_paths[file_path] = block end end |
#ignores(*file_path) ⇒ Object
Copies the before subdirectory of the given tests folder in the temporary directory.
153 154 155 |
# File 'lib/CLIntegracon/file_tree_spec_context.rb', line 153 def ignores(*file_path) has_special_handling_for *file_path, &self.class.nop end |
#prepare! ⇒ Object
Prepare the temporary directory and the attribute #temp_path itself.
164 165 166 167 |
# File 'lib/CLIntegracon/file_tree_spec_context.rb', line 164 def prepare! temp_path.mkpath @temp_path = temp_path.realpath end |
#spec(spec_folder) ⇒ FileTreeSpec
Get a specific spec with given folder to run it
176 177 178 |
# File 'lib/CLIntegracon/file_tree_spec_context.rb', line 176 def spec(spec_folder) FileTreeSpec.new(self, spec_folder) end |
#transform_produced(*file_paths, &block) ⇒ Object
Registers a block for special handling certain files, matched with globs. Multiple transformers can match a single file.
124 125 126 127 128 |
# File 'lib/CLIntegracon/file_tree_spec_context.rb', line 124 def transform_produced(*file_paths, &block) file_paths.each do |file_path| self.transform_paths[file_path] = block end end |