-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b4df7a2
commit 9102f48
Showing
9 changed files
with
87 additions
and
16 deletions.
There are no files selected for viewing
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 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 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require './classes/decorator' | ||
|
||
RSpec.describe Decorator do | ||
let(:nameable) { instance_double('Nameable', correct_name: 'Original Name') } | ||
subject { described_class.new(nameable) } | ||
|
||
describe '#correct_name' do | ||
it 'delegates to the correct_name method of the underlying nameable object' do | ||
expect(subject.correct_name).to eq('Original Name') | ||
end | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require 'rspec' | ||
require './classes/nameable' | ||
|
||
describe Nameable do | ||
let(:nameable_instance) { Nameable.new } | ||
|
||
describe '#correct_name' do | ||
it 'raises NotImplementedError' do | ||
expect { nameable_instance.correct_name }.to raise_error(NotImplementedError, /#{__method__}/) | ||
end | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,25 @@ | ||
require 'rspec' | ||
require 'json' | ||
require './classes/book' | ||
require './classes/teacher' | ||
require './classes/rental' | ||
|
||
describe Book do | ||
context 'Given a Book named The Sphere by Michael Crichton' do | ||
before :each do | ||
@person = Person.new(age: 24, name: 'Santiago') | ||
@person = Teacher.new(specialization: 'Mathematics', age: 52, name: 'Lilsnow', parent_permission: true) | ||
@book = Book.new('Sphere', 'Michael Crichton') | ||
end | ||
|
||
it '@rental should be instance of Rental' do | ||
it 'to_json should return a valid JSON representation of the rental' do | ||
rental = Rental.new('2020-10-23', @book, @person) | ||
expect(rental).to be_an_instance_of(Rental) | ||
json_data = JSON.parse(rental.to_json) | ||
|
||
expect(json_data['date']).to eq('2020-10-23') | ||
expect(json_data['book']['title']).to eq('Sphere') | ||
expect(json_data['book']['author']).to eq('Michael Crichton') | ||
expect(json_data['person']['age']).to eq(52) | ||
expect(json_data['person']['name']).to eq('Lilsnow') | ||
end | ||
end | ||
end |
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 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