Sha256: d2580a069cfad6aff74f264cb91a6298b54989fdf1942af9bf8c8c74262fbfbd
Contents?: true
Size: 748 Bytes
Versions: 2
Compression:
Stored size: 748 Bytes
Contents
RSpec::Matchers.define :create_file do |expected| match do |block| @before = exists?(expected) block.call @after = exists?(expected) !@before && @after end failure_message do |block| existed_before_message expected do "The file #{expected.inspect} was not created" end end failure_message_when_negated do |block| existed_before_message expected do "The file #{expected.inspect} was created" end end def exists?(expected) # Allows us to use wildcard checks for existence. !Dir.glob(expected).empty? end def existed_before_message(expected) if @before "The file #{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.1 | spec/support/matcher_create_file.rb |
metric_fu-4.11.0 | spec/support/matcher_create_file.rb |