Last active
October 12, 2015 17:37
-
-
Save jparker/4062626 to your computer and use it in GitHub Desktop.
Snippet to be placed in test_helper.rb or spec_helper.rb to trick has_secure_password into using lower cost bcrypt encryption than the default.
This file contains hidden or 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
# Place in test_helper.rb or spec_helper.rb | |
AuthLogic::CryptoProviders::BCrypt.cost = 1 |
This file contains hidden or 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
# Place in test_helper.rb, spec_helper.rb or spec/support/... | |
require 'bcrypt' | |
class BCrypt::Password | |
class << self | |
method = instance_method(:create) | |
define_method :create do |arg, options = {cost: 1}| | |
method.bind(self).call(arg, options) | |
end | |
end | |
end |
This file contains hidden or 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
# Place in test_helper.rb or spec_helper.rb | |
Devise.setup do |config| | |
config.stretches = 1 | |
end |
This file contains hidden or 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
# Before... | |
$ bundle exec rspec ./spec/features | |
.................................................................................................................. | |
Finished in 42.67 seconds | |
114 examples, 0 failures | |
Randomized with seed 48858 | |
# ...and after | |
$ SPEC_OPTS="--seed 48858" bundle exec rspec ./spec/features | |
.................................................................................................................. | |
Finished in 27.36 seconds | |
114 examples, 0 failures | |
Randomized with seed 48858 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment