Sha256: 4db61ea01563b4f4c32462c584d620f2f744056de7f5e3176884c21586a745e8

Contents?: true

Size: 1.12 KB

Versions: 78

Compression:

Stored size: 1.12 KB

Contents

require 'abstract_unit'

module PeopleHelper
  def title(text)
    content_tag(:h1, text)
  end

  def homepage_path
    people_path
  end

  def homepage_url
    people_url
  end

  def link_to_person(person)
    link_to person.name, person
  end
end

class PeopleHelperTest < ActionView::TestCase
  def setup
    ActionController::Routing::Routes.draw do |map|
      map.people 'people', :controller => 'people', :action => 'index'
      map.connect ':controller/:action/:id'
    end
  end

  def test_title
    assert_equal "<h1>Ruby on Rails</h1>", title("Ruby on Rails")
  end

  def test_homepage_path
    assert_equal "/people", homepage_path
  end

  def test_homepage_url
    assert_equal "http://test.host/people", homepage_url
  end

  def test_link_to_person
    person = mock(:name => "David")
    expects(:mocha_mock_path).with(person).returns("/people/1")
    assert_equal '<a href="/people/1">David</a>', link_to_person(person)
  end
end

class CrazyHelperTest < ActionView::TestCase
  tests PeopleHelper

  def test_helper_class_can_be_set_manually_not_just_inferred
    assert_equal PeopleHelper, self.class.helper_class
  end
end

Version data entries

78 entries across 77 versions & 18 rubygems

Version Path
elkinsware-erubis_rails_helper-0.6.0 test/template/test_test.rb
elkinsware-erubis_rails_helper-0.6.1 test/template/test_test.rb
elkinsware-erubis_rails_helper-0.9.0 test/template/test_test.rb
elkinsware-erubis_rails_helper-0.9.1 test/template/test_test.rb
elkinsware-erubis_rails_helper-0.9.5 test/template/test_test.rb
ghazel-erubis_rails_helper-0.9.5 test/template/test_test.rb
actionpack-2.3.18 test/template/test_test.rb
actionpack_csi-2.3.5.p8 test/template/test_test.rb
actionpack-2.3.17-rack-upgrade-2.3.17 test/template/test_test.rb
actionpack-2.3.17 test/template/test_test.rb
actionpack_csi-2.3.5.p7 test/template/test_test.rb
actionpack_csi-2.3.5.p6 test/template/test_test.rb
actionpack-2.3.16 test/template/test_test.rb
actionpack-rack-upgrade-2-2.3.16 test/template/test_test.rb
actionpack-rack-upgrade-2-2.3.15 test/template/test_test.rb
actionpack-2.3.15 test/template/test_test.rb
actionpack-rack-upgrade-2.3.16 test/template/test_test.rb
actionpack-rack-upgrade-2.3.15 test/template/test_test.rb
actionpack-rack-upgrade-2.3.14 test/template/test_test.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/actionpack-2.3.14/test/template/test_test.rb