Sha256: d887bf2cccea41950691da04163bc85281f225dc02f72adc71c3b7e4dfcb0527

Contents?: true

Size: 1.17 KB

Versions: 15

Compression:

Stored size: 1.17 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

  uses_mocha "link_to_person" do
    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
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

15 entries across 14 versions & 6 rubygems

Version Path
radiant-0.7.2 vendor/rails/actionpack/test/template/test_test.rb
vibes-bj-1.2.2 spec/rails_root/vendor/rails/actionpack/test/template/test_test.rb
vibes-bj-1.2.1 spec/rails_root/vendor/rails/actionpack/test/template/test_test.rb
usher-0.7.0 spec/rails2_2/vendor/rails/vendor/rails/actionpack/pkg/actionpack-2.2.2/test/template/test_test.rb
usher-0.7.0 spec/rails2_2/vendor/rails/vendor/rails/actionpack/test/template/test_test.rb
actionpack-2.2.3 test/template/test_test.rb
actionpack-2.1.2 test/template/test_test.rb
actionpack-2.1.0 test/template/test_test.rb
actionpack-2.1.1 test/template/test_test.rb
actionpack-2.2.2 test/template/test_test.rb
antfarm-0.3.0 rails/vendor/rails/actionpack/test/template/test_test.rb
antfarm-0.4.0 rails/vendor/rails/actionpack/test/template/test_test.rb
eactionpack-2.1.2 test/template/test_test.rb
radiant-0.7.0 vendor/rails/actionpack/test/template/test_test.rb
radiant-0.7.1 vendor/rails/actionpack/test/template/test_test.rb