From 86ed58d9121844e2d881be67e2d845ae721f72e7 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sat, 3 Oct 2009 23:31:38 -0500 Subject: Use with_routing helper in tests instead of modifying global route set --- actionpack/test/template/test_test.rb | 37 ++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/test_test.rb b/actionpack/test/template/test_test.rb index f32d0b3d42..05a14f3554 100644 --- a/actionpack/test/template/test_test.rb +++ b/actionpack/test/template/test_test.rb @@ -19,32 +19,41 @@ module PeopleHelper end class PeopleHelperTest < ActionView::TestCase - def setup - super - 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 "

Ruby on Rails

", title("Ruby on Rails") end def test_homepage_path - assert_equal "/people", homepage_path + with_test_route_set do + assert_equal "/people", homepage_path + end end def test_homepage_url - assert_equal "http://test.host/people", homepage_url + with_test_route_set do + assert_equal "http://test.host/people", homepage_url + end end def test_link_to_person - person = mock(:name => "David") - person.class.extend ActiveModel::Naming - expects(:mocha_mock_path).with(person).returns("/people/1") - assert_equal 'David', link_to_person(person) + with_test_route_set do + person = mock(:name => "David") + person.class.extend ActiveModel::Naming + expects(:mocha_mock_path).with(person).returns("/people/1") + assert_equal 'David', link_to_person(person) + end end + + private + def with_test_route_set + with_routing do |set| + set.draw do |map| + map.people 'people', :controller => 'people', :action => 'index' + map.connect ':controller/:action/:id' + end + yield + end + end end class CrazyHelperTest < ActionView::TestCase -- cgit v1.2.3