Last active
February 26, 2018 04:22
-
-
Save alanmaciel/6c407a9dd56c3f41063b060be30ccfc1 to your computer and use it in GitHub Desktop.
This file contains 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 '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