Skip to content
Browse files

Spec for last commit

  • Loading branch information...
1 parent 594b3b7 commit e38a068c11b7698507a4892f212a79a6298e7c3a @sobrinho sobrinho committed Sep 30, 2010
Showing with 19 additions and 0 deletions.
  1. +15 −0 spec/input_spec.rb
  2. +4 −0 spec/spec_helper.rb
View
15 spec/input_spec.rb
@@ -319,6 +319,21 @@ def should_be_required(options)
end
end
+ describe 'and validates_inclusion_of was called for the method' do
+ it 'should be required' do
+ @new_post.class.should_receive(:validators_on).with(:published).any_number_of_times.and_return([
+ active_model_inclusion_validator([:published], {:in => [false, true]})
+ ])
+
+ form = semantic_form_for(@new_post) do |builder|
+ concat(builder.input(:published))
+ end
+ output_buffer.concat(form) if Formtastic::Util.rails3?
+ output_buffer.should have_tag('form li.required')
+ output_buffer.should_not have_tag('form li.optional')
+ end
+ end
+
# TODO make a matcher for this?
def should_be_required(options)
@new_post.class.should_receive(:validators_on).with(:body).at_least(2).and_return([
View
4 spec/spec_helper.rb
@@ -67,6 +67,10 @@ def active_model_length_validator(attributes, options = {})
active_model_validator(:length, attributes, options)
end
+ def active_model_inclusion_validator(attributes, options = {})
+ active_model_validator(:inclusion, attributes, options)
+ end
+
class ::Post
extend ActiveModel::Naming if defined?(ActiveModel::Naming)
include ActiveModel::Conversion if defined?(ActiveModel::Conversion)

0 comments on commit e38a068

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