Sha256: 5f24b7b01d73c0dd4a609ad0c5eb4013d4a579dc16406e1827b65bf13f681832

Contents?: true

Size: 1.3 KB

Versions: 9

Compression:

Stored size: 1.3 KB

Contents

require 'test_helper'
require 'view_test_helper'

module Rails3JQueryAutocomplete
  class SimpleFormPluginTest < ActionView::TestCase

    should "apply a class of 'autocomplete'" do
      with_input_for @user, :name, :autocomplete
      assert_select "input#user_name.autocomplete[type=text][name='user[name]']"
    end

    should "add a data-autocomplete attribute with the provided :url" do
      with_input_for @user, :name, :autocomplete, :url => '/test'
      assert_select "input#user_name[data-autocomplete=/test]"
    end

    should "add a data-update-elements attribute with encoded data if passed an :update_elements option" do
      with_input_for @user, :name, :autocomplete, :update_elements => { :id => '#this', :ego => '#that' }
      assert_select "input#user_name[data-update-elements='{&quot;id&quot;:&quot;#this&quot;,&quot;ego&quot;:&quot;#that&quot;}']"
    end

    should "not add a data-update-elements attribute if not passed an :update_elements option" do
      with_input_for @user, :name, :autocomplete, :url => '/test'
      assert_no_select "input#user_name[data-update-elements]"
    end

    should "add arbitrary html options, if specified" do
      with_input_for @user, :name, :autocomplete, :input_html => { :class => "superego" }
      assert_select "input#user_name.superego"
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rails3-jquery-autocomplete-1.0.15 test/lib/rails3-jquery-autocomplete/simple_form_plugin_test.rb
rails3-jquery-autocomplete-1.0.14 test/lib/rails3-jquery-autocomplete/simple_form_plugin_test.rb
rails3-jquery-autocomplete-1.0.13 test/lib/rails3-jquery-autocomplete/simple_form_plugin_test.rb
rails3-jquery-autocomplete-1.0.12 test/lib/rails3-jquery-autocomplete/simple_form_plugin_test.rb
rails3-jquery-autocomplete-1.0.11 test/lib/rails3-jquery-autocomplete/simple_form_plugin_test.rb
rails3-jquery-autocomplete-1.0.10 test/lib/rails3-jquery-autocomplete/simple_form_plugin_test.rb
rails3-jquery-autocomplete-1.0.9 test/lib/rails3-jquery-autocomplete/simple_form_plugin_test.rb
rails3-jquery-autocomplete-1.0.8 test/lib/rails3-jquery-autocomplete/simple_form_plugin_test.rb
rails3-jquery-autocomplete-1.0.7 test/lib/rails3-jquery-autocomplete/simple_form_plugin_test.rb