Skip to content

Instantly share code, notes, and snippets.

@alanmaciel
Created February 26, 2018 04:15
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/378b00a0df292fac0bcfa6e40f318b93 to your computer and use it in GitHub Desktop.
Save alanmaciel/378b00a0df292fac0bcfa6e40f318b93 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe "Viewing the list of movies" do
it "shows the movies" do
# Arrange
movie1 = Movie.create(title: "Iron Man",
rating: "PG-13",
total_gross: 318412101.00,
description: "Tony Stark builds an armored suit to fight the throes of evil",
released_on: "2008-05-02",
cast: "Robert Downey Jr., Gwyneth Paltrow and Terrence Howard",
director: "Jon Favreau",
duration: "126 min",
image_file_name: "ironman.jpg")
movie2 = Movie.create(title: "Superman",
rating: "PG",
total_gross: 134218018.00,
description: "Clark Kent grows up to be the greatest super-hero",
released_on: "1978-12-15",
cast: "Christopher Reeve, Margot Kidder and Gene Hackman",
director: "Richard Donner",
duration: "143 min",
image_file_name: "superman.jpg")
movie3 = Movie.create(title: "Spider-Man",
rating: "PG-13",
total_gross: 403706375.00,
description: "Peter Parker gets bit by a genetically modified spider",
released_on: "2002-05-03",
cast: "Tobey Maguire, Kirsten Dunst and Willem Dafoe",
director: "Sam Raimi",
duration: "121 min",
image_file_name: "spiderman.jpg")
# Act
visit movies_url
# Assert
expect(page).to have_link(movie1.title, movie_url(movie1))
expect(page).to have_link(movie2.title, movie_url(movie2))
expect(page).to have_link(movie3.title, movie_url(movie3))
expect(page).to have_text(movie1.rating)
expect(page).to have_text(movie1.description[0..10])
expect(page).to have_text(movie1.released_on.year)
expect(page).to have_text("$318,412,101.00")
expect(page).to have_text(movie1.cast)
expect(page).to have_text(movie1.duration)
expect(page).to have_selector("img[src$='#{movie1.image_file_name}']")
end
it "does not show a movie that hasn't yet been released" do
movie = Movie.create(movie_attributes(released_on: 1.month.from_now))
visit movies_path
expect(page).not_to have_text(movie.title)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment