Created
July 3, 2014 08:03
-
-
Save GustavoCaso/2122342c68da9db1c48c to your computer and use it in GitHub Desktop.
Error with shared examples rspec, always return undefined method id for nil class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe ReviewsController do | |
before(:each) do | |
signin_user | |
@video = Fabricate(:video) | |
end | |
describe 'Post Create' do | |
context 'Authenticated user Valid data' do | |
it 'create a new review with valid data' do | |
expect{ | |
post :create, review: {rating: "1", description: "icdgivbwi"}, video_id: @video.id | |
}.to change(Review,:count).by(1) | |
end | |
it 'will redirect_to video show after creation' do | |
post :create, review: {rating: "1", description: "icdgivbwi"}, video_id: @video.id | |
expect(response).to redirect_to video_path(@video) | |
end | |
it 'will fill flash[:info] variable' do | |
post :create, review: {rating: "1", description: "icdgivbwi"}, video_id: @video.id | |
expect(flash[:info]).to_not be_empty | |
end | |
end | |
context 'Authenticated user Invalid data' do | |
it 'will not create a review' do | |
expect{ | |
post :create, review: {rating: "1"}, video_id: @video.id | |
}.to_not change(Review,:count) | |
end | |
it 'will render videos show' do | |
post :create, review: {rating: "1"}, video_id: @video.id | |
expect(response).to render_template 'videos/show' | |
end | |
it 'will fill flash[:danger] variable' do | |
post :create, review: {rating: "1"}, video_id: @video.id | |
expect(flash[:danger]).to_not be_empty | |
end | |
end | |
it_behaves_like "unauthenticated user" do | |
let(:action) { post :create, review: {rating: "1", description: "icdgivbwi"}, video_id: @video } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment