Skip to content

Instantly share code, notes, and snippets.

View jasoncharnes's full-sized avatar
🎉
Here to party

Jason Charnes jasoncharnes

🎉
Here to party
View GitHub Profile
@palkan
palkan / factory_doctor.rb
Created March 27, 2017 15:42
FactoryDoc: detect useless data generation in tests
module FactoryGirl
module Doctor
module FloatDuration
refine Float do
def duration
t = self
format("%02d:%02d.%03d", t / 60, t % 60, t.modulo(1) * 1000)
end
end
end
@kmamykin
kmamykin / tasks.rake
Created June 28, 2011 08:26
How to render Rails 3 view in a rake task
task :renderview => :environment do
app = YourApp::Application
app.routes.default_url_options = { :host => 'xxx.com' }
controller = YourController.new
view = ActionView::Base.new(app.config.paths.app.views.first, {}, controller)
view.class_eval do
include ApplicationHelper
include app.routes.url_helpers
end
puts view.render(:template => 'your/action')