mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Safely cleans up a test to avoid relying on a particular test order
This commit is contained in:
parent
70916f6a9c
commit
7c785592ec
1 changed files with 24 additions and 11 deletions
|
@ -89,6 +89,9 @@ module ActionView
|
||||||
end
|
end
|
||||||
|
|
||||||
test "helper class that is being tested is always included in view instance" do
|
test "helper class that is being tested is always included in view instance" do
|
||||||
|
# This ensure is a hidious hack to deal with these tests bleeding
|
||||||
|
# methods between eachother
|
||||||
|
begin
|
||||||
self.class.helper_class.module_eval do
|
self.class.helper_class.module_eval do
|
||||||
def render_from_helper
|
def render_from_helper
|
||||||
render :partial => 'customer', :collection => @customers
|
render :partial => 'customer', :collection => @customers
|
||||||
|
@ -99,6 +102,10 @@ module ActionView
|
||||||
|
|
||||||
@customers = [stub(:name => 'Eloy'), stub(:name => 'Manfred')]
|
@customers = [stub(:name => 'Eloy'), stub(:name => 'Manfred')]
|
||||||
assert_match /Hello: EloyHello: Manfred/, render(:partial => 'test/from_helper')
|
assert_match /Hello: EloyHello: Manfred/, render(:partial => 'test/from_helper')
|
||||||
|
|
||||||
|
ensure
|
||||||
|
self.class.helper_class.remove_method :render_from_helper
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "no additional helpers should shared across test cases" do
|
test "no additional helpers should shared across test cases" do
|
||||||
|
@ -147,10 +154,16 @@ module ActionView
|
||||||
end
|
end
|
||||||
|
|
||||||
test "is able to make methods available to the view" do
|
test "is able to make methods available to the view" do
|
||||||
|
# This ensure is a hidious hack to deal with these tests bleeding
|
||||||
|
# methods between eachother
|
||||||
|
begin
|
||||||
_helpers.module_eval do
|
_helpers.module_eval do
|
||||||
def render_from_helper; from_test_case end
|
def render_from_helper; from_test_case end
|
||||||
end
|
end
|
||||||
assert_equal 'Word!', render(:partial => 'test/from_helper')
|
assert_equal 'Word!', render(:partial => 'test/from_helper')
|
||||||
|
ensure
|
||||||
|
_helpers.remove_method :render_from_helper
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def from_test_case; 'Word!'; end
|
def from_test_case; 'Word!'; end
|
||||||
|
|
Loading…
Reference in a new issue