Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minor formatting changes in test files
Browse files Browse the repository at this point in the history
add2point71dots committed Mar 13, 2017
1 parent a57f2bc commit 11b6bfe
Showing 3 changed files with 17 additions and 14 deletions.
7 changes: 5 additions & 2 deletions specs/driver_spec.rb
Original file line number Diff line number Diff line change
@@ -119,7 +119,7 @@
end

it "Returns an empty array if no trips are found" do
driver100.trips.length.must_equal 0
driver100.trips.must_equal []
end
end

@@ -136,6 +136,9 @@
proc { driver100.avg_rating }.must_raise NoRatingError
end

#make test for formatting??
it "Returns rating with no more than two decimal places" do
rating_string = driver64.avg_rating.to_s
rating_string.length.must_be :<=, 4
end
end
end
4 changes: 1 addition & 3 deletions specs/rider_spec.rb
Original file line number Diff line number Diff line change
@@ -134,9 +134,7 @@

it "Drivers are not duplicated for a rider that's had a driver > 1 time" do
rider164_drivers = RideShare::Rider.find(164).drivers

rider164_drivers.length.must_equal 5
rider164_drivers.each { |driver| rider164_drivers.count(driver).must_equal 1 }
end

it "Returns an empty array if no trips were taken" do
@@ -147,7 +145,7 @@
proc { rider103.drivers }.must_output (/.+/)
end

it "Doesn't include drivers with invalid driver ids for driver ID that doesn't exist" do
it "Trips taken with driver IDs that don't return a Driver won't add to the array" do
rider103.drivers.length.must_equal 1
end
end
20 changes: 11 additions & 9 deletions specs/trip_spec.rb
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@
it "raises ArgumentError if the date string cannot be parsed to a Date" do
trip_hash1 = { id: 2, driver_id: 4, rider_id: 8, date: "jsad;flk", rating: 5 }
trip_hash2 = { id: 2, driver_id: 4, rider_id: 8, date: "Two weeks ago", rating: 5 }
trip_hash3 = { id: 2, driver_id: 4, rider_id: 8, date: "a trip happend at some point", rating: 5 }
trip_hash3 = { id: 2, driver_id: 4, rider_id: 8, date: "a trip happened at some point", rating: 5 }

proc { RideShare::Trip.new(trip_hash1) }.must_raise ArgumentError
proc { RideShare::Trip.new(trip_hash2) }.must_raise ArgumentError
@@ -136,7 +136,7 @@
end

it "Returns empty array if no trips are found" do
RideShare::Trip.find_driver_trips(10000).length.must_equal 0
RideShare::Trip.find_driver_trips(10000).must_equal []
end
end

@@ -157,39 +157,41 @@
end

it "Returns empty array if no trips are found" do
RideShare::Trip.find_rider_trips(10000).length.must_equal 0
RideShare::Trip.find_rider_trips(10000).must_equal []
end
end

describe "Trip#driver" do
it "returns a Driver object if the driver exists" do
it "Returns a Driver object if the driver exists" do
trip.driver.must_be_instance_of RideShare::Driver
end

it "returns the correct Driver for a driver that exists" do
it "Returns the correct Driver for a driver that exists" do
driver = trip.driver
driver.name.must_equal "Jeromy O'Keefe DVM"
end

it "outputs message and returns nil if driver doesn't exist" do
it "Outputs message and returns nil if driver doesn't exist" do
bad_trip = RideShare::Trip.new({ id: 2, driver_id: 0, rider_id: 8, date: "2014-07-12", rating: 5 })

proc { bad_trip.driver }.must_output (/.+/)
bad_trip.driver.must_equal nil
end
end

describe "Trip#rider" do
it "returns a Rider object if the rider exists" do
it "Returns a Rider object if the rider exists" do
trip.rider.must_be_instance_of RideShare::Rider
end

it "returns the correct Rider for a rider that exists" do
it "Returns the correct Rider for a rider that exists" do
rider = trip.rider
rider.phone.must_equal "1-904-093-5211 x9183"
end

it "outputs message and returns nil if rider doesn't exist" do
it "Outputs message and returns nil if rider doesn't exist" do
bad_trip = RideShare::Trip.new({ id: 2, driver_id: 4, rider_id: 0, date: "2014-07-12", rating: 5 })

proc { bad_trip.rider }.must_output (/.+/)
bad_trip.rider.must_equal nil
end

0 comments on commit 11b6bfe

Please sign in to comment.