Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

test case

  • Loading branch information...
commit a745de3b382a89c6cbd8f347542156dbd2e03ccc 1 parent bd3c06b
gpetrica gpetrica authored
7 spec/inputs/select_input_spec.rb
View
@@ -94,6 +94,7 @@
before do
semantic_form_for(@new_post) do |builder|
concat(builder.input(:author, :as => :select))
+ concat(builder.input(:reviewer, :as => :select))
end
end
@@ -108,11 +109,13 @@
it 'should have a select inside the wrapper' do
output_buffer.should have_tag('form li select')
output_buffer.should have_tag('form li select#post_author_id')
+ output_buffer.should have_tag('form li select#post_reviewer_id')
end
it 'should have a valid name' do
output_buffer.should have_tag("form li select[@name='post[author_id]']")
output_buffer.should_not have_tag("form li select[@name='post[author_id][]']")
+ output_buffer.should_not have_tag("form li select[@name='post[reviewer_id][]']")
end
it 'should not create a multi-select' do
@@ -128,14 +131,14 @@
end
it 'should have a select option for each Author' do
- output_buffer.should have_tag('form li select option', :count => ::Author.find(:all).size + 1)
+ output_buffer.should have_tag("form li select[@name='post[author_id]'] option", :count => ::Author.find(:all).size + 1)
::Author.find(:all).each do |author|
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)
+ output_buffer.should have_tag("form li select[@name='post[author_id]'] option[@selected]", :count => 1)
end
it 'should not singularize the association name' do
1  spec/inputs_spec.rb
View
@@ -391,5 +391,4 @@
end
end
-
end
6 spec/spec_helper.rb
View
@@ -126,6 +126,7 @@ def new_author_path; "/authors/new"; end
@new_post.stub!(:new_record?).and_return(true)
@new_post.stub!(:errors).and_return(mock('errors', :[] => nil))
@new_post.stub!(:author).and_return(nil)
+ @new_post.stub!(:reviewer).and_return(nil)
@new_post.stub!(:main_post).and_return(nil)
@new_post.stub!(:sub_posts).and_return([]) #TODO should be a mock with methods for adding sub posts
@@ -148,7 +149,7 @@ def new_author_path; "/authors/new"; end
::Post.stub!(:reflect_on_validations_for).and_return([])
::Post.stub!(:reflect_on_association).and_return do |column_name|
case column_name
- when :author, :author_status
+ when :author, :author_status, :reviewer
mock = mock('reflection', :options => {}, :klass => ::Author, :macro => :belongs_to)
mock.stub!(:[]).with(:class_name).and_return("Author")
mock
@@ -184,6 +185,9 @@ def new_author_path; "/authors/new"; end
@new_post.stub!(:author).and_return(@bob)
@new_post.stub!(:author_id).and_return(@bob.id)
+ @new_post.stub!(:reviewer).and_return(@fred)
+ @new_post.stub!(:reviewer_id).and_return(@fred.id)
+
@new_post.should_receive(:publish_at=).any_number_of_times
@new_post.should_receive(:title=).any_number_of_times
@new_post.stub!(:main_post_id).and_return(nil)
Please sign in to comment.
Something went wrong with that request. Please try again.