Skip to content

Commit

Permalink
Update tests using factory bot
Browse files Browse the repository at this point in the history
  • Loading branch information
rlmoser99 committed Mar 8, 2021
1 parent 31641cc commit 26e4c6e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
22 changes: 12 additions & 10 deletions spec/services/flight_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@
let(:tomorrow) { Time.zone.tomorrow }
subject(:flight_generator) { described_class.new(tomorrow) }

Airport.find_or_create_by(code: "SFO", location: "San Francisco, CA")
Airport.find_or_create_by(code: "NYC", location: "New York City, NY")
Airport.find_or_create_by(code: "ATL", location: "Atlanta, GA")
Airport.find_or_create_by(code: "ORD", location: "Chicago, IL")
Airport.find_or_create_by(code: "LAX", location: "Los Angeles, CA")
Airport.find_or_create_by(code: "DFW", location: "Dallas, TX")
Airport.find_or_create_by(code: "MCO", location: "Orlando, FL")
Airport.find_or_create_by(code: "DEN", location: "Denver, CO")

describe "#create_flights" do
it "returns flight duration" do
before do
create(:airport, code: "SFO", location: "San Francisco, CA")
create(:airport, code: "NYC", location: "New York City, NY")
create(:airport, code: "ATL", location: "Atlanta, GA")
create(:airport, code: "ORD", location: "Chicago, IL")
create(:airport, code: "LAX", location: "Los Angeles, CA")
create(:airport, code: "DFW", location: "Dallas, TX")
create(:airport, code: "MCO", location: "Orlando, FL")
create(:airport, code: "DEN", location: "Denver, CO")
end

it "increases flight count by the daily flight count" do
airport_pairs = 56
flights_per_day = 3
daily_flight_count = airport_pairs * flights_per_day
Expand Down
12 changes: 6 additions & 6 deletions spec/system/add_booking_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
require "rails_helper"

RSpec.describe "add booking", type: :system do
let!(:chicago) { create(:airport, :chicago, location: "Chicago, IL") }
let!(:new_york) { create(:airport, :new_york_city, location: "New York City, NY") }
let!(:atlanta) { create(:airport, :atlanta) }
it "allows a user to search flights, select a booking option, and create a booking" do
chicago = create(:airport, :chicago, location: "Chicago, IL")
new_york = create(:airport, :new_york_city, location: "New York City, NY")
atlanta = create(:airport, :atlanta)

let!(:ORD_NYC) { create(:tomorrow_morning_flight, id: 1, origin_airport: chicago, destination_airport: new_york) }
let!(:ORD_ATL) { create(:tomorrow_morning_flight, id: 2, origin_airport: chicago, destination_airport: atlanta) }
create(:tomorrow_morning_flight, id: 1, origin_airport: chicago, destination_airport: new_york)
create(:tomorrow_morning_flight, id: 2, origin_airport: chicago, destination_airport: atlanta)

it "allows a user to search flights, select a booking option, and create a booking" do
visit "/"
select("Chicago, IL", from: "origin_id")
select("New York City, NY", from: "destination_id")
Expand Down

0 comments on commit 26e4c6e

Please sign in to comment.