Module: GollyUtils::Testing::RSpecMatchers
- Defined in:
- lib/golly-utils/testing/rspec/files.rb,
lib/golly-utils/testing/rspec/arrays.rb,
lib/golly-utils/testing/rspec/base.rb
Overview
Instance Method Summary collapse
-
#be_file_with_contents(contents, *extra) ⇒ Object
(also: #be_file_with_content)
Checks that a file exists and has expected content.
-
#equal_array(expected) ⇒ Object
Passes if an array is the same as the target array.
-
#exist_as_a_dir ⇒ Object
(also: #exist_as_dir)
Passes if a directory exists (relative to the current directory) with a name specified by the target string.
-
#exist_as_a_file ⇒ Object
(also: #exist_as_file)
Passes if a file exists (relative to the current directory) with a name specified by the target string.
Instance Method Details
#be_file_with_contents(contents, *extra) ⇒ Object Also known as: be_file_with_content
Checks that a file exists and has expected content.
258 259 260 |
# File 'lib/golly-utils/testing/rspec/files.rb', line 258 def be_file_with_contents(contents, *extra) FileWithContents.new.and(contents).and(extra) end |
#equal_array(expected) ⇒ Object
The order and frequency of elements matters; call sort or uniq first if required.
Passes if an array is the same as the target array.
The advantage of calling this rather than == is that the error messages on failure here are customised for array
comparison and will provide much more useful description of why the arrays don't match.
78 79 80 81 |
# File 'lib/golly-utils/testing/rspec/arrays.rb', line 78 def equal_array(expected) return be_nil if expected.nil? EqualsArray.new(expected) end |
#exist_as_a_dir ⇒ Object Also known as: exist_as_dir
Passes if a directory exists (relative to the current directory) with a name specified by the target string.
144 145 146 |
# File 'lib/golly-utils/testing/rspec/files.rb', line 144 def exist_as_a_dir ExistAsDir.new end |
#exist_as_a_file ⇒ Object Also known as: exist_as_file
Passes if a file exists (relative to the current directory) with a name specified by the target string.
Note: This only passes if a file is found; a directory with the same name will fail.
102 103 104 |
# File 'lib/golly-utils/testing/rspec/files.rb', line 102 def exist_as_a_file ExistAsFile.new end |