require File.dirname(__FILE__) + "/../../../spec_helper.rb" describe RightRails::Helpers::Forms do include ActionView::Helpers::TagHelper include ActionView::Helpers::FormTagHelper include ActionView::Helpers::JavaScriptHelper include RightRails::Helpers::Basic include RightRails::Helpers::Forms def url_for(options) options end def escape_javascript(str) str end def rightjs_required_files RightRails::Helpers.required_js_files(self) end before :each do RightRails::Config.reset! end describe ".calendar_field" do it "should generate a basic calendar_field_tag" do calendar_field_tag('name', 'value').should == %Q{} rightjs_required_files.should include('right/calendar') end it "should generate a calendar_field_tag with options" do calendar_field_tag('name', 'value', :format => '%Y/%m/%d').should == %Q{} end it "should generate a basic calendar_field" do calendar_field('model', 'method').should == %Q{} end it "should generate a calendar_field with options" do calendar_field('model', 'method', :hide_on_pick => true).should == %Q{} end describe "in RightJS 1 mode" do before :each do RightRails::Config.rightjs_version = 1 end it "should generate a basic calendar_field_tag" do calendar_field_tag('name', 'value').should == %Q{} rightjs_required_files.should include('right/calendar') end it "should generate a calendar_field_tag with options" do calendar_field_tag('name', 'value', :format => '%Y/%m/%d').should == %Q{} end it "should generate a basic calendar_field" do calendar_field('model', 'method').should == %Q{} end it "should generate a calendar_field with options" do calendar_field('model', 'method', :hide_on_pick => true).should == %Q{} end end end describe ".autocomplete_field" do it "should generate a basic autocomplete_field_tag" do autocomplete_field_tag('name', 'value', :url => '/foo').should == %Q{} rightjs_required_files.should include('right/autocompleter') end it "should generate an autocomplete_field_tag with options" do autocomplete_field_tag('name', 'value', :url => '/foo', :spinner => 'spinner', :min_length => 2).should == %Q{} end it "should generate a basic autocomplete_field" do autocomplete_field('object', 'method', :url => '/foo').should == %Q{} end it "should generate an autocomplete_field with options" do autocomplete_field('object', 'method', :url => '/foo', :fx_name => 'fade').should == %Q{} end describe "in RightJS 1 mode" do before :each do RightRails::Config.rightjs_version = 1 end it "should generate a basic autocomplete_field_tag" do autocomplete_field_tag('name', 'value', :url => '/foo').should == %Q{} rightjs_required_files.should include('right/autocompleter') end it "should generate an autocomplete_field_tag with options" do autocomplete_field_tag('name', 'value', :url => '/foo', :spinner => 'spinner', :min_length => 2).should == %Q{} end it "should generate a basic autocomplete_field" do autocomplete_field('object', 'method', :url => '/foo').should == %Q{} end it "should generate an autocomplete_field with options" do autocomplete_field('object', 'method', :url => '/foo', :fx_name => 'fade').should == %Q{} end end end describe ".slider" do it "should generate a basic slider_tag" do slider_tag('some_field', 22).should == %Q{\n}+ %Q{} end it "should generate a slider_tag with options" do slider_tag('some_field', 22, :min => 10, :max => 40).should == %Q{\n}+ %Q{} end it "should generate a slider with options" do model = {} model.should_receive('method').twice.and_return(22) should_receive(:instance_variable_get).twice.with('@object').and_return(model) slider('object', 'method', :value => 22, :min => 20, :max => 80).should == %Q{\n}+ %Q{} end end describe ".rater" do it "should generate a simple rater" do model = {} model.should_receive('method').twice.and_return(2) should_receive(:instance_variable_get).twice.with('@object').and_return(model) rater('object', 'method', :value => 2).should == %Q{\n}+ %Q{} end it "should generate a #rater_tag" do rater_tag('some_field', 2).should == %Q{\n}+ %Q{} end it "should generate the #rater_display tag" do rater_display(4).should == %Q{