Sha256: b1940c957ade7c9587761268bc4329b2758777d33467d8a2b9a380cd02bb13ad
Contents?: true
Size: 1.47 KB
Versions: 2
Compression:
Stored size: 1.47 KB
Contents
# @!method have_sub_directory(sub_directory) # This matchers checks if <directory> has given sub-directory # # @param [Array] sub_directory # A list of sub-directory relative to current directory # # @return [TrueClass, FalseClass] The result # # false: # * if directory does not have sub-directory # true: # * if directory has sub-directory # # @example Use matcher with single directory # # RSpec.describe do # it { expect('dir1.d').to have_sub_directory('subdir.1.d') } # end # # @example Use matcher with multiple directories # # RSpec.describe do # it { expect('dir1.d').to have_sub_directory(['subdir.1.d', 'subdir.2.d']) } # it { expect(directories).to include a_directory_with_sub_directory(['subdir.1.d', 'subdir.2.d']) } # end RSpec::Matchers.define :have_sub_directory do |expected| match do |actual| next false unless directory?(actual) @old_actual = actual @actual = list(actual) @expected = Array(expected).map { |p| File.join(@old_actual, p) } (@expected - @actual).empty? end diffable failure_message do |actual| format("expected that directory \"%s\" has the following sub-directories: %s.", actual.join(', '), expected) end failure_message_when_negated do |actual| format("expected that directory \"%s\" does not have the following sub-directories: %s.", actual.join(', '), expected) end end RSpec::Matchers.alias_matcher :a_directory_having_sub_directory, :have_sub_directory
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
aruba-0.8.0.pre2 | lib/aruba/matchers/directory/have_sub_directory.rb |
aruba-0.8.0.pre | lib/aruba/matchers/directory/have_sub_directory.rb |