change spec config setup to use class method with_config

This commit is contained in:
Adam Meehan
2011-01-29 16:33:37 +11:00
parent 3793ef2ed4
commit 38457ec334
7 changed files with 48 additions and 76 deletions

View File

@@ -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