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

Version Path
hobo-2.2.6 test/doctest/hobo/hobo_helper.rdoctest
hobo-2.2.5 test/doctest/hobo/hobo_helper.rdoctest
hobo-2.2.4 test/doctest/hobo/hobo_helper.rdoctest
hobo-2.2.3 test/doctest/hobo/hobo_helper.rdoctest
hobo-2.2.2 test/doctest/hobo/hobo_helper.rdoctest
hobo-2.2.1 test/doctest/hobo/hobo_helper.rdoctest
hobo-2.2.0 test/doctest/hobo/hobo_helper.rdoctest
hobo-2.1.2 test/doctest/hobo/hobo_helper.rdoctest
hobo-2.1.1 test/doctest/hobo/hobo_helper.rdoctest
hobo-2.1.0 test/doctest/hobo/hobo_helper.rdoctest
hobo-2.1.0.pre4 test/doctest/hobo/hobo_helper.rdoctest
hobo-2.1.0.pre3 test/doctest/hobo/hobo_helper.rdoctest
hobo-2.1.0.pre2 test/doctest/hobo/hobo_helper.rdoctest
hobo-2.1.0.pre1 test/doctest/hobo/hobo_helper.rdoctest
hobo-2.0.1 test/doctest/hobo/hobo_helper.rdoctest
hobo-2.0.0 test/doctest/hobo/hobo_helper.rdoctest
hobo-2.0.0.pre10 test/doctest/hobo/hobo_helper.rdoctest
hobo-2.0.0.pre9 test/doctest/hobo/hobo_helper.rdoctest
hobo-2.0.0.pre8 test/doctest/hobo/hobo_helper.rdoctest
hobo-2.0.0.pre7 test/doctest/hobo/hobo_helper.rdoctest