Sha256: 12370a9efcf789afcbfdfa3fbb6a7386b49774faedaf06b633c657b8fbc04329
Contents?: true
Size: 1.69 KB
Versions: 26
Compression:
Stored size: 1.69 KB
Contents
doctest: prepare testapp environment doctest_require: '../prepare_testapp' doctest_require: 'mocha' # Hobo::Helper Create a mock view layer: >> class View extend HoboRouteHelper class << self protected_instance_methods.each {|m| public m } def params; {} ;end def subsite; "" ;end def base_url; "" ;end end end Useful stuff >> def init_mocha; $stubba = Mocha::Central.new; end >> def mock; Mocha::Mockery.instance.named_mock 'mock'; end # object_url now uses polymorphic_url, so this is completely out of date. FIXME # ## `object_url` # Returns a canonical restful URL for a given object. THe Hobo routing is checked and URLs are only returned for routes that exist. # Note that `object_url` doesn't perform "reverse routing". It knows nothing about attractive URLs you may have declared in your routes file. # Something to link to: # >> init_mocha # >> class Thing; end # >> thing = Thing.new # >> thing.expects(:to_url_path).at_least_once.returns("things/1") # ### Simple 'show' URLs # >> Hobo::Routes.expects(:linkable?).with(Thing, :show, {:subsite => ''}).returns(true) # >> View.object_url(thing) # => "/things/1" # Returns nil if Routes says it's not linkable # >> Hobo::Routes.expects(:linkable?).with(Thing, :show, {:subsite => ''}).returns(false) # >> View.object_url(thing) # => nil # A URL to the 'edit' page: # >> Hobo::Routes.expects(:linkable?).with(Thing, :edit, {:subsite => ''}).returns(true) # >> View.object_url(thing, :edit) # => "/things/1/edit"
Version data entries
26 entries across 26 versions & 1 rubygems