diff --git a/Rakefile b/Rakefile new file mode 100644 index 000000000..43287f15d --- /dev/null +++ b/Rakefile @@ -0,0 +1,9 @@ +require 'rake/testtask' + +Rake::TestTask.new do |t| + t.libs = [] + t.warning = true + t.test_files = FileList['./specs/*_spec.rb'] +end + +task default: :test diff --git a/design-activity.md b/design-activity.md new file mode 100644 index 000000000..9a1d1b2f8 --- /dev/null +++ b/design-activity.md @@ -0,0 +1,34 @@ +What classes does each implementation include? Are the lists the same? +A: CartEntry, ShoppingCart, Order +B: CartEntry, ShoppingCart, Order +(The same!) + +Write down a sentence to describe each class. +CartEntry: In both implementations, it collects the unit price and quantity. B will also find the price by multiplying the two arguments passed in. +ShoppingCart: Both create an array of items in the cart. In B, I _think_ it is trying to iterate through the entries array and add the price of each item in the cart to sum (it is unclear where entry.price is coming from, but I assume from CartEntry.price?) +Order: Each implementation finds the total price of the order, including tax. A does it by iterating through the entries array and adding each item with its own tax to a total price, whereas B adds tax to the final subtotal. + +How do the classes relate to each other? It might be helpful to draw a diagram on a whiteboard or piece of paper. +CartEntry collects info of an item placed in the cart > ShoppingCart stores each entry into an array > Order calculates the total cost of items in the array, plus tax. + +What data does each class store? How (if at all) does this differ between the two implementations? +@unit_price, @quantity, @entries, @cart. They all seem the same to me--initialized the same and seem to hold the same information. + +What methods does each class have? How (if at all) does this differ between the two implementations? +Each class has an initialize method. Both Order classes have a total_price method. implementation B has an additional price method for its CartEntry and ShoppingCart classes. + +Consider the Order#total_price method. In each implementation: +Is logic to compute the price delegated to "lower level" classes like ShoppingCart and CartEntry, or is it retained in Order? +implementation A does not--it retains all logic in itself, and only uses values from other classes. B does, using ShoppingCart#price. + +Does total_price directly manipulate the instance variables of other classes? +No. They both use the values in local variables. + +If we decide items are cheaper if bought in bulk, how would this change the code? Which implementation is easier to modify? +I feel like A would be easier to modify because it calculates the price only once, and it would be simpler to make changes in one class than the several classes it would be in B. + +Which implementation better adheres to the single responsibility principle? +A. A keeps all of its pricing math within the Order class, whereas B calculates price in some way in each of its classes. + +Identify one place in your Hotel project where a class takes on multiple roles, or directly modifies the attributes of another class. +My Reservation class should only be responsible for a single reservation. Instead of Reservation creating AND storing every instance, I should have a Hotel class to store all reservations in. That would make it much easier to create a Blocks class, which I was unable to do when the project was originally assigned. diff --git a/lib/date_range.rb b/lib/date_range.rb new file mode 100644 index 000000000..c475113ee --- /dev/null +++ b/lib/date_range.rb @@ -0,0 +1,23 @@ +module Hotel + class DateRange + class InvalidDateRange < StandardError ; end + attr_reader :check_in, :check_out + + def initialize(check_in, check_out) + unless check_out > check_in + raise InvalidDateRange.new("Invalid dates #{check_in} to #{check_out}") # I took this from the example--I wouldn't have thought to put this here and it is such a good idea + end + + @check_in = check_in + @check_out = check_out + end # end initialize + + def number_of_nights + return @check_out - @check_in + end # end number_of_nights + + def overlap?(other) + !(@check_out <= other.check_in || @check_in >= other.check_out) + end # end overlap? + end # end of class +end # end of module diff --git a/lib/hotel.rb b/lib/hotel.rb new file mode 100644 index 000000000..041197b08 --- /dev/null +++ b/lib/hotel.rb @@ -0,0 +1,48 @@ + +module Hotel + class Hotel + class InvalidRoomError < StandardError ; end + attr_reader :reservations, :rooms + + def initialize + @reservations = [] + @rooms = (1..20).to_a + end # initialize + + def available_rooms(date_range) + reservations = @reservations.reject do |reservation| # removes rooms already booked + !reservation.dates.overlap?(date_range) + end + reserved_rooms = reservations.map do |reservation| # converts each reservation in reservations into its room number + reservation.room + end + return @rooms.reject do |room| # returns the available room numbers by removing reserved rooms from the @rooms list + reserved_rooms.include?(room) + end + end # end available_rooms + + def add_reservation(reservation) + available = available_rooms(reservation.dates) + if !available.include?(reservation.room) + raise InvalidRoomError.new('This room has already been booked') # tests if room has already been booked + else + @reservations << reservation + end + end # end add_reservation + + def all_reservations + return @reservations.map do |reservation| + reservation.pretty_print + end + end # end all_reservations + + def list_on_date(date) + reservations = @reservations.select do |reservation| + reservation.dates.check_in <= date && date <= reservation.dates.check_out + end + return reservations.map do |reservation| + reservation.pretty_print + end + end # end on_date + end # end class +end # end module diff --git a/lib/reservation.rb b/lib/reservation.rb new file mode 100644 index 000000000..6986248ed --- /dev/null +++ b/lib/reservation.rb @@ -0,0 +1,61 @@ +require_relative 'date_range' +module Hotel + class Reservation # various ways to list reservations + # COST = 200 # per night + # @@reservations = [] # list of all reservations made + attr_reader :dates, :room, :rate + + def initialize(dates, room, rate) + @dates = dates + @room = room + @rate = 200 + # available_room_numbers = Hotel::Reservation.available_rooms(@dates).map do |room| + # room.room_number + # end + # if !available_room_numbers.include?(@room.room_number) + # raise InvalidRoomError.new('This room has already been booked') + # end # tests if room has already been booked, raises error if so + # @@reservations << self # each new instance put into the list of total reservations + end # end initialize + + def final_cost + return @rate * @dates.number_of_nights.to_i + end # end final_cost + + def pretty_print + return "Check In: #{@dates.check_in}\nCheck Out: #{@dates.check_out}\nRoom Number: #{@room}\nTotal Cost: $#{final_cost}" + end + + # def self.reservations + # @@reservations + # end # end self.reservations + + # def self.print_list + # bookings = [] + # @@reservations.each do |booking| + # bookings << "Check In: #{booking.check_in}\nCheck Out: #{booking.check_out}\nRoom Number: #{booking.room.room_number}\nTotal Cost: $#{booking.cost}" # turns out you can't use instance variables within a class method + # end + # return bookings + # end # end self.print_list + + # def self.on_date(date) # list reservations on a given date + # @@reservations.select do |reservation| + # reservation.check_in == date + # end + # end # end self.on_date + # + # def self.available_rooms(date_range) # list reservations on given date range + # reservations_in_range = @@reservations.reject do |reservation| # excludes reservastions outside date range + # reservation.dates.overlap?(date_range) + # end + # + # rooms_in_range = reservations_in_range.map do |reservation| # iterates over reservations_in_range and converts each reservation into its room number (instead of list of obj, becomes list of int) + # reservation.room.room_number + # end + # + # return Hotel::Room.all.reject do |room| # remove from list of rooms without reservations in date range + # rooms_in_range.include?(room.room_number) + # end + # end # end self.available_rooms + end # end of Reservation +end # end of Hotel module diff --git a/lib/room.rb b/lib/room.rb new file mode 100644 index 000000000..5a30de660 --- /dev/null +++ b/lib/room.rb @@ -0,0 +1,34 @@ +################################# +# decided I don't need this class +################################# + +# require 'spec_helper' +# +# module Hotel +# class Room +# class InvalidRoomNumber < StandardError ; end +# attr_reader :room_number, :rooms_available +# +# def initialize(room_number) +# @room_number = room_number +# end # end initialize +# +# def self.all +# all_rooms = [] +# CSV.open("support/rooms.csv", 'r').each do |line| +# room_number = line[0].to_i +# all_rooms << self.new(room_number) +# end +# return all_rooms +# end # end self.all +# +# def self.find(room_number) +# self.all.each do |room| +# if room_number == room.room_number +# return room +# end +# end +# raise InvalidRoomNumber.new ('Invalid Room Number') +# end # end self.find +# end # end Room class +# end # Hotel module diff --git a/specs/date_range_spec.rb b/specs/date_range_spec.rb new file mode 100644 index 000000000..086f39824 --- /dev/null +++ b/specs/date_range_spec.rb @@ -0,0 +1,138 @@ +require_relative 'spec_helper' + +describe 'DateRange' do + + describe 'initialize' do + it 'passes in two Date objects as check in and check out arguments' do + check_in = Date.new(2017, 10, 13) + check_out = Date.new(2017, 10, 31) + honeymoon = Hotel::DateRange.new(check_in, check_out) + + honeymoon.check_in.must_be_kind_of Date + honeymoon.check_out.must_be_kind_of Date + end + + it 'cannot have a negative number of nights' do + check_out = Date.new(2017, 10, 13) + check_in = Date.new(2017, 10, 31) + + proc { Hotel::DateRange.new(check_in, check_out) }.must_raise Hotel::DateRange::InvalidDateRange + end + + it 'cannot book zero nights' do + check_out = Date.new(2017, 10, 13) + check_in = Date.new(2017, 10, 13) + + proc { Hotel::DateRange.new(check_in, check_out) }.must_raise Hotel::DateRange::InvalidDateRange + end + end # end initialize + + describe 'number_of_nights' do + it 'returns the number of nights passed in' do + check_in = Date.new(2017, 10, 13) + check_out = Date.new(2017, 10, 31) + honeymoon = Hotel::DateRange.new(check_in, check_out) + + honeymoon.number_of_nights.must_equal 18 + end + end # end number_of_nights + + describe 'overlap?' do + before do + @check_in = Date.new(2017, 10, 13) + @check_out = Date.new(2017, 10, 31) + @honeymoon = Hotel::DateRange.new(@check_in, @check_out) + end + + it 'returns true if the check in dates are the same' do + birthday = Hotel::DateRange.new(@check_in, @check_out) + @honeymoon.overlap?(birthday).must_equal true + end + + it 'returns true if the reservation starts before the other ends' do + check_in = Date.new(2017, 10, 10) + check_out = Date.new(2017, 10, 15) + birthday = Hotel::DateRange.new(check_in, check_out) + + @honeymoon.overlap?(birthday).must_equal true + end + + it 'returns true if the reservation ends after the other starts' do + check_in = Date.new(2017, 10, 30) + check_out = Date.new(2017, 11, 1) + birthday = Hotel::DateRange.new(check_in, check_out) + + @honeymoon.overlap?(birthday).must_equal true + end + + it 'returns true if the new date range is contained in the other date range' do + check_in = Date.new(2017, 10, 15) + check_out = Date.new(2017, 10, 16) + birthday = Hotel::DateRange.new(check_in, check_out) + + @honeymoon.overlap?(birthday).must_equal true + end + + it 'returns true if the new date range contains the other date range' do + check_in = Date.new(2017, 10, 1) + check_out = Date.new(2017, 11, 1) + birthday = Hotel::DateRange.new(check_in, check_out) + + @honeymoon.overlap?(birthday).must_equal true + end + + it 'returns false if the reservation ends before the other starts' do + check_in = Date.new(2017, 10, 1) + check_out = Date.new(2017, 10, 12) + birthday = Hotel::DateRange.new(check_in, check_out) + + @honeymoon.overlap?(birthday).must_equal false + end + + it 'returns false if the reservation begins after the other ends' do + check_in = Date.new(2017, 11, 1) + check_out = Date.new(2017, 11, 2) + birthday = Hotel::DateRange.new(check_in, check_out) + + @honeymoon.overlap?(birthday).must_equal false + end + + it 'returns false if the reservation begins on the other check out date' do + check_in = Date.new(2017, 10, 1) + check_out = Date.new(2017, 10, 13) + birthday = Hotel::DateRange.new(check_in, check_out) + + @honeymoon.overlap?(birthday).must_equal false + end + + it 'returns false if the reservation ends on the other check in date' do + check_in = Date.new(2017, 10, 31) + check_out = Date.new(2017, 11, 1) + birthday = Hotel::DateRange.new(check_in, check_out) + + @honeymoon.overlap?(birthday).must_equal false + end + end # end overlap? + + # before do + # @puppy_dates = Hotel::DateRange.new(Date.new(2017, 10, 13), Date.new(2017, 10, 31)) + # end # end before + # + # describe 'initialize' do + # it 'takes a check in date and a check out date' do + # @puppy_dates.check_in.to_s.must_equal '2017-10-13' + # @puppy_dates.check_out.to_s.must_equal '2017-10-31' + # end # end test + # + # it 'passes check_in and check_out in as Date objects' do + # @puppy_dates.check_in.class.must_equal Date + # @puppy_dates.check_out.class.must_equal Date + # end # end test + # end # end #initialize + # + # describe 'length_of_stay' do + # it 'finds the number of days needed for the reservation based on given dates' do + # @puppy_dates.length_of_stay.must_equal 18 + # end # end test + # end # end #length_of_stay +end # end of all DateRange tests diff --git a/specs/hotel_spec.rb b/specs/hotel_spec.rb new file mode 100644 index 000000000..850581531 --- /dev/null +++ b/specs/hotel_spec.rb @@ -0,0 +1,137 @@ +require_relative 'spec_helper' + +describe 'Hotel' do + before do + @peach_castle = Hotel::Hotel.new + + dates = Hotel::DateRange.new(Date.new(2017, 10, 13), Date.new(2017, 10, 31)) + @honeymoon = Hotel::Reservation.new(dates, 13, 200) + + dates = Hotel::DateRange.new(Date.new(2017, 1, 13), Date.new(2017, 1, 31)) + @birthday = Hotel::Reservation.new(dates, 13, 200) + + @peach_castle.add_reservation(@honeymoon) + @peach_castle.add_reservation(@birthday) + end + + describe 'available_rooms' do + it 'returns a list of all rooms when all are available' do + dates = Hotel::DateRange.new(Date.new(2018, 10, 13), Date.new(2018, 10, 31)) + @peach_castle.available_rooms(dates).must_equal @peach_castle.rooms + end + + it 'returns list of rooms available' do + dates = Hotel::DateRange.new(Date.new(2017, 10, 10), Date.new(2017, 10, 15)) + @peach_castle.available_rooms(dates).wont_include 13 + @peach_castle.available_rooms(dates).length.must_equal 19 + end + end # end available_rooms + + describe 'add_reservation' do + it 'adds a reservation' do + dates = Hotel::DateRange.new(Date.new(2017, 2, 13), Date.new(2017, 2, 28)) + batmitzvah = Hotel::Reservation.new(dates, 13, 200) + @peach_castle.add_reservation(batmitzvah) + + @peach_castle.reservations.length.must_equal 3 + end + + it 'raises an error if the room is already booked' do + dates = Hotel::DateRange.new(Date.new(2017, 10, 13), Date.new(2017, 10, 31)) + batmitzvah = Hotel::Reservation.new(dates, 13, 200) + + proc{@peach_castle.add_reservation(batmitzvah)}.must_raise Hotel::Hotel::InvalidRoomError + end + + it 'will not add an invalid reservation to the array' do + dates = Hotel::DateRange.new(Date.new(2017, 10, 13), Date.new(2017, 10, 31)) + batmitzvah = Hotel::Reservation.new(dates, 13, 200) + + proc{@peach_castle.add_reservation(batmitzvah)}.must_raise Hotel::Hotel::InvalidRoomError + @peach_castle.reservations.length.must_equal 2 + end + end # end add_reservation + + describe 'all_reservations' do + it 'returns a list of all reservations' do + @peach_castle.all_reservations.must_equal ["Check In: 2017-10-13 +Check Out: 2017-10-31 +Room Number: 13 +Total Cost: $3600", +"Check In: 2017-01-13 +Check Out: 2017-01-31 +Room Number: 13 +Total Cost: $3600"] + end # sorry I know this is ugly but tabbing it will make it fail! + end # end all_reservations + + describe 'list_on_date' do + it 'returns a list of reservations on a date' do + @peach_castle.list_on_date(Date.new(2017, 10, 20)).must_equal ["Check In: 2017-10-13 +Check Out: 2017-10-31 +Room Number: 13 +Total Cost: $3600"] + end + + it 'returns an empty array if there are no reservations on a date' do + @peach_castle.list_on_date(Date.new(2020, 12, 25)).must_equal [] + end + + it 'returns a list including an added reservation on a date' do + dates = Hotel::DateRange.new(Date.new(2017, 10, 10), Date.new(2017, 10, 15)) + batmitzvah = Hotel::Reservation.new(dates, 1, 200) + @peach_castle.add_reservation(batmitzvah) + + @peach_castle.list_on_date(Date.new(2017, 10, 13)).must_equal ["Check In: 2017-10-13 +Check Out: 2017-10-31 +Room Number: 13 +Total Cost: $3600", "Check In: 2017-10-10 +Check Out: 2017-10-15 +Room Number: 1 +Total Cost: $1000"] + end + end # end list_on_date + + # it 'raises an InvalidRoomError if room has already been booked' do + # proc{Hotel::Reservation.new('Suge', Date.new(2017, 10, 15), Date.new(2017, 10, 20), Hotel::Room.find(13))}.must_raise Hotel::InvalidRoomError + # end # end test + # + # it 'will not add invalid reservation to @@reservations' do + # number_of_reservations = Hotel::Reservation.reservations.length + # begin + # Hotel::Reservation.new('Suge', Date.new(2017, 10, 15), Date.new(2017, 10, 20), Hotel::Room.find(13)) + # rescue + # end + # + # Hotel::Reservation.reservations.length.must_equal number_of_reservations # makes sure number did not change! + # end # end test + # end # end #initialize + # + # describe 'self.reservations' do + # it 'calls the class variable @@reservations, which holds all instances of Reservation in an array' do + # Hotel::Reservation.reservations.must_equal [puppy_expo, kitten_expo] + # end # end test + # end # end #self.reservations + # + # describe 'self.print_list' do + # it 'returns list of all reservations' do + # Hotel::Reservation.print_list.must_equal ["Name: Finn\nCheck In: 2017-10-13\nCheck Out: 2017-10-31\nRoom Number: 13\nTotal Cost: $3600", "Name: Girlie\nCheck In: 2018-01-17\nCheck Out: 2018-01-31\nRoom Number: 11\nTotal Cost: $2800"] + # end # end test + # end # end #self.print_list + # + # describe 'self.on_date' do + # it 'returns a list of reservations for a specific date' do + # Hotel::Reservation.on_date(Date.new(2018, 1, 17)).must_equal [kitten_expo] + # end # end test + # end # end #self.on_date + # + # describe 'self.available_rooms' do + # it 'excludes reservations outside a given date range' do + # given_range = Hotel::DateRange.new(Date.new(2017, 01, 01), Date.new(2017, 12, 31)) + # + # Hotel::Reservation.available_rooms(given_range).map do |room| + # room.room_number + # end.wont_include 13 + # end # end test + # end # end #self.available_rooms +end diff --git a/specs/reservation_spec.rb b/specs/reservation_spec.rb new file mode 100644 index 000000000..d0f3792f7 --- /dev/null +++ b/specs/reservation_spec.rb @@ -0,0 +1,91 @@ +require_relative 'spec_helper' +# puppy_expo = Hotel::Reservation.new('Finn', Date.new(2017, 10, 13), Date.new(2017, 10, 31), Hotel::Room.find(13)) +# kitten_expo = Hotel::Reservation.new('Girlie', Date.new(2018, 1, 17), Date.new(2018, 1, 31), Hotel::Room.find(11)) + +describe 'Reservation' do + describe 'initialize' do + it 'creates a room instance with the dates, room, and rate' do + dates = Hotel::DateRange.new(Date.new(2017, 10, 13), Date.new(2017, 10, 31)) + honeymoon = Hotel::Reservation.new(dates, 13, 200) + + honeymoon.dates.check_in.must_equal Date.new(2017, 10, 13) + honeymoon.dates.check_out.must_equal Date.new(2017, 10, 31) + honeymoon.room.must_equal 13 + honeymoon.rate.must_equal 200 + end + + it 'passes in a DateRange object as the dates argument' do + dates = Hotel::DateRange.new(Date.new(2017, 10, 13), Date.new(2017, 10, 31)) + honeymoon = Hotel::Reservation.new(dates, 13, 200) + + honeymoon.dates.must_be_kind_of Hotel::DateRange + end + + it 'will not pass in anything but a DateRange object as the dates argument' do + dates = Hotel::DateRange.new(Date.new(2017, 10, 13), Date.new(2017, 10, 31)) + honeymoon = Hotel::Reservation.new(dates, 13, 200) + + honeymoon.dates.wont_be_kind_of Date + end + end # end initialize + + describe 'final_cost' do + it 'calculates the cost of the stay based on number of nights times the rate' do + dates = Hotel::DateRange.new(Date.new(2017, 10, 13), Date.new(2017, 10, 31)) + honeymoon = Hotel::Reservation.new(dates, 13, 200) + + honeymoon.final_cost.must_equal 3600 + end + end # end final_cost + + + # describe 'initialize' do + # it 'initializes with guest name, date range from DateRange, and room number from Room' do + # puppy_expo.guest_name.must_equal 'Finn' + # puppy_expo.dates.check_in.to_s.must_equal '2017-10-13' + # puppy_expo.dates.check_out.to_s.must_equal '2017-10-31' + # end # end test + # + # it 'raises an InvalidRoomError if room has already been booked' do + # proc{Hotel::Reservation.new('Suge', Date.new(2017, 10, 15), Date.new(2017, 10, 20), Hotel::Room.find(13))}.must_raise Hotel::InvalidRoomError + # end # end test + # + # it 'will not add invalid reservation to @@reservations' do + # number_of_reservations = Hotel::Reservation.reservations.length + # begin + # Hotel::Reservation.new('Suge', Date.new(2017, 10, 15), Date.new(2017, 10, 20), Hotel::Room.find(13)) + # rescue + # end + # + # Hotel::Reservation.reservations.length.must_equal number_of_reservations # makes sure number did not change! + # end # end test + # end # end #initialize + # + # describe 'self.reservations' do + # it 'calls the class variable @@reservations, which holds all instances of Reservation in an array' do + # Hotel::Reservation.reservations.must_equal [puppy_expo, kitten_expo] + # end # end test + # end # end #self.reservations + # + # describe 'self.print_list' do + # it 'returns list of all reservations' do + # Hotel::Reservation.print_list.must_equal ["Name: Finn\nCheck In: 2017-10-13\nCheck Out: 2017-10-31\nRoom Number: 13\nTotal Cost: $3600", "Name: Girlie\nCheck In: 2018-01-17\nCheck Out: 2018-01-31\nRoom Number: 11\nTotal Cost: $2800"] + # end # end test + # end # end #self.print_list + # + # describe 'self.on_date' do + # it 'returns a list of reservations for a specific date' do + # Hotel::Reservation.on_date(Date.new(2018, 1, 17)).must_equal [kitten_expo] + # end # end test + # end # end #self.on_date + # + # describe 'self.available_rooms' do + # it 'excludes reservations outside a given date range' do + # given_range = Hotel::DateRange.new(Date.new(2017, 01, 01), Date.new(2017, 12, 31)) + # + # Hotel::Reservation.available_rooms(given_range).map do |room| + # room.room_number + # end.wont_include 13 + # end # end test + # end # end #self.available_rooms +end # end of all Reservation tests diff --git a/specs/room_spec.rb b/specs/room_spec.rb new file mode 100644 index 000000000..ce21a095a --- /dev/null +++ b/specs/room_spec.rb @@ -0,0 +1,48 @@ +################################# +# decided I don't need this class +################################# + + +# require_relative '../specs/spec_helper' +# +# describe 'Room' do +# describe 'initialize' do +# it 'creates an instance of Room' do +# end # end test +# end # end #initialize +# +# describe 'self.all' do +# it "Returns an Array when Room.all is called" do +# Hotel::Room.all.must_be_kind_of Array +# end # end test +# +# it "Verifies the number of rooms is correct" do +# total_rooms = CSV.read("support/rooms.csv", 'r').length +# Hotel::Room.all.length.must_equal total_rooms +# end # end test +# +# it "Verifies everything in the Array is a Room" do +# Hotel::Room.all.each do |room| +# room.must_be_kind_of Hotel::Room +# end +# end # end test +# +# it "Matches the first and last room numbers with the CSV file" do +# Hotel::Room.all.first.room_number.must_equal 1 +# Hotel::Room.all.last.room_number.must_equal 20 +# end # end test +# end # end #self.all +# +# describe 'self.find(room_number)' do +# it "Can find the room 1 from the CSV" do +# Hotel::Room.find(1).room_number.must_equal Hotel::Room.all.first.room_number +# end +# +# it "Can find the last order from the CSV" do +# Hotel::Room.find(20).room_number.must_equal Hotel::Room.all.last.room_number +# end +# it 'raises an ArgumentError if room number does not exist' do +# proc{Hotel::Room.find(666)}.must_raise Hotel::InvalidRoomError +# end # end test +# end # end #self.find(room_number) +# end # end all Room tests diff --git a/specs/spec_helper.rb b/specs/spec_helper.rb new file mode 100644 index 000000000..7b67033f7 --- /dev/null +++ b/specs/spec_helper.rb @@ -0,0 +1,12 @@ +require 'simplecov' +SimpleCov.start + +require 'minitest/autorun' +require 'minitest/reporters' +require 'minitest/skip_dsl' +require_relative '../lib/hotel' +require_relative '../lib/date_range' +require_relative '../lib/reservation' +# require_relative '../lib/room' + +Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new diff --git a/support/rooms.csv b/support/rooms.csv new file mode 100644 index 000000000..0ff3bbb9c --- /dev/null +++ b/support/rooms.csv @@ -0,0 +1,20 @@ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20