testing - Rails application settings and tests -
in app i've used settingslogic handle app's settings (such facebook tokens etc.) gem parses config/application.yml file , provides easy access content.
i've used configuration file enable or disable i18n support entire app, app more of core app many child apps.
and in routes.rb things :
if settings.i18n.enabled match ':this', :to => 'that#place' end
or in models :
if settings.i18n.enabled scope :for_current_locale, lambda { where(:locale => i18n.locale) } end
i'd test how app responds both states : when i18n turned off , when turned on.
my problem state read configuration file when rails initializes. when run tests run tests related i18n.enabled being false, change configuration file , run tests related i18n.enabled being true.
is there way reinitialize app between 2 tests ? (i'm using rspec) or should automate way of running 2 separate tests files both i18n cases ? or maybe there better way ?
thanks !
edit
as routes issue managed make specs pass changing settings , reloading routes explicitly :
before(:all) settings.i18n["enabled"] = true my::application.reload_routes! end
but still feel not ideal, , things defined in models ? can reload models before running specs ? won't duplicate stuff callbacks ?
i think simple can reconfigure application following, example in rspec before_all block in specific test file:
yourappname::application.configure config.i18n.enabled = true # or false end
and in after_all block can set configuration default one. think work.
Comments
Post a Comment