Created
August 12, 2009 17:45
-
-
Save joshuaclayton/166634 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Admin::CustomerHelper | |
def customer_breadcrumbs(customer) | |
link_to(h(customer.name), [:edit, :admin, customer]) + " » " | |
end | |
end |
This file contains hidden or 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
require "test_helper" | |
class Admin::CustomerHelperTest < ActionView::TestCaseWithControllerAssertions | |
context "customer_breadcrumbs" do | |
setup { @customer = Factory(:customer) } | |
should "generate a link" do | |
with_content(customer_breadcrumbs(@customer)) do | |
assert_select "a[href=?]", edit_admin_customer_path(@customer), @customer.name | |
# yes, assertions other than assert_select work within this block | |
assert_tag :a, | |
:attributes => {:href => edit_admin_customer_path(@customer)}, | |
:content => @customer.name | |
end | |
end | |
should "include the proper separator" do | |
assert_match %r( » ), customer_breadcrumbs(@customer) | |
end | |
end | |
end |
This file contains hidden or 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
# etc. | |
class ActionView::TestCaseWithControllerAssertions < ActionView::TestCase | |
protected | |
def with_content(content, content_type = "html") | |
@response = stub_everything(:content_type => content_type, :body => content) | |
yield if block_given? | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment