Sha256: 9c3aee6ca7a2335ac8b32aeaebecd60d281fd76060711b7a64be88e5b5acc3ea
Contents?: true
Size: 1.54 KB
Versions: 7
Compression:
Stored size: 1.54 KB
Contents
doctest: prepare testapp environment doctest_require: '../prepare_testapp' # 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` 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
7 entries across 7 versions & 1 rubygems