# Checks if a directory has a migration from given source file. RSpec::Matchers.define :have_migration_from do |source| match do |dir| # Search file that matches source with any timestamp. basename = File.basename(source, ".rb")[14..-1] sample = "*#{ basename }.uuids.rb" search = File.join(dir, sample) file = Dir[search].first # Check the file exists and has required content. expect(file).not_to be_nil expect(File.read file).to eq File.read source end end