ruby on rails - Controller testing Show page with Rspec, it gives an error nil & and render empty page -
i'm new tdd on rails, , i'm trying test videos_controller book "everyday rails testing rails" simple show page gives me error 'nil' & render empty, follows. don't know i'm doing wrong. please advise me. thank help.
spec/controllers/videos_controller_spec.rb
require 'spec_helper' describe videoscontroller describe "get show" before {@video1 = video.create!(title: 'family guy', description: 'some description')} "assigns requested video @video" :show, id: @video1 assigns(:video).should == @video1 end "render show tempalte" :show, id: @video1 response.should render_template :show end end end
app/controllers/videos_controller.rb
class videoscontroller < applicationcontroller before_filter :require_user def show @video = video.find(params[:id]) end end
error got in terminal:
failures: 1) videoscontroller show assigns requested video @video failure/error: assigns(:video).should == @video1 expected: #<video id: 1, title: "family guy", small_cover_url: nil, large_cover_url: nil, description: "some description", created_at: "2013-05-13 00:12:32", updated_at: "2013-05-13 00:12:32"> got: nil (using ==) # ./spec/controllers/videos_controller_spec.rb:9:in `block (3 levels) in <top (required)>' 2) videoscontroller show render show tempalte failure/error: response.should render_template :show expecting <"show"> rendering <""> # ./spec/controllers/videos_controller_spec.rb:14:in `block (3 levels) in <top (required)>
there before_filter
in controller
before_filter :require_user
you have not supplied required action in test, real action show
has not been reached yet.
to fix, add necessary action creating user or login, before get :show
Comments
Post a Comment