Created
November 15, 2012 22:31
-
-
Save alfielapeter/4081877 to your computer and use it in GitHub Desktop.
RSpec Helpers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This assumes that EVERY spec file has AT LEAST ONE SPEC in it. It can be pending but it must exist. | |
# Otherwise, the file_names and times will be off. | |
RSpec.configure do |config| | |
config.add_setting :file_count, default: 0 | |
config.add_setting :file_times, default: {} | |
config.before(:all) do | |
@start = Time.now | |
end | |
config.after(:all) do | |
finish = Time.now | |
time = finish - @start | |
file_name = File.basename(config.files_to_run[config.file_count],".rb") | |
config.file_times[file_name] = time | |
config.file_count += 1 | |
end | |
config.after(:suite) do | |
results = config.file_times.sort_by { |file_name, time| -time } | |
puts "\nTop 10 slowest spec files" | |
results[1..10].each do |result| | |
puts "#{result[0]}: #{result[1]}" | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Stolen from: http://www.rubyinside.com/careful-cutting-to-get-faster-rspec-runs-with-rails-5207.html | |
Spork.prefork do | |
# Don't need passwords in test DB to be secure, but we would like 'em to be | |
# fast -- and the stretches mechanism is intended to make passwords | |
# computationally expensive. | |
module Devise | |
module Models | |
module DatabaseAuthenticatable | |
protected | |
def password_digest(password) | |
password | |
end | |
end | |
end | |
end | |
Devise.setup do |config| | |
config.stretches = 0 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment