Created
October 18, 2016 15:05
-
-
Save lkrych/a883e6c1d29234a941cfd98a1fccc42d to your computer and use it in GitHub Desktop.
Completed RSpec for update method in 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 "PUT #update" do | |
| it "located the requested movie" do | |
| put :update, id: @mock_movie, movie: @mock_movie_attributes | |
| expect(assigns(:movie)).to eq(@mock_movie) | |
| end | |
| it "changed the requested movies attributes" do | |
| put :update, id: @mock_movie, movie: @mock_movie_attributes | |
| @mock_movie.reload | |
| expect(@mock_movie.title).to eq("Space Balls") | |
| expect(@mock_movie.rating).to eq("PG") | |
| end | |
| it "redirects to the updated movie" do | |
| put :update, id: @mock_movie, movie: @mock_movie_attributes | |
| expect(response).to redirect_to @contact | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment