require File.dirname(__FILE__) + '/../abstract_unit' module BaseTest include ActionView::Helpers::JavaScriptHelper include ActionView::Helpers::PrototypeHelper include ActionView::Helpers::ScriptaculousHelper include ActionView::Helpers::UrlHelper include ActionView::Helpers::TagHelper include ActionView::Helpers::TextHelper include ActionView::Helpers::FormTagHelper include ActionView::Helpers::FormHelper include ActionView::Helpers::CaptureHelper def setup @template = nil @controller = Class.new do def url_for(options, *parameters_for_method_reference) if options.is_a?(String) options else url = "http://www.example.com/" url << options[:action].to_s if options and options[:action] url << "?a=#{options[:a]}" if options && options[:a] url << "&b=#{options[:b]}" if options && options[:a] && options[:b] url end end end.new end protected def create_generator block = Proc.new { |*args| yield *args if block_given? } JavaScriptGenerator.new self, &block end end class PrototypeHelperTest < Test::Unit::TestCase include BaseTest def test_link_to_remote assert_dom_equal %(Remote outpost), link_to_remote("Remote outpost", { :url => { :action => "whatnot" }}, { :class => "fine" }) assert_dom_equal %(Remote outpost), link_to_remote("Remote outpost", :complete => "alert(request.reponseText)", :url => { :action => "whatnot" }) assert_dom_equal %(Remote outpost), link_to_remote("Remote outpost", :success => "alert(request.reponseText)", :url => { :action => "whatnot" }) assert_dom_equal %(Remote outpost), link_to_remote("Remote outpost", :failure => "alert(request.reponseText)", :url => { :action => "whatnot" }) assert_dom_equal %(Remote outpost), link_to_remote("Remote outpost", :failure => "alert(request.reponseText)", :url => { :action => "whatnot", :a => '10', :b => '20' }) end def test_periodically_call_remote assert_dom_equal %(), periodically_call_remote(:update => "schremser_bier", :url => { :action => "mehr_bier" }) end def test_form_remote_tag assert_dom_equal %(
), _erbout end def test_on_callbacks callbacks = [:uninitialized, :loading, :loaded, :interactive, :complete, :success, :failure] callbacks.each do |callback| assert_dom_equal %(