Sha256: 95e217ab0ebc771b3daf3811d9a023471d27c8979d1901d6a15add78dd48ccb8
Contents?: true
Size: 946 Bytes
Versions: 2
Compression:
Stored size: 946 Bytes
Contents
RSpec::Matchers.define :create_files do |expected| match do |block| @before = false @after = true expected.each do |file| @before |= exists?(file) end block.call expected.each do |file| @after &= exists?(file) end !@before && @after end failure_message do |block| existed_before_message expected do "One or more files in [#{expected.inspect}] was not created." end end failure_message_when_negated do |block| existed_before_message expected do "The files in [#{expected.inspect}] were created." end end def supports_block_expectations? true end def exists?(expected) # Allows us to use wildcard checks for existence. !Dir.glob(expected).empty? end def existed_before_message(expected) if @before "One or more files in [#{expected.inspect}] existed before, so this test doesn't work" else yield end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
metric_fu-4.11.3 | spec/support/matcher_create_files.rb |
metric_fu-4.11.2 | spec/support/matcher_create_files.rb |