1
我有一個模型,其行爲應該根據配置文件稍微改變。理論上,配置文件將爲我的客戶端的每次安裝應用程序進行更改。那麼我該如何測試這些變化?如何在Rails中測試不同的應用程序配置?
例如...
# in app/models/person.rb
before_save automatically_make_person_contributer if Rails.configuration.x.people['are_contributers_by_default']
# in test/models/person_test.rb
test "auto-assigns role if it should" do
# this next line doesn't actually work when the Person#before_save runs...
Rails.configuration.x.people['are_contributers_by_default'] = true
end
test "won't auto assign a role if it shouldn't" do
# this next line doesn't actually work when the Person#before_save runs...
Rails.configuration.x.people['are_contributers_by_default'] = false
end
它沒有意義,這些被存儲在數據庫中,因爲他們是一個時間的配置,但我需要確保在所有的我的應用程序的行爲所有環境中可能的配置。