Skip to content

Instantly share code, notes, and snippets.

@joshuaclayton
Created August 12, 2009 17:45
Show Gist options
  • Save joshuaclayton/166634 to your computer and use it in GitHub Desktop.
Save joshuaclayton/166634 to your computer and use it in GitHub Desktop.
module Admin::CustomerHelper
def customer_breadcrumbs(customer)
link_to(h(customer.name), [:edit, :admin, customer]) + " » "
end
end
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( &#187; ), customer_breadcrumbs(@customer)
end
end
end
# 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