Created
October 18, 2016 15:15
-
-
Save lkrych/9841bf88df3f8dbf4909b75ff3ae124e to your computer and use it in GitHub Desktop.
Complete RSpec file to test the delete method in the movies_controller
This file contains hidden or 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 'rails_helper' | |
| RSpec.describe MoviesController, type: :controller do | |
| before (:each) do | |
| @mock_movie_attributes = {:title => 'Space Balls', :release_date => '24/6/1987', :rating => 'PG'} | |
| @mock_movie = FactoryGirl.create(:movie) | |
| end | |
| describe "DELETE #destroy" do | |
| it "deletes the movie" do | |
| expect{ | |
| delete :destroy, id: @mock_movie | |
| }.to change(Movie,:count).by(-1) | |
| end | |
| it "redirects to the main page " do | |
| delete :destroy, id: @mock_movie | |
| expect(response).to redirect_to(:action => 'index') | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment