From adcc5e11fe5edd2883b6ec4d08ab72180a973155 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 28 Sep 2010 15:29:40 -0300 Subject: @selected may not be defined here, avoid warning. --- actionpack/lib/action_dispatch/testing/assertions/selector.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_dispatch/testing/assertions/selector.rb') diff --git a/actionpack/lib/action_dispatch/testing/assertions/selector.rb b/actionpack/lib/action_dispatch/testing/assertions/selector.rb index 353be10d20..9ae4f65db9 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/selector.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/selector.rb @@ -197,7 +197,7 @@ module ActionDispatch # This usually happens when passing a node/element that # happens to be nil. raise ArgumentError, "First argument is either selector or element to select, but nil found. Perhaps you called assert_select with an element that does not exist?" - elsif @selected + elsif defined?(@selected) && @selected root = HTML::Node.new(nil) root.children.concat @selected else -- cgit v1.2.3 From 059d609a1a59300faefdc2d4186bae13b30c9699 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 28 Sep 2010 15:46:30 -0300 Subject: Avoid more uninitialized variable warnings. --- actionpack/lib/action_dispatch/testing/assertions/selector.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_dispatch/testing/assertions/selector.rb') diff --git a/actionpack/lib/action_dispatch/testing/assertions/selector.rb b/actionpack/lib/action_dispatch/testing/assertions/selector.rb index 9ae4f65db9..f5ecb9a199 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/selector.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/selector.rb @@ -187,6 +187,7 @@ module ActionDispatch def assert_select(*args, &block) # Start with optional element followed by mandatory selector. arg = args.shift + @selected ||= nil if arg.is_a?(HTML::Node) # First argument is a node (tag or text, but also HTML root), @@ -197,7 +198,7 @@ module ActionDispatch # This usually happens when passing a node/element that # happens to be nil. raise ArgumentError, "First argument is either selector or element to select, but nil found. Perhaps you called assert_select with an element that does not exist?" - elsif defined?(@selected) && @selected + elsif @selected root = HTML::Node.new(nil) root.children.concat @selected else -- cgit v1.2.3 From 523f98099d331908db6ab4c45f7657e61a8a4d5f Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 28 Sep 2010 18:01:48 -0300 Subject: Remove more warnings on AP. --- actionpack/lib/action_dispatch/testing/assertions/selector.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_dispatch/testing/assertions/selector.rb') diff --git a/actionpack/lib/action_dispatch/testing/assertions/selector.rb b/actionpack/lib/action_dispatch/testing/assertions/selector.rb index f5ecb9a199..2b862fb7d6 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/selector.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/selector.rb @@ -67,7 +67,7 @@ module ActionDispatch arg = args.shift elsif arg == nil raise ArgumentError, "First argument is either selector or element to select, but nil found. Perhaps you called assert_select with an element that does not exist?" - elsif @selected + elsif defined?(@selected) && @selected matches = [] @selected.each do |selected| @@ -443,6 +443,7 @@ module ActionDispatch assert_block("") { true } # to count the assertion if block_given? && !([:remove, :show, :hide, :toggle].include? rjs_type) begin + @selected ||= nil in_scope, @selected = @selected, matches yield matches ensure -- cgit v1.2.3