Skip to content

Instantly share code, notes, and snippets.

@alanmaciel
Last active February 26, 2018 04:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanmaciel/6c407a9dd56c3f41063b060be30ccfc1 to your computer and use it in GitHub Desktop.
Save alanmaciel/6c407a9dd56c3f41063b060be30ccfc1 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe "Creating a new review" do
it "saves the review" do
movie = Movie.create(movie_attributes)
visit movie_url(movie)
click_link 'Write Review'
expect(current_path).to eq(new_movie_review_path(movie))
fill_in "Name", with: "Alan Maciel"
choose "review_stars_3"
fill_in "Comment", with: "My first review"
click_button 'Post Review'
expect(current_path).to eq(movie_reviews_path(movie))
expect(page).to have_text('Thanks for your review!')
end
it "does not save the movie review if it's invalid" do
movie = Movie.create(movie_attributes)
visit new_movie_review_url(movie)
expect {
click_button 'Post Review'
}.not_to change(Review, :count)
expect(page).to have_text('error')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment