Skip to content

Instantly share code, notes, and snippets.

View Talha5's full-sized avatar
🏠
Working from home

Talha Meh Talha5

🏠
Working from home
View GitHub Profile
@kinopyo
kinopyo / custom_logger.rb
Created October 11, 2011 15:40
Custom logger file in Rails
# lib/custom_logger.rb
class CustomLogger < Logger
def format_message(severity, timestamp, progname, msg)
"#{timestamp.to_formatted_s(:db)} #{severity} #{msg}\n"
end
end
logfile = File.open("#{Rails.root}/log/custom.log", 'a') # create log file
logfile.sync = true # automatically flushes data to file
CUSTOM_LOGGER = CustomLogger.new(logfile) # constant accessible anywhere
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
# This works with steak 0.3.x and rspec 1.x
# For steak --pre and rspec 2 see this fork: http://gist.github.com/448487
# Put this code in acceptance_helper.rb or better in a new file spec/acceptance/support/javascript.rb
Spec::Runner.configure do |config|
config.before(:each) do
Capybara.current_driver = :selenium if options[:js]
end