Sha256: 1c6a4b6a1566ea7551dc69a1557ae83a4cf4ffa8c7524d5be18df75e55ed5c47
Contents?: true
Size: 799 Bytes
Versions: 9
Compression:
Stored size: 799 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 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 "The file #{expected.inspect} existed before, so this test doesn't work" else yield end end end
Version data entries
9 entries across 9 versions & 3 rubygems