mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-25 07:16:41 +00:00
change spec config setup to use class method with_config
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
module ConfigHelper
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
# Justin French tip
|
||||
def with_config(preference_name, temporary_value)
|
||||
old_value = ValidatesTimeliness.send(preference_name)
|
||||
@@ -7,4 +9,18 @@ module ConfigHelper
|
||||
ensure
|
||||
ValidatesTimeliness.send(:"#{preference_name}=", old_value)
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
def with_config(preference_name, temporary_value)
|
||||
original_config_value = ValidatesTimeliness.send(preference_name)
|
||||
|
||||
before(:all) do
|
||||
ValidatesTimeliness.send(:"#{preference_name}=", temporary_value)
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
ValidatesTimeliness.send(:"#{preference_name}=", original_config_value)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user