Skip to content

Instantly share code, notes, and snippets.

@roalcantara
roalcantara / 1_remove_task.rake
Last active April 29, 2019 08:58
[Rails 5] Overriding `db:schema:load` rake in order to load legacy schema before running the default `db:schema:load` task
#lib/tasks/remove_task.rake
Rake::TaskManager.class_eval do
def remove_task(task_name)
@tasks.delete(task_name.to_s)
end
end
def remove_task(name)
Rake.application.remove_task(name)
@mattwynne
mattwynne / be_same_file_as.rb
Last active May 21, 2022 13:27
RSpec matcher to compare two file, using their MD5 hashes
RSpec::Matchers.define(:be_same_file_as) do |exected_file_path|
match do |actual_file_path|
expect(md5_hash(actual_file_path)).to eq(md5_hash(expected_file_path))
end
def md5_hash(file_path)
Digest::MD5.hexdigest(File.read(file_path))
end
end