-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zion Mekonnen #613
base: main
Are you sure you want to change the base?
Zion Mekonnen #613
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ GEM | |
PLATFORMS | ||
arm64-darwin-20 | ||
arm64-darwin-21 | ||
arm64-darwin-24 | ||
|
||
DEPENDENCIES | ||
faraday | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,40 @@ | ||
class Facility | ||
attr_reader :name, :address, :phone, :services | ||
attr_reader :name, :address, :phone, :services, :registered_vehicles, :plate_type, :registration_cost, :collected_fees | ||
|
||
def initialize(name, address, phone) | ||
@name = name | ||
@address = address | ||
@phone = phone | ||
def initialize (facility_hash) | ||
@name = facility_hash[:name] | ||
@address = facility_hash[:address] | ||
@phone = facility_hash[:phone] | ||
@services = [] | ||
@registered_vehicles = [] | ||
@collected_fees = 0 | ||
end | ||
|
||
def add_services(service) | ||
def add_service(service) | ||
@services << service | ||
end | ||
|
||
|
||
|
||
|
||
def register_vehicle(vehicle) | ||
binding.pry | ||
if vehicle.antique? | ||
vehicle.update_plate_type(:antique) | ||
@collected_fees += 25 | ||
elsif vehicle.electric_vehicle? | ||
vehicle.update_plate_type(:ev) | ||
@collected_fees += 200 | ||
else | ||
vehicle.update_plate_type(:regular) | ||
@collected_fees += 100 | ||
|
||
end | ||
binding.pry | ||
@registration_date = Date.today | ||
|
||
@registered_vehicles << vehicle | ||
end | ||
|
||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
class Registrant | ||
attr_reader :name, :age, :permit, :license_data | ||
|
||
def initialize(name, age, permit = false) | ||
@name = name | ||
@age = age | ||
@permit = permit | ||
@license_data = {:written=>false, :license=>false, :renewed=>false} | ||
end | ||
|
||
def permit? | ||
@permit | ||
end | ||
|
||
def earn_permit | ||
@permit = true | ||
end | ||
|
||
end | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
require 'spec_helper' | ||
require 'RSpec' | ||
|
||
RSpec.describe Facility do | ||
it 'exists' do | ||
facility_1 = Facility.new({name: 'DMV Tremont Branch', address: '2855 Tremont Place Suite 118 Denver CO 80205', phone: '(720) 865-4600'}) | ||
facility_2 = Facility.new({name: 'DMV Northeast Branch', address: '4685 Peoria Street Suite 101 Denver CO 80239', phone: '(720) 865-4600'}) | ||
|
||
expect(facility_1).to be_an_instance_of(Facility) | ||
expect(facility_2).to be_an_instance_of(Facility) | ||
end | ||
|
||
describe Vehicle do | ||
it 'exists' do | ||
cruz = Vehicle.new({vin: '123456789abcdefgh', year: 2012, make: 'Chevrolet', model: 'Cruz', engine: :ice}) | ||
bolt = Vehicle.new({vin: '987654321abcdefgh', year: 2019, make: 'Chevrolet', model: 'Bolt', engine: :ev}) | ||
camaro = Vehicle.new({vin: '1a2b3c4d5e6f', year: 1969, make: 'Chevrolet', model: 'Camaro', engine: :ice}) | ||
|
||
expect(cruz).to be_an_instance_of(Vehicle) | ||
expect(bolt).to be_an_instance_of(Vehicle) | ||
expect(camaro).to be_an_instance_of(Vehicle) | ||
end | ||
end | ||
|
||
# it "adds new service" do | ||
# facility_1 = Facility.new({name: 'DMV Tremont Branch', address: '2855 Tremont Place Suite 118 Denver CO 80205', phone: '(720) 865-4600'}) | ||
# facility_1.add_service('Vehicle Registration') | ||
|
||
# expect(facility_1.services).to include('Vehicle Registration') | ||
# end | ||
|
||
# it 'returns nil for cruz registration date' do | ||
# cruz = Vehicle.new({vin: '123456789abcdefgh', year: 2012, make: 'Chevrolet', model: 'Cruz', engine: :ice}) | ||
|
||
# expect(cruz.registration_date).to eq(nil) | ||
#end | ||
|
||
# it 'returns [] for registered vehicles' do | ||
# facility_1 = Facility.new({name: 'DMV Tremont Branch', address: '2855 Tremont Place Suite 118 Denver CO 80205', phone: '(720) 865-4600'}) | ||
|
||
# expect(facility_1.registered_vehicles).to eq([]) | ||
|
||
# end | ||
|
||
# it 'returns [] for collected fees' do | ||
# facility_1 = Facility.new({name: 'DMV Tremont Branch', address: '2855 Tremont Place Suite 118 Denver CO 80205', phone: '(720) 865-4600'}) | ||
|
||
# expect(facility_1.collected_fees).to eq(0) | ||
|
||
# end | ||
|
||
# it 'registers a vehicle' do | ||
# facility_1 = Facility.new({name: 'DMV Tremont Branch', address: '2855 Tremont Place Suite 118 Denver CO 80205', phone: '(720) 865-4600'}) | ||
# cruz = Vehicle.new({vin: '123456789abcdefgh', year: 2012, make: 'Chevrolet', model: 'Cruz', engine: :ice}) | ||
|
||
# expect(facility_1.register_vehicle(cruz)).to include(cruz) | ||
#end | ||
it 'returns cruz registration date' do | ||
facility_1 = Facility.new({name: 'DMV Tremont Branch', address: '2855 Tremont Place Suite 118 Denver CO 80205', phone: '(720) 865-4600'}) | ||
cruz = Vehicle.new({vin: '123456789abcdefgh', year: 2012, make: 'Chevrolet', model: 'Cruz', engine: :ice}) | ||
|
||
facility_1.register_vehicle(cruz) | ||
|
||
|
||
expect(cruz.registration_date).to eq(Date.today) | ||
end | ||
|
||
it "return plate type for cruz" do | ||
facility_1 = Facility.new({name: 'DMV Tremont Branch', address: '2855 Tremont Place Suite 118 Denver CO 80205', phone: '(720) 865-4600'}) | ||
cruz = Vehicle.new({vin: '123456789abcdefgh', year: 2012, make: 'Chevrolet', model: 'Cruz', engine: :ice}) | ||
|
||
facility_1.register_vehicle(cruz) | ||
|
||
expect(cruz.plate_type).to eq(:regular) | ||
end | ||
|
||
it 'a vehicle has been registered' do | ||
facility_1 = Facility.new({name: 'DMV Tremont Branch', address: '2855 Tremont Place Suite 118 Denver CO 80205', phone: '(720) 865-4600'}) | ||
cruz = Vehicle.new({vin: '123456789abcdefgh', year: 2012, make: 'Chevrolet', model: 'Cruz', engine: :ice}) | ||
|
||
facility_1.register_vehicle(cruz) | ||
expect(facility_1.registered_vehicles).to include(cruz) | ||
|
||
end | ||
|
||
it "updates collected fees when vehicle is registered" do | ||
facility_1 = Facility.new({name: 'DMV Tremont Branch', address: '2855 Tremont Place Suite 118 Denver CO 80205', phone: '(720) 865-4600'}) | ||
cruz = Vehicle.new({vin: '123456789abcdefgh', year: 2012, make: 'Chevrolet', model: 'Cruz', engine: :ice}) | ||
|
||
facility_1.register_vehicle(cruz) | ||
expect(facility_1.collected_fees).to eq(100) | ||
end | ||
|
||
|
||
|
||
|
||
|
||
|
||
end | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require './lib/registrant' | ||
require 'spec_helper' | ||
|
||
RSpec.describe Registrant do | ||
it "exists" do | ||
registrant_1 = Registrant.new('Bruce', 18, true) | ||
registrant_2 = Registrant.new('Penny', 15) | ||
|
||
expect(registrant_1).to be_an_instance_of(Registrant) | ||
expect(registrant_2).to be_an_instance_of(Registrant) | ||
end | ||
|
||
it 'returns attributes registrant 1' do | ||
registrant_1 = Registrant.new('Bruce', 18, true) | ||
|
||
expect(registrant_1.name).to eq("Bruce") | ||
expect(registrant_1.age).to eq(18) | ||
expect(registrant_1.permit?).to eq(true) | ||
expect(registrant_1.license_data).to eq({:written=>false, :license=>false, :renewed=>false}) | ||
end | ||
|
||
it 'returns attributes registrant 2' do | ||
registrant_2 = Registrant.new('Penny', 15) | ||
|
||
expect(registrant_2.name).to eq("Penny") | ||
expect(registrant_2.age).to eq(15) | ||
expect(registrant_2.license_data).to eq({:written=>false, :license=>false, :renewed=>false}) | ||
end | ||
|
||
it "returns if permit is earned" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a great test! |
||
registrant_1 = Registrant.new('Bruce', 18, true) | ||
registrant_2 = Registrant.new('Penny', 15) | ||
|
||
expect(registrant_2.permit?).to eq(false) | ||
registrant_1.earn_permit | ||
expect(registrant_1.permit?).to eq(true) | ||
|
||
end | ||
|
||
end | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
require './lib/facility' | ||
require './lib/vehicle' | ||
require './lib/dmv_data_service' | ||
require './lib/registrant' |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,4 +33,11 @@ | |
expect(@camaro.electric_vehicle?).to eq(false) | ||
end | ||
end | ||
it 'returns nil for cruz registration date' do | ||
cruz = Vehicle.new({vin: '123456789abcdefgh', year: 2012, make: 'Chevrolet', model: 'Cruz', engine: :ice}) | ||
|
||
expect(cruz.registration_date).to eq(nil) | ||
end | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You want to add tests for any methods that you create. It looks like we are missing tests for |
||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure you name your attr_readers with the same name as your instance variable that it is reading. In this case, it should be :registration_date