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
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
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
# Add below into config/application.rb: | |
# | |
# config.middleware.use 'RequestLogger' | |
# | |
class RequestLogger | |
def initialize app | |
@app = app | |
end | |
def call(env) |
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
capitales_dict = { | |
"Aguascalientes" : "Aguascalientes", | |
"Baja California" : "Mexicali", | |
"Baja California Sur" : "La Paz", | |
"Campeche" : "Campeche", | |
"Chihuahua" : "Chihuahua", | |
"Chiapas" : "Tuxtla Gutiérrez", | |
"Coahuila" : "Saltillo", | |
"Colima" : "Colima", | |
"Durango" : "Victoria", |
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
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" | |
} | |
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 "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) |
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 "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", |
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 "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")) |
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
# 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 } |
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 "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' |
NewerOlder