Skip to content

Instantly share code, notes, and snippets.

@jacobo
Last active August 29, 2015 14:01
Show Gist options
  • Save jacobo/e69718ef920861f7cfc7 to your computer and use it in GitHub Desktop.
Save jacobo/e69718ef920861f7cfc7 to your computer and use it in GitHub Desktop.
ReloadHax
# 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