Skip to content

Instantly share code, notes, and snippets.

@alanmaciel
Created February 26, 2018 04:11
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/8bf7f4a52e7b0241152f5bc76b4eff8b to your computer and use it in GitHub Desktop.
Save alanmaciel/8bf7f4a52e7b0241152f5bc76b4eff8b to your computer and use it in GitHub Desktop.
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