Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test cases for select tag #1353

Merged
merged 2 commits into from Jul 17, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -20,6 +20,7 @@
<%= label_tag :color %>
<%= select_tag :color, :options => ['green', 'orange', 'purple'] %>
<%= select_tag :type, :grouped_options => { 'foo' => ['foo', 'bar'], 'bar' => ['foo', 'bar'] } %>
<%= select_tag :character, :grouped_options => [['Friends',['Yoda',['Obiwan',1]]],['Enemies',['Palpatine',['Darth Vader',3]]]] %>
<%= radio_button_tag :gender, :value => 'male' %>
<%= radio_button_tag :gender, :value => 'female' %>
<%= submit_tag %>
Expand Down
Expand Up @@ -19,6 +19,7 @@
= label_tag :color
= select_tag :color, :options => ['green', 'orange', 'purple']
= select_tag :type, :grouped_options => { 'foo' => ['foo', 'bar'], 'bar' => ['foo', 'bar'] }
= select_tag :character, :grouped_options => [['Friends',['Yoda',['Obiwan',1]]],['Enemies',['Palpatine',['Darth Vader',3]]]]
= label_tag :gender
= radio_button_tag :gender, :value => 'male'
= radio_button_tag :gender, :value => 'female'
Expand Down
Expand Up @@ -19,6 +19,7 @@
= label_tag :color
= select_tag :color, :options => ['green', 'orange', 'purple']
= select_tag :type, :grouped_options => { 'foo' => ['foo', 'bar'], 'bar' => ['foo', 'bar'] }
= select_tag :character, :grouped_options => [['Friends',['Yoda',['Obiwan',1]]],['Enemies',['Palpatine',['Darth Vader',3]]]]
= label_tag :gender
= radio_button_tag :gender, :value => 'male'
= radio_button_tag :gender, :value => 'female'
Expand Down
35 changes: 31 additions & 4 deletions padrino-helpers/test/test_form_helpers.rb
Expand Up @@ -10,7 +10,7 @@ def app

context 'for #form_tag method' do
after(:each) { app.set :protect_from_csrf, true }

should "display correct forms in ruby" do
actual_html = form_tag('/register', :"accept-charset" => "UTF-8", :class => 'test', :method => "post") { "Demo" }
assert_has_tag(:form, :"accept-charset" => "UTF-8", :class => "test") { actual_html }
Expand Down Expand Up @@ -782,11 +782,20 @@ def app
assert_have_selector('select option', :content => 'green', :value => 'green')
assert_have_selector('select option', :content => 'orange', :value => 'orange')
assert_have_selector('select option', :content => 'purple', :value => 'purple')
assert_have_selector 'form.advanced-form select', :name => 'fav_color'
assert_have_selector('form.advanced-form select', :name => 'fav_color')
assert_have_selector('select option', :content => 'green', :value => '1')
assert_have_selector('select option', :content => 'orange', :value => '2', :selected => 'selected')
assert_have_selector('select option', :content => 'purple', :value => '3')
assert_have_selector('select optgroup', :label => 'foo')
assert_have_selector('select optgroup', :label => 'bar')
assert_have_selector('select optgroup option', :content => 'foo', :value => 'foo')
assert_have_selector('select optgroup option', :content => 'bar', :value => 'bar')
assert_have_selector('select optgroup', :label => 'Friends')
assert_have_selector('select optgroup', :label => 'Enemies')
assert_have_selector('select optgroup option', :content => 'Yoda', :value => 'Yoda')
assert_have_selector('select optgroup option', :content => 'Obiwan', :value => '1')
assert_have_selector('select optgroup option', :content => 'Palpatine', :value => 'Palpatine')
assert_have_selector('select optgroup option', :content => 'Darth Vader', :value => '3')
end

should "display select tag in haml" do
Expand All @@ -795,11 +804,20 @@ def app
assert_have_selector('select option', :content => 'green', :value => 'green')
assert_have_selector('select option', :content => 'orange', :value => 'orange')
assert_have_selector('select option', :content => 'purple', :value => 'purple')
assert_have_selector 'form.advanced-form select', :name => 'fav_color'
assert_have_selector('form.advanced-form select', :name => 'fav_color')
assert_have_selector('select option', :content => 'green', :value => '1')
assert_have_selector('select option', :content => 'orange', :value => '2', :selected => 'selected')
assert_have_selector('select option', :content => 'purple', :value => '3')
assert_have_selector('select optgroup', :label => 'foo')
assert_have_selector('select optgroup', :label => 'bar')
assert_have_selector('select optgroup option', :content => 'foo', :value => 'foo')
assert_have_selector('select optgroup option', :content => 'bar', :value => 'bar')
assert_have_selector('select optgroup', :label => 'Friends')
assert_have_selector('select optgroup', :label => 'Enemies')
assert_have_selector('select optgroup option', :content => 'Yoda', :value => 'Yoda')
assert_have_selector('select optgroup option', :content => 'Obiwan', :value => '1')
assert_have_selector('select optgroup option', :content => 'Palpatine', :value => 'Palpatine')
assert_have_selector('select optgroup option', :content => 'Darth Vader', :value => '3')
end

should "display select tag in slim" do
Expand All @@ -808,11 +826,20 @@ def app
assert_have_selector('select option', :content => 'green', :value => 'green')
assert_have_selector('select option', :content => 'orange', :value => 'orange')
assert_have_selector('select option', :content => 'purple', :value => 'purple')
assert_have_selector 'form.advanced-form select', :name => 'fav_color'
assert_have_selector('form.advanced-form select', :name => 'fav_color')
assert_have_selector('select option', :content => 'green', :value => '1')
assert_have_selector('select option', :content => 'orange', :value => '2', :selected => 'selected')
assert_have_selector('select option', :content => 'purple', :value => '3')
assert_have_selector('select optgroup', :label => 'foo')
assert_have_selector('select optgroup', :label => 'bar')
assert_have_selector('select optgroup option', :content => 'foo', :value => 'foo')
assert_have_selector('select optgroup option', :content => 'bar', :value => 'bar')
assert_have_selector('select optgroup', :label => 'Friends')
assert_have_selector('select optgroup', :label => 'Enemies')
assert_have_selector('select optgroup option', :content => 'Yoda', :value => 'Yoda')
assert_have_selector('select optgroup option', :content => 'Obiwan', :value => '1')
assert_have_selector('select optgroup option', :content => 'Palpatine', :value => 'Palpatine')
assert_have_selector('select optgroup option', :content => 'Darth Vader', :value => '3')
end
end

Expand Down