I have the following library code: def normal_time_now return DateTime.now.utc if default_timezone == :utc return DateTime.now end
This is dependent upon a setting in config/environment.rb # Make Active Record use UTC-base instead of local time config.active_record.default_timezone = :utc I want to test that I get the expected results with the config set to utc and otherwise. The library code is used to automatically set a model attribute on create. My existing specification looks somewhat like this: describe "Builds a Model with custom magic columns" do before(:all) do build_model :magiks do string :description # these are Rails' own magic columns ... # these are our custom magic columns ... end @my_mage = Magik.new @my_mage.save! end it "should set each custom magic column present" do (Magik.column_names & ActiveRecord::Base::HLL_AUDIT_COLUMNS).each do |magic_column| @my_mage.read_attribute(magic_column).should_not be_nil end end I can simply create duplicate separate specification file and set the configuration value appropriately in each. Something along the lines of: describe "Builds a Model with custom magic columns" do before(:all) do config.active_record.default_timezone = nil or config.active_record.default_timezone = :utc But this strikes me as inappropriate. I believe that this test belongs inside the basic specification file but I cannot conceive of how to do this. Basically, I require some form of variable setup routine. Does anyone have any suggestions on how to handle this case? Regards, -- Posted via http://www.ruby-forum.com/. _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users