Last active
August 29, 2015 14:01
-
-
Save jacobo/e69718ef920861f7cfc7 to your computer and use it in GitHub Desktop.
ReloadHax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Put this anywhere in your specfile: | |
class ReloadHax | |
def self.setup(*files_to_reload, &go_block) | |
@files_to_reload, @go_block = files_to_reload, go_block | |
end | |
def self.go | |
ApplicationController.asset_host = "http://billing.localdev.engineyard.com:3000" | |
ActionView::Resolver.caching = false | |
@files_to_reload.each{|x| load(File.join(Rails.root,x))} | |
@go_block.call | |
rescue => e | |
puts e.inspect | |
puts RSpec::Core::BacktraceFormatter.format_backtrace(e.backtrace) | |
raise e | |
end | |
end | |
def go | |
ReloadHax.go | |
end | |
# Call this from the "slow" spec you are iterating on in the place where you make assertions | |
ReloadHax.setup("app/controllers/invoices_controller.rb") do | |
visit pending_account_invoices_url(@account) | |
end | |
binding.pry | |
# go | |
# Make changes to invoices_controller.rb or your views, and then run in your pry console run go | |
go | |
# If you want to assert on somehting different or reload different files, just paste the new version of your ReloadHax directly into pry | |
ReloadHax.setup("app/controllers/invoices_controller.rb") do | |
visit pending_account_invoices_url(@account) | |
expect(page.status_code).to eq 200 | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment