aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-10-03 23:31:38 -0500
committerJoshua Peek <josh@joshpeek.com>2009-10-03 23:31:38 -0500
commit86ed58d9121844e2d881be67e2d845ae721f72e7 (patch)
treeea670adc7da8b04d21d8a644db2ce619ea771dbe /actionpack/test/template
parent61411f2aeb29edba2d8cd2008020044799ea3d61 (diff)
downloadrails-86ed58d9121844e2d881be67e2d845ae721f72e7.tar.gz
rails-86ed58d9121844e2d881be67e2d845ae721f72e7.tar.bz2
rails-86ed58d9121844e2d881be67e2d845ae721f72e7.zip
Use with_routing helper in tests instead of modifying global route set
Diffstat (limited to 'actionpack/test/template')
-rw-r--r--actionpack/test/template/test_test.rb37
1 files changed, 23 insertions, 14 deletions
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 "<h1>Ruby on Rails</h1>", 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 '<a href="/people/1">David</a>', 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 '<a href="/people/1">David</a>', 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