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
它没有意义,这些被存储在数据库中,因为他们是一个时间的配置,但我需要确保在所有的我的应用程序的行为所有环境中可能的配置。