Skip to content

Instantly share code, notes, and snippets.

Alan Maciel alanmaciel

Block or report user

Report or block alanmaciel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View xp_validations_model.rb
validates :title, :released_on, :duration, presence: true
validates :description, length: { minimum: 25 }
validates :total_gross, numericality: { greater_than_or_equal_to: 0 }
validates :image_file_name, allow_blank: true, format: {
with: /\w+\.(gif|jpg|png)\z/i,
message: "must reference a GIF, JPG, or PNG image"
}
View xp_show_object_spec.rb
require 'spec_helper'
describe "Viewing an individual movie" do
it "shows the movie's details" do
movie = Movie.create(movie_attributes)
visit movie_url(movie)
expect(page).to have_text(movie.title)
expect(page).to have_text(movie.rating)
View xp_navigate_objects_spec.rb
require 'spec_helper'
describe "Navigating movies" do
it "allows navigation from the detail page to the listing page" do
movie = Movie.create(movie_attributes)
visit movie_url(movie)
View xp_list_objects_spec.rb
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",
View xp_list_child_objects_spec.rb
require 'spec_helper'
describe "Viewing a list of reviews" do
it "shows the reviews for a specific movie" do
movie1 = Movie.create(movie_attributes(title: "Iron Man"))
review1 = movie1.reviews.create(review_attributes(name: "Roger Ebert"))
review2 = movie1.reviews.create(review_attributes(name: "Gene Siskel"))
movie2 = Movie.create(movie_attributes(title: "Superman"))
review3 = movie2.reviews.create(review_attributes(name: "Peter Travers"))
View xp_helper_spec.rb
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
View xp_edit_object_spec.rb
require 'spec_helper'
describe "Editing a movie" do
it "updates the movie and shows the movie's updated details" do
movie = Movie.create(movie_attributes)
visit movie_url(movie)
click_link 'Edit'
View xp_delete_object_spec.rb
require 'spec_helper'
describe "Deleting a movie" do
it "destroys the movie and shows the movie listing without the deleted movie" do
movie = Movie.create(movie_attributes)
visit movie_path(movie)
click_link 'Delete'
View xp_create_object_spec.rb
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'
View xp_create_object_spec.rb
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)
You can’t perform that action at this time.