Skip to content

Commit

Permalink
Merge branches 'AddUnitTests' and 'AddUnitTests' of https://github.co…
Browse files Browse the repository at this point in the history
  • Loading branch information
GeekyHacks committed Oct 27, 2023
2 parents 2c0f1c6 + f2c2217 commit 401973e
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions spec/rental_spec.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
require './rental'
require './book'
require './person'

describe Rental do
let(:book) { double('Book', rentals: []) }
let(:person) { double('Person', rentals: []) }
let(:book) { Book.new('Book Title', 'Author') }
let(:person) { Person.new(25, 'John Doe') }

subject(:rental) { described_class.new('2023-10-26', book, person) }

it { is_expected.to have_attributes(date: '2023-10-26', book: book, person: person) }

it 'associates the rental with the book and person' do
expect(book.rentals).to be_empty
expect(person.rentals).to be_empty

rental

expect(book.rentals).to contain_exactly(rental)
expect(person.rentals).to contain_exactly(rental)
expect(book.rentals).to include(rental)
expect(person.rentals).to include(rental)
end
end

0 comments on commit 401973e

Please sign in to comment.