This file contains 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
# Don't know about better, but fewer lines: | |
def mock_controller | |
['test_request','test_response'].each {|fname| require "action_dispatch/testing/#{fname}" } | |
controller = ApplicationController.new | |
controller.perform_caching = true | |
controller.cache_store = ActiveSupport::Cache::MemoryStore.new | |
['request','response'].each {|r| controller.send("#{r}=", ActionDispatch.const_get("Test#{r.capitalize}").new) } | |
controller.initialize_template_class controller.response | |
controller.assign_shortcuts controller.request, controller.response |
This file contains 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
class Router | |
@@routes = {} | |
@name | |
attr_accessor :name | |
def Router.register ( name) | |
@@routes[name] = self | |
name | |
end | |
def Router.factory (klass_name) | |
created_route = @@routes[klass_name] || nil |
This file contains 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
module ProofTest | |
class Model | |
def self.attr_reader property | |
define_method property do | |
puts "reading #{attributes[property]} from #{property}" | |
attributes[property] | |
end | |
end | |
def self.attr_writer property |
This file contains 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
jQuery -> | |
count = 0 | |
$("a").click (e) -> | |
e.preventDefault() | |
alert("Hello World #{++count}") |