Skip to content

Instantly share code, notes, and snippets.

@lkrych
Created October 18, 2016 14:58
Show Gist options
  • Save lkrych/d56d8f1592b397bf58784def62bb7a9b to your computer and use it in GitHub Desktop.
Save lkrych/d56d8f1592b397bf58784def62bb7a9b to your computer and use it in GitHub Desktop.
Completed RSpec file for testing show functionality of movies_controller
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 "GET #show" do
it "assigns the requested movie to @movie" do
get :show, id: @mock_movie
expect(assigns(:movie).title).to include("Blazing Saddles")
end
it "renders the :show template" do
get :show, id: @mock_movie
expect(response).to render_template(:show)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment