Skip to content

Commit edacfc6

Browse files
committed
tests are passing! This new testing paradigm is starting to almost work. Still having issues getting assert_no_select to work.
1 parent 5c72313 commit edacfc6

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

test/lib/rails3-jquery-autocomplete/simple_form_plugin_test.rb

+10-15
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,16 @@
44
module Rails3JQueryAutocomplete
55
class SimpleFormPluginTest < ActionView::TestCase
66

7-
context '#autocomplete_field' do
8-
should "not include :update_options if not specifically set" do
9-
with_concat_form_for(@user) do |f|
10-
f.input :name, url: '/test', as: :autocomplete
11-
end
12-
assert_tag "input", attributes: {
13-
:id => 'user_name',
14-
:name => "user[name]",
15-
:size => '30',
16-
:type => 'text',
17-
:value => @user.name,
18-
'data-autocomplete' => '/test',
19-
:class => 'autocomplete optional'
20-
}
21-
end
7+
def setup
8+
with_input_for @user, :name, :autocomplete, :url => '/test'
9+
end
10+
11+
should "apply a class of 'autocomplete'" do
12+
assert_select "input#user_name.autocomplete[type=text][name='user[name]']"
13+
end
14+
15+
should "add a data-autocomplete attribute with the provided :url" do
16+
assert_select "input#user_name[data-autocomplete=/test]"
2217
end
2318

2419
end

test/view_test_helper.rb

+6
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ def with_concat_form_for(*args, &block)
7070
concat simple_form_for(*args, &block)
7171
end
7272

73+
def with_input_for(object, attribute_name, type, options={})
74+
with_concat_form_for(object) do |f|
75+
f.input(attribute_name, options.merge(:as => type))
76+
end
77+
end
78+
7379
def set_controller
7480
@controller = MockController.new
7581
end

0 commit comments

Comments
 (0)