Notes posted by lukaszsliwa
RSS feed
0 thanks
Locale
To change default locale by the parameter you can set :locale option, like below:
select_date 'user', 'birth', :locale => 'de'

0 thanks
Stubs Logger in rspec
Let we have a module like below:
module MyModule class << self def logger @logger ||= Logger.new(File.join(Rails.root, "log", "my_gem_#{Rails.env}.log")) end end end
To use this logger just type:
MyModule.logger.info "This is a log line"
To stub in tests use (for rspec):
require 'active_support/log_subscriber/test_helper' RSpec.configure do |config| config.include ActiveSupport::LogSubscriber::TestHelper config.before do MyModule.stub!(:logger).and_return(MockLogger.new) end end
Usefull in testing when you don’t like to log anything.