Skip to content

Instantly share code, notes, and snippets.

@jbodah
jbodah / bypass_rails_routing.rb
Created August 6, 2014 18:10
Bypassing Rails routing
should 'support custom read only mode handler methods' do
controller = CustomReadOnlyHandlerTestController.new
controller.params = HashWithIndifferentAccess.new
controller.request = ActionController::TestRequest.new
controller.response = ActionController::TestResponse.new
controller.expects(:my_read_only_handler).at_least_once
controller.process :foo
end
@jbodah
jbodah / rails_file_diff.rb
Last active August 29, 2015 14:04
One-liner to get a diff between two strings and write it to a file
require 'diffy'; File.open(Rails.root.join('diff'), 'w') {|f| f.write Diffy::Diff.new event_json, expected_json}