Permalink
Browse files

tests are passing! This new testing paradigm is starting to almost wo…

…rk. Still having issues getting `assert_no_select` to work.
  • Loading branch information...
1 parent 5c72313 commit edacfc679762a563516db004d84edbeec389d4d5 @chadoh chadoh committed Apr 18, 2012
Showing with 16 additions and 15 deletions.
  1. +10 −15 test/lib/rails3-jquery-autocomplete/simple_form_plugin_test.rb
  2. +6 −0 test/view_test_helper.rb
@@ -4,21 +4,16 @@
module Rails3JQueryAutocomplete
class SimpleFormPluginTest < ActionView::TestCase
- context '#autocomplete_field' do
- should "not include :update_options if not specifically set" do
- with_concat_form_for(@user) do |f|
- f.input :name, url: '/test', as: :autocomplete
- end
- assert_tag "input", attributes: {
- :id => 'user_name',
- :name => "user[name]",
- :size => '30',
- :type => 'text',
- :value => @user.name,
- 'data-autocomplete' => '/test',
- :class => 'autocomplete optional'
- }
- end
+ def setup
+ with_input_for @user, :name, :autocomplete, :url => '/test'
+ end
+
+ should "apply a class of 'autocomplete'" do
+ assert_select "input#user_name.autocomplete[type=text][name='user[name]']"
+ end
+
+ should "add a data-autocomplete attribute with the provided :url" do
+ assert_select "input#user_name[data-autocomplete=/test]"
end
end
View
@@ -70,6 +70,12 @@ def with_concat_form_for(*args, &block)
concat simple_form_for(*args, &block)
end
+ def with_input_for(object, attribute_name, type, options={})
+ with_concat_form_for(object) do |f|
+ f.input(attribute_name, options.merge(:as => type))
+ end
+ end
+
def set_controller
@controller = MockController.new
end

0 comments on commit edacfc6

Please sign in to comment.