Skip to content

Instantly share code, notes, and snippets.

require "rubygems"
require "dm-core"
DataMapper.setup(:default, "sqlite3::memory:")
class Category
include DataMapper::Resource
property :id, Serial
has n, :items
@wycats
wycats / CHANGELOG
Created August 8, 2008 22:30
undefined
== 0.9.3 "We Sold Our Soul for Rock 'n' Roll" 2008-05-03
* Added render(template_path) feature to view specs.
* add mutex around compiled statement generation in the router so reloading doesn't step
* BootLoader::LoadClasses now logs the actual exceptions
* Added String#unescape_regexp for usage in Router::Route#generate
* Added Time#to_json to Core Extensions so JSON formatted output for Time is ISO 8601 compatible
* redo stream_file to (hopefully) work
* _dispatch returns @body
* Refactored Merb::AbstractController.layout class method
* Fixed lurking infinite loop with not so common formats and ExceptionController
class Foo
private
def bar
"Hey"
end
protected
def baz
"HeyHey"
end
def requirable?(filename)
result = fork do
begin
require filename
exit!(0)
rescue
exit!(1)
end
end
result == 0 ? true : false
>> module DataMapper; class Collection; alias_method :create_or_error, :create; end; end
=> DataMapper::Collection
>> Customer.first.environments.create_or_error
=> #<Environment created_at=nil updated_at=nil id=nil number=nil classification=nil description=nil cluster_id=nil customer_id=1>
def check_box(method_or_attrs = {}, attrs = {})
unless method_or_attrs.is_a?(Hash)
method = method_or_attrs
name = control_name(method)
update_control_fields(method, attrs, "checkbox")
check_box({:name => name}.merge(attrs))
else
attrs = method_or_attrs
end
update_fields(attrs, "checkbox")
def dispatch_action(klass, action, status = 200)
controller = klass.new(self, status)
- if Dispatcher.use_mutex then
+ if nil then
@@mutex.synchronize { controller._dispatch(action) }
else
controller._dispatch(action)
end
controller
end
Thread.current[:rake_namespace] = ""
require "set"
class RakeTask
TASKS = Hash.new {|h,k| h[k] = {:blocks => [], :deps => []}}
CALLED_TASKS = Set.new
def self.call(task_name)
return if CALLED_TASKS.include?(task_name.to_sym)
CALLED_TASKS << task_name.to_s
task = TASKS[task_name.to_s]
require 'rubygems'
require 'benchmark'
require 'drb'
module Spec
module Runner
module Formatters
class BaseTextFormatter
def dump_failure(counter, failure)
output = @options.error_stream
1)
'Merb::Request query and body params should support XML params' FAILED
expected: {"foo"=>{"baz"=>nil, "bar"=>"baz"}},
got: {} (using ==)
./spec/public/request/request_spec.rb:94:
./bin/../lib/merb-core/test/run_specs.rb:104:in `run_specs'
./bin/../lib/merb-core/test/run_specs.rb:95:in `fork'
./bin/../lib/merb-core/test/run_specs.rb:95:in `run_specs'
./bin/../lib/merb-core/test/run_specs.rb:93:in `each'
./bin/../lib/merb-core/test/run_specs.rb:93:in `run_specs'