Created
February 26, 2018 04:11
-
-
Save alanmaciel/8bf7f4a52e7b0241152f5bc76b4eff8b 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_relative 'spec_helper' | |
describe "Creating a new movie" do | |
it "saves the movie and shows the new movie's details" do | |
visit movies_url | |
click_link 'Add New Movie' | |
expect(current_path).to eq(new_movie_path) | |
fill_in "Title", with: "New Movie Title" | |
fill_in "Description", with: "Superheroes saving the world from villains" | |
select "PG-13", :from => "movie_rating" | |
fill_in "Total gross", with: "75000000" | |
select (Time.now.year - 1).to_s, :from => "movie_released_on_1i" | |
fill_in "Cast", with: "The award-winning cast" | |
fill_in "Director", with: "The ever-creative director" | |
fill_in "Duration", with: "123 min" | |
fill_in "Image file name", with: "movie.png" | |
click_button 'Create Movie' | |
expect(current_path).to eq(movie_path(Movie.last)) | |
expect(page).to have_text('New Movie Title') | |
expect(page).to have_text('Movie successfully created!') | |
end | |
it "does not save the movie if it's invalid" do | |
visit new_movie_url | |
expect { | |
click_button 'Create Movie' | |
}.not_to change(Movie, :count) | |
expect(current_path).to eq(movies_path) | |
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