poll功能测试

This commit is contained in:
zhuhao 2015-01-30 14:11:59 +08:00
parent 7cdcf96845
commit ac001a4ba0
1 changed files with 63 additions and 6 deletions

View File

@ -8,7 +8,20 @@ describe PollController do
expect(create(:poll)).to be_valid
end
end
# describe 'GET #index' do
# 2 context 'with params[:letter]' do
# 3 it " populates an array of contacts starting with the letter" do
# 4 smith = create( :contact, lastname: 'Smith' )
# 5 jones = create( :contact, lastname: 'Jones' )
# 6 get :index, letter: 'S'
# 7 expect(assigns( :contacts)) . to match_array( [ smith] )
# 8 end
# 9
# 10 it " renders the :index view" do
# 11 get :index, letter: 'S'
# 12 expect(response) . to render_template :index
# 13 end
# 14 end
describe "GET #index" do
it "get the poll list" do
@ -27,7 +40,19 @@ describe PollController do
end
end
# describe 'GET #show' do
# 2 it " assigns the requested contact to @contact" do
# 3 contact = create( :contact)
# 4 get :show, id: contact
# 5 expect(assigns( :contact)) . to eq contact
# 6 end
# 78
# it " renders the :show template" do
# 9 contact = create( :contact)
# 10 get :show, id: contact
# 11 expect(response) . to render_template :show
# 12 end
# 13 end
describe 'GET #show' do
it "it show the poll by poll_id"do
@poll=create( :poll)
@ -37,7 +62,18 @@ describe PollController do
end
describe 'GET #new' do
it "save the poll success "do
PollController.any_instance.stubs(:valid?).returns(true)
get 'new'
#@poll=Poll.new
response.should redirect_to(edit_poll_path @poll.id)
#expect(assigns( :poll)).to be_a_new( Poll)
end
it"should redirect new template on fiald save"do
PollController.any_instance.stubs(:valid?).returns(true)
get 'new'
response.should redirect_to(news_path)
end
end
describe 'GET #edit' do
@ -53,11 +89,24 @@ describe PollController do
describe 'PATCH #updte' do
end
# describe 'DELETE #destroy' do
# before :each do
# @contact = create( :contact)
# end
#
# it " deletes the contact" do
# expect{
# delete :destroy, id: @contact
# } . to change( Contact, :count) . by( - 1 )
# end
#
# it " redirects to contacts#index" do
# delete :destroy, id: @contact
# expect(response) . to redirect_to contacts_url
# end
# end
# 删除问卷的测试
describe 'DELETE #destroy' do
before do
@poll=create(:poll)
end
it "deletes the poll"do
expect { delete 'destroy',id: @poll }.to change( Poll, :count).by(-1)
end
@ -67,4 +116,12 @@ describe PollController do
expect(response).to redirect_to poll_url
end
end
describe 'POST #create' do
end
describe 'PATCH #update' do
end
end