Skip to content

Instantly share code, notes, and snippets.

@alanmaciel
Created February 26, 2018 04:11
Show Gist options
  • Select an option

  • Save alanmaciel/7b7da1b9acb1761f01985967f64ce993 to your computer and use it in GitHub Desktop.

Select an option

Save alanmaciel/7b7da1b9acb1761f01985967f64ce993 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