Skip to content
Browse files

trailing whitespace removal

Signed-off-by: Justin French <justin@indent.com.au>
  • Loading branch information...
1 parent 3390247 commit e6769759f5a608517cb12e64786b2a06389eda90 @sprsquish sprsquish committed with
Showing with 28 additions and 28 deletions.
  1. +3 −3 lib/formtastic.rb
  2. +25 −25 spec/formtastic_spec.rb
View
6 lib/formtastic.rb
@@ -390,11 +390,11 @@ def select_input(method, options)
choices = formatted_collection(options[:collection], options[:label_method], options[:value_method])
input_label(input_name, options) + template.select(@object_name, input_name, choices, set_options(options), html_options)
end
-
+
def detect_label_method(collection) #:nodoc:
(!collection.instance_of?(Hash)) ? @@collection_label_methods.detect { |m| collection.first.respond_to?(m) } : nil
end
-
+
def formatted_collection(collection, label_method, value_method = :id) #:nodoc:
return collection if (collection.instance_of?(Hash) || (collection.instance_of?(Array) && collection.first.instance_of?(String)))
collection.map { |o| [o.send(label_method), o.send(value_method)] }
@@ -457,7 +457,7 @@ def radio_input(method, options)
choices.map { |c|
label = (!c.instance_of?(String)) ? c.first : c
value = (!c.instance_of?(String)) ? c.last : c
-
+
template.content_tag(:li,
template.content_tag(:label,
"#{template.radio_button(@object_name, input_name, value, set_options(options))} #{label}",
View
50 spec/formtastic_spec.rb
@@ -399,7 +399,7 @@ def custom(arg1, arg2, options = {})
output_buffer.should have_tag('form li.optional')
end
- it 'should append the "optional" string to the label' do
+ it 'should append the "optional" string to the label' do
semantic_form_for(@new_post) do |builder|
concat(builder.input(:title, :required => false))
end
@@ -544,11 +544,11 @@ def custom(arg1, arg2, options = {})
it 'should default to :file for attributes that respond to #file?' do
attachment_input_type(:file?).should == :file
end
-
+
it 'should default to :file for attributes that respond to #public_filename' do
attachment_input_type(:public_filename).should == :file
end
-
+
end
end
@@ -861,7 +861,7 @@ def custom(arg1, arg2, options = {})
output_buffer.should have_tag('form li fieldset ol')
output_buffer.should have_tag('form li fieldset ol li', :count => Author.find(:all).size)
end
-
+
it 'should have one option with a "selected" attribute' do
output_buffer.should have_tag('form li input[@checked]', :count => 1)
end
@@ -998,14 +998,14 @@ def custom(arg1, arg2, options = {})
end
output_buffer.should have_tag('form li fieldset ol li', :count => @authors.size)
end
-
+
describe 'and the :collection is an array of strings' do
-
+
before do
@new_post.stub!(:category_name).and_return('')
@categories = [ 'General', 'Design', 'Development' ]
end
-
+
it 'should use the string as the label text and value for each radio button' do
semantic_form_for(@new_post) do |builder|
concat(builder.input(:category_name, :as => :radio, :collection => @categories))
@@ -1015,16 +1015,16 @@ def custom(arg1, arg2, options = {})
output_buffer.should have_tag('form li fieldset ol li label input[@value='+item+']')
end
end
-
+
end
-
+
describe 'and the :collection is a hash of strings' do
-
+
before do
@new_post.stub!(:category_name).and_return('')
@categories = { 'General' => 'gen', 'Design' => 'des','Development' => 'dev' }
end
-
+
it 'should use the key as the label text and the hash value as the value attribute for each radio button' do
semantic_form_for(@new_post) do |builder|
concat(builder.input(:category_name, :as => :radio, :collection => @categories))
@@ -1034,9 +1034,9 @@ def custom(arg1, arg2, options = {})
output_buffer.should have_tag('form li fieldset ol li label input[@value='+value+']')
end
end
-
+
end
-
+
end
describe 'when the :label_method option is provided' do
@@ -1109,7 +1109,7 @@ def custom(arg1, arg2, options = {})
output_buffer.should have_tag("form li select option[@value='#{author.id}']", /#{author.to_label}/)
end
end
-
+
it 'should have one option with a "selected" attribute' do
output_buffer.should have_tag('form li select option[@selected]', :count => 1)
end
@@ -1150,7 +1150,7 @@ def custom(arg1, arg2, options = {})
output_buffer.should have_tag("form li select option[@value='#{post.id}']", /#{post.to_label}/)
end
end
-
+
it 'should have one option with a "selected" attribute' do
output_buffer.should have_tag('form li select option[@selected]', :count => 1)
end
@@ -1191,7 +1191,7 @@ def custom(arg1, arg2, options = {})
output_buffer.should have_tag("form li select option[@value='#{author.id}']", /#{author.to_label}/)
end
end
-
+
it 'should have one option with a "selected" attribute' do
output_buffer.should have_tag('form li select option[@selected]', :count => 1)
end
@@ -1236,7 +1236,7 @@ def custom(arg1, arg2, options = {})
end
end
-
+
describe 'when the :collection option is not provided' do
it 'should perform a basic find on the parent class' do
@@ -1268,14 +1268,14 @@ def custom(arg1, arg2, options = {})
end
output_buffer.should have_tag('form li select option', :count => @authors.size)
end
-
+
describe 'and the :collection is an array of strings' do
-
+
before do
@new_post.stub!(:category_name).and_return('')
@categories = [ 'General', 'Design', 'Development' ]
end
-
+
it 'should use the string as the text and value for each option element' do
semantic_form_for(@new_post) do |builder|
concat(builder.input(:category_name, :as => :select, :collection => @categories))
@@ -1284,16 +1284,16 @@ def custom(arg1, arg2, options = {})
output_buffer.should have_tag('form li select option[@value='+item+']', item)
end
end
-
+
end
-
+
describe 'and the :collection is a hash of strings' do
-
+
before do
@new_post.stub!(:category_name).and_return('')
@categories = { 'General' => 'gen', 'Design' => 'des','Development' => 'dev' }
end
-
+
it 'should use the key as the text and the hash value as the value attribute for each option element' do
semantic_form_for(@new_post) do |builder|
concat(builder.input(:category_name, :as => :select, :collection => @categories))
@@ -1302,7 +1302,7 @@ def custom(arg1, arg2, options = {})
output_buffer.should have_tag('form li select option[@value='+value+']', label)
end
end
-
+
end
end

0 comments on commit e676975

Please sign in to comment.
Something went wrong with that request. Please try again.