From a71e67154553b57a653ec7cc0155248867d863ea Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Thu, 12 Dec 2024 13:24:37 -0700 Subject: [PATCH 01/34] initial commit --- Gemfile.lock | 1 + lib/dmv.rb | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index d273a79f9..4f65a6ed3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -29,6 +29,7 @@ GEM PLATFORMS arm64-darwin-20 arm64-darwin-21 + universal-darwin-24 DEPENDENCIES faraday diff --git a/lib/dmv.rb b/lib/dmv.rb index f9e59bdf3..8940d0456 100644 --- a/lib/dmv.rb +++ b/lib/dmv.rb @@ -1,6 +1,6 @@ class Dmv - - def initialize +attr_reader :facilities + def initialize(facilities) @facilities = [] end From 33eb0577bb9055d8de20f60a3164294ddde59121 Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Thu, 12 Dec 2024 13:57:17 -0700 Subject: [PATCH 02/34] 3 failures left iteration 1 --- lib/dmv.rb | 4 +++- lib/facility.rb | 11 ++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/dmv.rb b/lib/dmv.rb index 8940d0456..cecbf862e 100644 --- a/lib/dmv.rb +++ b/lib/dmv.rb @@ -1,6 +1,6 @@ class Dmv attr_reader :facilities - def initialize(facilities) + def initialize @facilities = [] end @@ -13,4 +13,6 @@ def facilities_offering_service(service) facility.services.include?(service) end end + + end diff --git a/lib/facility.rb b/lib/facility.rb index a65757687..14fc03dc8 100644 --- a/lib/facility.rb +++ b/lib/facility.rb @@ -1,14 +1,15 @@ class Facility attr_reader :name, :address, :phone, :services - def initialize(name, address, phone) - @name = name - @address = address - @phone = phone + def initialize(facility_details) + facility_details = Hash.new + @name = facility_details[:name] + @address = facility_details[:address] + @phone = facility_details[:phone] @services = [] end - def add_services(service) + def add_service(service) @services << service end end From 4c50e162c2f51098547a3cbd5b15e2ff65ad24e8 Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Thu, 12 Dec 2024 14:28:29 -0700 Subject: [PATCH 03/34] adding registrant class --- lib/dmv.rb | 2 +- lib/facility.rb | 3 ++- lib/registrant.rb | 21 +++++++++++++++++++++ lib/vehicle.rb | 4 +++- spec/registrant_spec.rb | 0 5 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 lib/registrant.rb create mode 100644 spec/registrant_spec.rb diff --git a/lib/dmv.rb b/lib/dmv.rb index cecbf862e..a5da90e61 100644 --- a/lib/dmv.rb +++ b/lib/dmv.rb @@ -9,7 +9,7 @@ def add_facility(facility) end def facilities_offering_service(service) - @facilities.find do |facility| + @facilities.find_all do |facility| facility.services.include?(service) end end diff --git a/lib/facility.rb b/lib/facility.rb index 14fc03dc8..d0ce5e8d8 100644 --- a/lib/facility.rb +++ b/lib/facility.rb @@ -2,7 +2,7 @@ class Facility attr_reader :name, :address, :phone, :services def initialize(facility_details) - facility_details = Hash.new + @name = facility_details[:name] @address = facility_details[:address] @phone = facility_details[:phone] @@ -10,6 +10,7 @@ def initialize(facility_details) end def add_service(service) + @services << service end end diff --git a/lib/registrant.rb b/lib/registrant.rb new file mode 100644 index 000000000..b5c8399c2 --- /dev/null +++ b/lib/registrant.rb @@ -0,0 +1,21 @@ + + +class Registrant + + attr_reader :name, + :age, + :permit, + :license_data + + def initialize(name, age, permit = false) + @name = name + @age = age + @permit = permit + end + + def permit? + if @permit? + return true + end + end +end diff --git a/lib/vehicle.rb b/lib/vehicle.rb index 49ae83672..fe6a96df1 100644 --- a/lib/vehicle.rb +++ b/lib/vehicle.rb @@ -5,7 +5,8 @@ class Vehicle :year, :make, :model, - :engine + :engine, + :registration_date def initialize(vehicle_details) @vin = vehicle_details[:vin] @@ -13,6 +14,7 @@ def initialize(vehicle_details) @make = vehicle_details[:make] @model = vehicle_details[:model] @engine = vehicle_details[:engine] + end def antique? diff --git a/spec/registrant_spec.rb b/spec/registrant_spec.rb new file mode 100644 index 000000000..e69de29bb From ed95d4118597f0c88f5c3647ef76de2f55a1a2ec Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Thu, 12 Dec 2024 14:41:07 -0700 Subject: [PATCH 04/34] new branch git push git status --- lib/registrant.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/registrant.rb b/lib/registrant.rb index b5c8399c2..6d532a9ba 100644 --- a/lib/registrant.rb +++ b/lib/registrant.rb @@ -19,3 +19,4 @@ def permit? end end end +### \ No newline at end of file From e71198b125fc75e21a2d3676ef7d2f4f7f1ab38d Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Thu, 12 Dec 2024 14:53:27 -0700 Subject: [PATCH 05/34] creating registrant spec --- spec/registrant_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/registrant_spec.rb b/spec/registrant_spec.rb index e69de29bb..2973d3ed6 100644 --- a/spec/registrant_spec.rb +++ b/spec/registrant_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper' + +Rspec.describe Registrant do + before(:each) do + registrant_1 = Registrant.new('Bruce', 18, true ) + registrant_2 = Registrant.new('Penny', 15 ) + end + + it 'can initialize' do + expect(registrant_1).to be_an_instance_of(Registrant) + expect(registrant_2).to be_an_instance_of(Registrant) + end + + it 'has a name' do + expect(registrant_1.name).to eq('Bruce') + expect(registrant_2.name).to eq('Penny') +end From a186a9b8034b526217fb0b02f69879bebffb8819 Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Thu, 12 Dec 2024 15:04:23 -0700 Subject: [PATCH 06/34] no error in spec --- lib/registrant.rb | 8 +++++--- spec/registrant_spec.rb | 27 ++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/lib/registrant.rb b/lib/registrant.rb index 6d532a9ba..f98b1171c 100644 --- a/lib/registrant.rb +++ b/lib/registrant.rb @@ -14,9 +14,11 @@ def initialize(name, age, permit = false) end def permit? - if @permit? - return true - end + @permit + end + + def license_data end end + ### \ No newline at end of file diff --git a/spec/registrant_spec.rb b/spec/registrant_spec.rb index 2973d3ed6..0598ac710 100644 --- a/spec/registrant_spec.rb +++ b/spec/registrant_spec.rb @@ -1,17 +1,42 @@ require 'spec_helper' +require './lib/registrant' -Rspec.describe Registrant do +RSpec.describe Registrant do before(:each) do registrant_1 = Registrant.new('Bruce', 18, true ) registrant_2 = Registrant.new('Penny', 15 ) end + it 'can initialize' 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 'has a name' do + registrant_1 = Registrant.new('Bruce', 18, true ) + registrant_2 = Registrant.new('Penny', 15 ) + expect(registrant_1.name).to eq('Bruce') expect(registrant_2.name).to eq('Penny') + end + + it 'has an age' do + registrant_1 = Registrant.new('Bruce', 18, true ) + registrant_2 = Registrant.new('Penny', 15 ) + + expect(registrant_1.age).to eq(18) + expect(registrant_2.age).to eq(15) + end + + it 'has a permit' do + registrant_1 = Registrant.new('Bruce', 18, true ) + registrant_2 = Registrant.new('Penny', 15 ) + + expect(registrant_1.permit?).to eq(true) + expect(registrant_2.permit?).to eq(false) + end end From 8bb800e89c489c1fd56a891f1755f959f64a3122 Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Thu, 12 Dec 2024 15:36:54 -0700 Subject: [PATCH 07/34] iteration 1 done, rspec file complete --- lib/registrant.rb | 10 +++++++--- spec/registrant_spec.rb | 16 +++++++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/registrant.rb b/lib/registrant.rb index f98b1171c..05b898f4d 100644 --- a/lib/registrant.rb +++ b/lib/registrant.rb @@ -4,21 +4,25 @@ 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 license_data + def earn_permit + @permit = true end end -### \ No newline at end of file diff --git a/spec/registrant_spec.rb b/spec/registrant_spec.rb index 0598ac710..f799de793 100644 --- a/spec/registrant_spec.rb +++ b/spec/registrant_spec.rb @@ -7,7 +7,6 @@ registrant_2 = Registrant.new('Penny', 15 ) end - it 'can initialize' do registrant_1 = Registrant.new('Bruce', 18, true ) registrant_2 = Registrant.new('Penny', 15 ) @@ -39,4 +38,19 @@ expect(registrant_1.permit?).to eq(true) expect(registrant_2.permit?).to eq(false) end + + it 'has license data' do + registrant_1 = Registrant.new('Bruce', 18, true ) + registrant_2 = Registrant.new('Penny', 15 ) + + expect(registrant_1.license_data).to eq({:written=>false, :license=>false, :renewed=>false}) + expect(registrant_2.license_data).to eq({:written=>false, :license=>false, :renewed=>false}) + end + + it 'has earned permit' do + registrant_1 = Registrant.new('Bruce', 18, true ) + registrant_2 = Registrant.new('Penny', 15 ) + + expect(registrant_2.earn_permit).to eq(true) + end end From d1cd4be50cd3dac21b35f485cbf7ae7483d7b475 Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Thu, 12 Dec 2024 15:45:03 -0700 Subject: [PATCH 08/34] first branch 2 commit --- lib/registrant.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/registrant.rb b/lib/registrant.rb index 05b898f4d..808766e5c 100644 --- a/lib/registrant.rb +++ b/lib/registrant.rb @@ -26,3 +26,4 @@ def earn_permit end end +#branch 2! \ No newline at end of file From 4f7b7796abb5d38b91c0345d5237c57850ff9eb5 Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Fri, 13 Dec 2024 08:39:48 -0700 Subject: [PATCH 09/34] register vehicle method --- lib/facility.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/facility.rb b/lib/facility.rb index d0ce5e8d8..72b82a779 100644 --- a/lib/facility.rb +++ b/lib/facility.rb @@ -7,10 +7,24 @@ def initialize(facility_details) @address = facility_details[:address] @phone = facility_details[:phone] @services = [] + @registered_vehicles = [] + @collected_fees = 0 end def add_service(service) @services << service end + + def register_vehicle(vehicle) + if vehicle.antique? + @collected_fees += 25 + @registered_vehicles << vehicle + elsif vehicle.engine == 'ev' + @collected_fees += 200 + @registered_vehicles << vehicle + else + @collected_fees += 100 + @registered_vehicles << vehicle + end end From dc95fb8b3291aeddd4701196772b586da0c18baa Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Fri, 13 Dec 2024 08:48:15 -0700 Subject: [PATCH 10/34] adding plate type to vehicle class --- lib/vehicle.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/vehicle.rb b/lib/vehicle.rb index fe6a96df1..36a68c6f5 100644 --- a/lib/vehicle.rb +++ b/lib/vehicle.rb @@ -7,6 +7,7 @@ class Vehicle :model, :engine, :registration_date + :plate_type def initialize(vehicle_details) @vin = vehicle_details[:vin] @@ -14,7 +15,7 @@ def initialize(vehicle_details) @make = vehicle_details[:make] @model = vehicle_details[:model] @engine = vehicle_details[:engine] - + @plate_type = vehicle_details[:plate_type] end def antique? From e351fe13f76fdf89c147280b2f2c8ef7c640ae46 Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Fri, 13 Dec 2024 13:28:12 -0700 Subject: [PATCH 11/34] registered vehicles and collected fees methods, plus spec testing --- lib/facility.rb | 11 ++++++++++- spec/facility_spec.rb | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/facility.rb b/lib/facility.rb index 72b82a779..db8ed2bdf 100644 --- a/lib/facility.rb +++ b/lib/facility.rb @@ -16,15 +16,24 @@ def add_service(service) @services << service end + def registered_vehicles + @registered_vehicles + end + + def collected_fees + @collected_fees + end + def register_vehicle(vehicle) if vehicle.antique? @collected_fees += 25 @registered_vehicles << vehicle - elsif vehicle.engine == 'ev' + elsif vehicle.engine == :ev @collected_fees += 200 @registered_vehicles << vehicle else @collected_fees += 100 @registered_vehicles << vehicle end + end end diff --git a/spec/facility_spec.rb b/spec/facility_spec.rb index c0f2f1233..373811a40 100644 --- a/spec/facility_spec.rb +++ b/spec/facility_spec.rb @@ -23,4 +23,12 @@ expect(@facility.services).to eq(['New Drivers License', 'Renew Drivers License', 'Vehicle Registration']) end end + + describe '#register vehicle' do + it 'can register a vehicle' do + cruz = Vehicle.new({vin: '123456789abcdefgh', year: 2012, make: 'Chevrolet', model: 'Cruz', engine: :ice} ) + @facility.register_vehicle(cruz) + expect(@facility.registered_vehicles).to eq([cruz]) + end + end end From 6b65c7765d138ef65a72dd279cfcdbe7ad6a22f2 Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Fri, 13 Dec 2024 13:37:48 -0700 Subject: [PATCH 12/34] rspec tests for registered vehicles and collected fees --- spec/facility_spec.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/spec/facility_spec.rb b/spec/facility_spec.rb index 373811a40..7c1cbcd6a 100644 --- a/spec/facility_spec.rb +++ b/spec/facility_spec.rb @@ -31,4 +31,27 @@ expect(@facility.registered_vehicles).to eq([cruz]) end end + + describe '#check registered vehicles' do + it 'has an array of vehicles' 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} ) + @facility.register_vehicle(cruz) + @facility.register_vehicle(bolt) + @facility.register_vehicle(camaro) + expect(@facility.registered_vehicles).to eq([cruz, bolt, camaro]) + end + end + describe '#check fees' do + it 'has a value of collected fees' 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} ) + @facility.register_vehicle(cruz) + @facility.register_vehicle(bolt) + @facility.register_vehicle(camaro) + expect(@facility.collected_fees).to eq(325) + end + end end From 85e71a92a5ba18c112ace5342da27e3e459ab8ef Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Sat, 14 Dec 2024 19:21:43 -0700 Subject: [PATCH 13/34] more plate_type work, trying hashes to no avail --- lib/facility.rb | 17 +++++++++++++++++ lib/registrant.rb | 3 +++ lib/vehicle.rb | 9 +++++++-- spec/facility_spec.rb | 20 +++++++++++++++++++- 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/lib/facility.rb b/lib/facility.rb index db8ed2bdf..58c8b54b5 100644 --- a/lib/facility.rb +++ b/lib/facility.rb @@ -9,6 +9,7 @@ def initialize(facility_details) @services = [] @registered_vehicles = [] @collected_fees = 0 + end def add_service(service) @@ -25,15 +26,31 @@ def collected_fees end def register_vehicle(vehicle) + if vehicle.antique? @collected_fees += 25 @registered_vehicles << vehicle + elsif vehicle.engine == :ev @collected_fees += 200 @registered_vehicles << vehicle + else @collected_fees += 100 @registered_vehicles << vehicle + end end + + def plate_type(vehicle) + if vehicle.antique? + @plate_type << :antique + + elsif vehicle.electric_vehicle? + @plate_type << :ev + + else + @plate_type << :regular + end + end end diff --git a/lib/registrant.rb b/lib/registrant.rb index 808766e5c..9da49c1a0 100644 --- a/lib/registrant.rb +++ b/lib/registrant.rb @@ -21,6 +21,9 @@ def permit? @permit end + def administer_written_test(registrant) + + def earn_permit @permit = true end diff --git a/lib/vehicle.rb b/lib/vehicle.rb index 36a68c6f5..e5790e1a5 100644 --- a/lib/vehicle.rb +++ b/lib/vehicle.rb @@ -7,7 +7,8 @@ class Vehicle :model, :engine, :registration_date - :plate_type + + def initialize(vehicle_details) @vin = vehicle_details[:vin] @@ -15,14 +16,18 @@ def initialize(vehicle_details) @make = vehicle_details[:make] @model = vehicle_details[:model] @engine = vehicle_details[:engine] - @plate_type = vehicle_details[:plate_type] + @plate_type = {} end def antique? Date.today.year - @year > 25 end + def electric_vehicle? @engine == :ev end + + + end diff --git a/spec/facility_spec.rb b/spec/facility_spec.rb index 7c1cbcd6a..2eee78de5 100644 --- a/spec/facility_spec.rb +++ b/spec/facility_spec.rb @@ -43,6 +43,7 @@ expect(@facility.registered_vehicles).to eq([cruz, bolt, camaro]) end end + describe '#check fees' do it 'has a value of collected fees' do cruz = Vehicle.new({vin: '123456789abcdefgh', year: 2012, make: 'Chevrolet', model: 'Cruz', engine: :ice} ) @@ -54,4 +55,21 @@ expect(@facility.collected_fees).to eq(325) end end -end + + describe "#has plate type" do + it 'checks the plate type' 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} ) + @facility.register_vehicle(cruz) + @facility.register_vehicle(bolt) + @facility.register_vehicle(camaro) + @facility.plate_type(camaro) + @facility.plate_type(cruz) + @facility.plate_type(bolt) + expect(camaro.plate_type).to eq ([:antique]) + expect(cruz.plate_type).to eq ([:regular]) + expect(bolt.plate_type).to eq ([:ev]) + end + end +end \ No newline at end of file From 87ad2fb36ee0d78070ad98fd53e5de10df3db9a0 Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Sat, 14 Dec 2024 19:32:34 -0700 Subject: [PATCH 14/34] ditched hashes. modifying the plate type in the register vehicle method --- lib/facility.rb | 22 ++++++++++++---------- lib/registrant.rb | 3 ++- lib/vehicle.rb | 5 ++--- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/facility.rb b/lib/facility.rb index 58c8b54b5..cfa5ba68b 100644 --- a/lib/facility.rb +++ b/lib/facility.rb @@ -30,27 +30,29 @@ def register_vehicle(vehicle) if vehicle.antique? @collected_fees += 25 @registered_vehicles << vehicle - + vehicle.plate_type = ":antique" elsif vehicle.engine == :ev @collected_fees += 200 @registered_vehicles << vehicle + vehicle.plate_type = ":ev" else @collected_fees += 100 @registered_vehicles << vehicle + vehicle.plate_type = ":regular" end end - def plate_type(vehicle) - if vehicle.antique? - @plate_type << :antique + # def plate_type(vehicle) + # if vehicle.antique? + # @plate_type << :antique - elsif vehicle.electric_vehicle? - @plate_type << :ev + # elsif vehicle.electric_vehicle? + # @plate_type << :ev - else - @plate_type << :regular - end - end + # else + # @plate_type << :regular + # end + # end end diff --git a/lib/registrant.rb b/lib/registrant.rb index 9da49c1a0..aea3c8336 100644 --- a/lib/registrant.rb +++ b/lib/registrant.rb @@ -22,7 +22,8 @@ def permit? end def administer_written_test(registrant) - + end + def earn_permit @permit = true diff --git a/lib/vehicle.rb b/lib/vehicle.rb index e5790e1a5..7fab161fe 100644 --- a/lib/vehicle.rb +++ b/lib/vehicle.rb @@ -6,8 +6,8 @@ class Vehicle :make, :model, :engine, - :registration_date - + :registration_date, + :plate_type def initialize(vehicle_details) @@ -16,7 +16,6 @@ def initialize(vehicle_details) @make = vehicle_details[:make] @model = vehicle_details[:model] @engine = vehicle_details[:engine] - @plate_type = {} end def antique? From c836229e7d79ff987ac1fd0cf1302239bdfcbe01 Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Sat, 14 Dec 2024 19:58:12 -0700 Subject: [PATCH 15/34] moved test to vehicle_spec. duh. --- lib/facility.rb | 17 +++-------------- lib/vehicle.rb | 17 ++++++++++++----- spec/facility_spec.rb | 17 +---------------- spec/vehicle_spec.rb | 14 ++++++++++++++ 4 files changed, 30 insertions(+), 35 deletions(-) diff --git a/lib/facility.rb b/lib/facility.rb index cfa5ba68b..ee64d9071 100644 --- a/lib/facility.rb +++ b/lib/facility.rb @@ -30,29 +30,18 @@ def register_vehicle(vehicle) if vehicle.antique? @collected_fees += 25 @registered_vehicles << vehicle - vehicle.plate_type = ":antique" + elsif vehicle.engine == :ev @collected_fees += 200 @registered_vehicles << vehicle - vehicle.plate_type = ":ev" + else @collected_fees += 100 @registered_vehicles << vehicle - vehicle.plate_type = ":regular" + end end - # def plate_type(vehicle) - # if vehicle.antique? - # @plate_type << :antique - - # elsif vehicle.electric_vehicle? - # @plate_type << :ev - - # else - # @plate_type << :regular - # end - # end end diff --git a/lib/vehicle.rb b/lib/vehicle.rb index 7fab161fe..6819cc511 100644 --- a/lib/vehicle.rb +++ b/lib/vehicle.rb @@ -6,8 +6,9 @@ class Vehicle :make, :model, :engine, - :registration_date, - :plate_type + :registration_date + + attr_accessor :plate_type def initialize(vehicle_details) @@ -21,12 +22,18 @@ def initialize(vehicle_details) def antique? Date.today.year - @year > 25 end - def electric_vehicle? @engine == :ev end - - + def plate_type + if antique? + :antique + elsif @engine == :ev + :ev + else + :regular + end + end end diff --git a/spec/facility_spec.rb b/spec/facility_spec.rb index 2eee78de5..5a07164e6 100644 --- a/spec/facility_spec.rb +++ b/spec/facility_spec.rb @@ -56,20 +56,5 @@ end end - describe "#has plate type" do - it 'checks the plate type' 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} ) - @facility.register_vehicle(cruz) - @facility.register_vehicle(bolt) - @facility.register_vehicle(camaro) - @facility.plate_type(camaro) - @facility.plate_type(cruz) - @facility.plate_type(bolt) - expect(camaro.plate_type).to eq ([:antique]) - expect(cruz.plate_type).to eq ([:regular]) - expect(bolt.plate_type).to eq ([:ev]) - end - end + end \ No newline at end of file diff --git a/spec/vehicle_spec.rb b/spec/vehicle_spec.rb index 5c7f01184..551e843c6 100644 --- a/spec/vehicle_spec.rb +++ b/spec/vehicle_spec.rb @@ -33,4 +33,18 @@ expect(@camaro.electric_vehicle?).to eq(false) end end + + describe "#has plate type" do + it 'checks the plate type' 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} ) + cruz.plate_type + bolt.plate_type + camaro.plate_type + expect(bolt.plate_type).to eq(:ev) + expect(cruz.plate_type).to eq(:regular) + expect(camaro.plate_type).to eq(:antique) + end +end end From a4f3a3011987df910c1596452b713fb173db46fa Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Sun, 15 Dec 2024 11:05:42 -0700 Subject: [PATCH 16/34] vehicle registration complete --- lib/facility.rb | 2 ++ lib/vehicle.rb | 8 ++++---- spec/facility_spec.rb | 1 - spec/vehicle_spec.rb | 40 +++++++++++++++++++++++++++++----------- 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/lib/facility.rb b/lib/facility.rb index ee64d9071..aa5c1bef8 100644 --- a/lib/facility.rb +++ b/lib/facility.rb @@ -26,6 +26,8 @@ def collected_fees end def register_vehicle(vehicle) + + vehicle.registration_date = Date.today.strftime("%m/%d/%Y") if vehicle.antique? @collected_fees += 25 diff --git a/lib/vehicle.rb b/lib/vehicle.rb index 6819cc511..d76e8463f 100644 --- a/lib/vehicle.rb +++ b/lib/vehicle.rb @@ -5,10 +5,9 @@ class Vehicle :year, :make, :model, - :engine, - :registration_date - - attr_accessor :plate_type + :engine + + attr_accessor :registration_date def initialize(vehicle_details) @@ -17,6 +16,7 @@ def initialize(vehicle_details) @make = vehicle_details[:make] @model = vehicle_details[:model] @engine = vehicle_details[:engine] + end def antique? diff --git a/spec/facility_spec.rb b/spec/facility_spec.rb index 5a07164e6..59210e67d 100644 --- a/spec/facility_spec.rb +++ b/spec/facility_spec.rb @@ -56,5 +56,4 @@ end end - end \ No newline at end of file diff --git a/spec/vehicle_spec.rb b/spec/vehicle_spec.rb index 551e843c6..1068bbae5 100644 --- a/spec/vehicle_spec.rb +++ b/spec/vehicle_spec.rb @@ -35,16 +35,34 @@ end describe "#has plate type" do - it 'checks the plate type' 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} ) - cruz.plate_type - bolt.plate_type - camaro.plate_type - expect(bolt.plate_type).to eq(:ev) - expect(cruz.plate_type).to eq(:regular) - expect(camaro.plate_type).to eq(:antique) + it 'checks the plate type' 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} ) + cruz.plate_type + bolt.plate_type + camaro.plate_type + + expect(bolt.plate_type).to eq(:ev) + expect(cruz.plate_type).to eq(:regular) + expect(camaro.plate_type).to eq(:antique) + end + end + + describe "#registration date" do + it 'has a registration date when registered' 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} ) + facility = Facility.new({name: 'DMV Tremont Branch', address: '2855 Tremont Place Suite 118 Denver CO 80205', phone: '(720) 865-4600'}) + facility.register_vehicle(cruz) + facility.register_vehicle(bolt) + facility.register_vehicle(camaro) + + expect(cruz.registration_date).to eq(Date.today.strftime("%m/%d/%Y")) + expect(bolt.registration_date).to eq(Date.today.strftime("%m/%d/%Y")) + expect(camaro.registration_date).to eq(Date.today.strftime("%m/%d/%Y")) + + end end -end end From e1812b2e71d132f737da4c1b90762e1e06bce3a8 Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Sun, 15 Dec 2024 11:27:34 -0700 Subject: [PATCH 17/34] can administer written test if included in services --- lib/facility.rb | 10 +++++++++- lib/registrant.rb | 3 --- spec/facility_spec.rb | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/lib/facility.rb b/lib/facility.rb index aa5c1bef8..d3f809243 100644 --- a/lib/facility.rb +++ b/lib/facility.rb @@ -26,7 +26,7 @@ def collected_fees end def register_vehicle(vehicle) - + vehicle.registration_date = Date.today.strftime("%m/%d/%Y") if vehicle.antique? @@ -46,4 +46,12 @@ def register_vehicle(vehicle) end end + def administer_written_test(registrant) + if @services.include?("Written Test") + registrant.license_data[:written] = true + else + false + end + end + end diff --git a/lib/registrant.rb b/lib/registrant.rb index aea3c8336..e1185d8f9 100644 --- a/lib/registrant.rb +++ b/lib/registrant.rb @@ -21,9 +21,6 @@ def permit? @permit end - def administer_written_test(registrant) - end - def earn_permit @permit = true diff --git a/spec/facility_spec.rb b/spec/facility_spec.rb index 59210e67d..602f4f501 100644 --- a/spec/facility_spec.rb +++ b/spec/facility_spec.rb @@ -56,4 +56,18 @@ end end + describe "#administer_written_test" do + it "sets written value to true in registrant license data" do + registrant_1 = Registrant.new('Bruce', 18, true ) + registrant_2 = Registrant.new('Penny', 15 ) + registrant_3 = Registrant.new('Tucker', 15 ) + 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'}) + + facility_1.add_service('Written Test') + facility_1.administer_written_test(registrant_1) + + expect(registrant_1.license_data[:written]).to eq(true) + end + end end \ No newline at end of file From af0412db3c280c672d98b031987871d8845fc00f Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Sun, 15 Dec 2024 11:31:33 -0700 Subject: [PATCH 18/34] can administer a road test too, and set the license value to true --- lib/facility.rb | 9 ++++++++- spec/facility_spec.rb | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/facility.rb b/lib/facility.rb index d3f809243..32eaf895e 100644 --- a/lib/facility.rb +++ b/lib/facility.rb @@ -42,7 +42,6 @@ def register_vehicle(vehicle) @collected_fees += 100 @registered_vehicles << vehicle - end end @@ -54,4 +53,12 @@ def administer_written_test(registrant) end end + def administer_road_test(registrant) + if @services.include?("Road Test") + registrant.license_data[:license] = true + else + false + end + end + end diff --git a/spec/facility_spec.rb b/spec/facility_spec.rb index 602f4f501..0207eca93 100644 --- a/spec/facility_spec.rb +++ b/spec/facility_spec.rb @@ -70,4 +70,20 @@ expect(registrant_1.license_data[:written]).to eq(true) end end + + describe "#administer_road_test" do + it "sets license value to true in registrant license data" do + registrant_1 = Registrant.new('Bruce', 18, true ) + registrant_2 = Registrant.new('Penny', 15 ) + registrant_3 = Registrant.new('Tucker', 15 ) + 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'}) + + facility_1.add_service('Road Test') + facility_1.administer_road_test(registrant_1) + + expect(registrant_1.license_data[:license]).to eq(true) + end +end + end \ No newline at end of file From c6ee68110355289b18ecb3c536fa0275745c7209 Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Sun, 15 Dec 2024 11:35:13 -0700 Subject: [PATCH 19/34] can renew a drivers license too --- lib/facility.rb | 9 +++++++++ spec/facility_spec.rb | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/lib/facility.rb b/lib/facility.rb index 32eaf895e..b1a5e49a0 100644 --- a/lib/facility.rb +++ b/lib/facility.rb @@ -61,4 +61,13 @@ def administer_road_test(registrant) end end + def renew_drivers_license(registrant) + if @services.include?("Renew License") + registrant.license_data[:renewed] = true + else + false + end + end + + end diff --git a/spec/facility_spec.rb b/spec/facility_spec.rb index 0207eca93..9235ea168 100644 --- a/spec/facility_spec.rb +++ b/spec/facility_spec.rb @@ -86,4 +86,20 @@ end end +describe "#renew_drivers_license" do + it "sets renewed value to true in registrant license data" do + registrant_1 = Registrant.new('Bruce', 18, true ) + registrant_2 = Registrant.new('Penny', 15 ) + registrant_3 = Registrant.new('Tucker', 15 ) + 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'}) + + facility_1.add_service('Renew License') + facility_1.renew_drivers_license(registrant_1) + + expect(registrant_1.license_data[:renewed]).to eq(true) + end +end + + end \ No newline at end of file From 80ab7618ff5f1311cc8fad64c3783294f940b5cd Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Sun, 15 Dec 2024 11:53:14 -0700 Subject: [PATCH 20/34] adding conditions to methods --- lib/facility.rb | 4 ++-- spec/facility_spec.rb | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/facility.rb b/lib/facility.rb index b1a5e49a0..361051902 100644 --- a/lib/facility.rb +++ b/lib/facility.rb @@ -46,7 +46,7 @@ def register_vehicle(vehicle) end def administer_written_test(registrant) - if @services.include?("Written Test") + if @services.include?("Written Test") && registrant.permit? == true registrant.license_data[:written] = true else false @@ -62,7 +62,7 @@ def administer_road_test(registrant) end def renew_drivers_license(registrant) - if @services.include?("Renew License") + if @services.include?("Renew License") && registrant.license_data[:license] == true registrant.license_data[:renewed] = true else false diff --git a/spec/facility_spec.rb b/spec/facility_spec.rb index 9235ea168..d6e22359b 100644 --- a/spec/facility_spec.rb +++ b/spec/facility_spec.rb @@ -79,7 +79,10 @@ 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'}) + facility_1.add_service('Written Test') facility_1.add_service('Road Test') + + facility_1.administer_written_test(registrant_1) facility_1.administer_road_test(registrant_1) expect(registrant_1.license_data[:license]).to eq(true) @@ -94,9 +97,12 @@ 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'}) + facility_1.add_service('Written Test') + facility_1.add_service('Road Test') facility_1.add_service('Renew License') - facility_1.renew_drivers_license(registrant_1) + facility_1.administer_road_test(registrant_1) + facility_1.renew_drivers_license(registrant_1) expect(registrant_1.license_data[:renewed]).to eq(true) end end From 33cc813ee6310c673895c0ae85005052502070b8 Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Sun, 15 Dec 2024 11:56:51 -0700 Subject: [PATCH 21/34] cleaning up, fixing tests, adding more conditionals to my if statements for services --- lib/facility.rb | 3 +-- spec/facility_spec.rb | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/facility.rb b/lib/facility.rb index 361051902..8a2b008c6 100644 --- a/lib/facility.rb +++ b/lib/facility.rb @@ -54,7 +54,7 @@ def administer_written_test(registrant) end def administer_road_test(registrant) - if @services.include?("Road Test") + if @services.include?("Road Test") && registrant.license_data[:written] == true registrant.license_data[:license] = true else false @@ -69,5 +69,4 @@ def renew_drivers_license(registrant) end end - end diff --git a/spec/facility_spec.rb b/spec/facility_spec.rb index d6e22359b..1b8b323d0 100644 --- a/spec/facility_spec.rb +++ b/spec/facility_spec.rb @@ -81,7 +81,7 @@ facility_1.add_service('Written Test') facility_1.add_service('Road Test') - + facility_1.administer_written_test(registrant_1) facility_1.administer_road_test(registrant_1) @@ -101,6 +101,7 @@ facility_1.add_service('Road Test') facility_1.add_service('Renew License') + facility_1.administer_written_test(registrant_1) facility_1.administer_road_test(registrant_1) facility_1.renew_drivers_license(registrant_1) expect(registrant_1.license_data[:renewed]).to eq(true) From 5fd1b5a6a40e3b93143fe7128a58210870b9d9cc Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Sun, 15 Dec 2024 12:28:33 -0700 Subject: [PATCH 22/34] created vehicle factory file and accompanying spec file. testing some stuff out --- lib/vehiclefactory.rb | 15 +++++++++++++++ spec/vehiclefactory_spec.rb | 10 ++++++++++ 2 files changed, 25 insertions(+) create mode 100644 lib/vehiclefactory.rb create mode 100644 spec/vehiclefactory_spec.rb diff --git a/lib/vehiclefactory.rb b/lib/vehiclefactory.rb new file mode 100644 index 000000000..9860418b1 --- /dev/null +++ b/lib/vehiclefactory.rb @@ -0,0 +1,15 @@ +require './lib/vehicle' +require './lib/dmv_data_service' + + +class Vehicle_factory + + def initialize(vehicle_factory) + @vehicle_factory = vehicle_factory + end + + def create_vehicles + vehicle = Vehicle.new(@wa_ev_registrations) + vehicle.vehicle_details[:engine] = :ev + end +end diff --git a/spec/vehiclefactory_spec.rb b/spec/vehiclefactory_spec.rb new file mode 100644 index 000000000..44d5315a1 --- /dev/null +++ b/spec/vehiclefactory_spec.rb @@ -0,0 +1,10 @@ +require 'spec_helper' + +RSpec.describe Vehicle_factory do + @vehicle_factory = Vehicle_factory.new(DmvDataService.new.wa_ev_registrations) + describe "#initialize" do + it 'can initialize' do + expect(@vehicle_factory).to be_an_instance_of(Vehicle_factory) + end + end +end \ No newline at end of file From 3df417d96e486c9478f030e7179ab5767b5f98ae Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Sun, 15 Dec 2024 13:00:11 -0700 Subject: [PATCH 23/34] forgot to require the vehiclefactory file, it can initialize now --- spec/vehiclefactory_spec.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/vehiclefactory_spec.rb b/spec/vehiclefactory_spec.rb index 44d5315a1..7f26ef856 100644 --- a/spec/vehiclefactory_spec.rb +++ b/spec/vehiclefactory_spec.rb @@ -1,10 +1,11 @@ require 'spec_helper' +require './lib/vehiclefactory' RSpec.describe Vehicle_factory do - @vehicle_factory = Vehicle_factory.new(DmvDataService.new.wa_ev_registrations) + vehicle_factory = Vehicle_factory.new(DmvDataService.new.wa_ev_registrations) describe "#initialize" do it 'can initialize' do - expect(@vehicle_factory).to be_an_instance_of(Vehicle_factory) + expect(vehicle_factory).to be_an_instance_of(Vehicle_factory) end end end \ No newline at end of file From 39c790902cfa8d510302cdd9fdd7e77113a6f9b9 Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Sun, 15 Dec 2024 13:31:05 -0700 Subject: [PATCH 24/34] broken create_vehicles method. testing how to incorporate API data --- lib/facility.rb | 2 -- lib/vehiclefactory.rb | 11 ++++++----- spec/vehiclefactory_spec.rb | 16 +++++++++++++--- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/lib/facility.rb b/lib/facility.rb index 8a2b008c6..b51edb356 100644 --- a/lib/facility.rb +++ b/lib/facility.rb @@ -26,7 +26,6 @@ def collected_fees end def register_vehicle(vehicle) - vehicle.registration_date = Date.today.strftime("%m/%d/%Y") if vehicle.antique? @@ -37,7 +36,6 @@ def register_vehicle(vehicle) @collected_fees += 200 @registered_vehicles << vehicle - else @collected_fees += 100 @registered_vehicles << vehicle diff --git a/lib/vehiclefactory.rb b/lib/vehiclefactory.rb index 9860418b1..d6729aaf2 100644 --- a/lib/vehiclefactory.rb +++ b/lib/vehiclefactory.rb @@ -4,12 +4,13 @@ class Vehicle_factory - def initialize(vehicle_factory) - @vehicle_factory = vehicle_factory + def initialize + end - def create_vehicles - vehicle = Vehicle.new(@wa_ev_registrations) - vehicle.vehicle_details[:engine] = :ev + def create_vehicles(vehicle) + vehicle = Vehicle.new({wa_ev_registrations}) + vehicle.vehicle_details << wa_ev_registrations end + end diff --git a/spec/vehiclefactory_spec.rb b/spec/vehiclefactory_spec.rb index 7f26ef856..cad59a8a2 100644 --- a/spec/vehiclefactory_spec.rb +++ b/spec/vehiclefactory_spec.rb @@ -2,10 +2,20 @@ require './lib/vehiclefactory' RSpec.describe Vehicle_factory do - vehicle_factory = Vehicle_factory.new(DmvDataService.new.wa_ev_registrations) describe "#initialize" do - it 'can initialize' do - expect(vehicle_factory).to be_an_instance_of(Vehicle_factory) + it 'can initialize' do + vehicle_factory = Vehicle_factory.new(DmvDataService.new.wa_ev_registrations) + expect(vehicle_factory).to be_an_instance_of(Vehicle_factory) + end + end + + describe "#create vehicles" do + it 'can create vehicles and populate with vehicle details' do + + factory = Vehicle_factory.new + wa_ev_registrations = DmvDataService.new.wa_ev_registrations + factory.create_vehicles(wa_ev_registrations) + expect(vehicle.vehicle_details).to eq(wa_ev_registrations) end end end \ No newline at end of file From 9efc2804459ceb26a7330db9e6223c0c75f197f9 Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Sun, 15 Dec 2024 15:02:51 -0700 Subject: [PATCH 25/34] progress on create vehicles method. Fix spec test next(oops) --- lib/facility.rb | 37 +++++++++++++------------------------ lib/vehiclefactory.rb | 13 +++++++------ spec/vehiclefactory_spec.rb | 4 ++-- 3 files changed, 22 insertions(+), 32 deletions(-) diff --git a/lib/facility.rb b/lib/facility.rb index b51edb356..2adb34154 100644 --- a/lib/facility.rb +++ b/lib/facility.rb @@ -2,18 +2,15 @@ class Facility attr_reader :name, :address, :phone, :services def initialize(facility_details) - @name = facility_details[:name] @address = facility_details[:address] @phone = facility_details[:phone] @services = [] @registered_vehicles = [] @collected_fees = 0 - end def add_service(service) - @services << service end @@ -27,44 +24,36 @@ def collected_fees def register_vehicle(vehicle) vehicle.registration_date = Date.today.strftime("%m/%d/%Y") - - if vehicle.antique? - @collected_fees += 25 - @registered_vehicles << vehicle - - elsif vehicle.engine == :ev - @collected_fees += 200 - @registered_vehicles << vehicle - - else - @collected_fees += 100 - @registered_vehicles << vehicle - - end + if vehicle.antique? + @collected_fees += 25 + @registered_vehicles << vehicle + elsif vehicle.engine == :ev + @collected_fees += 200 + @registered_vehicles << vehicle + else + @collected_fees += 100 + @registered_vehicles << vehicle + end end def administer_written_test(registrant) if @services.include?("Written Test") && registrant.permit? == true registrant.license_data[:written] = true - else - false end + return registrant.license_data[:written] end def administer_road_test(registrant) if @services.include?("Road Test") && registrant.license_data[:written] == true registrant.license_data[:license] = true - else - false end + return registrant.license_data[:license] end def renew_drivers_license(registrant) if @services.include?("Renew License") && registrant.license_data[:license] == true registrant.license_data[:renewed] = true - else - false end + return registrant.license_data[:renewed] end - end diff --git a/lib/vehiclefactory.rb b/lib/vehiclefactory.rb index d6729aaf2..8a7709928 100644 --- a/lib/vehiclefactory.rb +++ b/lib/vehiclefactory.rb @@ -3,14 +3,15 @@ class Vehicle_factory - +attr_accessor :cars def initialize - + @cars = [] end - def create_vehicles(vehicle) - vehicle = Vehicle.new({wa_ev_registrations}) - vehicle.vehicle_details << wa_ev_registrations + def create_vehicles(registrations) + registrations.each do |registration| + @cars << Vehicle.new(registration) + end + return @cars end - end diff --git a/spec/vehiclefactory_spec.rb b/spec/vehiclefactory_spec.rb index cad59a8a2..92cb9c1f7 100644 --- a/spec/vehiclefactory_spec.rb +++ b/spec/vehiclefactory_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Vehicle_factory do describe "#initialize" do it 'can initialize' do - vehicle_factory = Vehicle_factory.new(DmvDataService.new.wa_ev_registrations) + vehicle_factory = Vehicle_factory.new expect(vehicle_factory).to be_an_instance_of(Vehicle_factory) end end @@ -15,7 +15,7 @@ factory = Vehicle_factory.new wa_ev_registrations = DmvDataService.new.wa_ev_registrations factory.create_vehicles(wa_ev_registrations) - expect(vehicle.vehicle_details).to eq(wa_ev_registrations) + expect(factory.cars).to eq([wa_ev_registrations]) end end end \ No newline at end of file From b2cd5892bc40a50eea9b3d652927699c43fb9429 Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Mon, 16 Dec 2024 12:16:38 -0700 Subject: [PATCH 26/34] messing with create vehicles --- lib/vehiclefactory.rb | 16 ++++++++++++---- spec/vehiclefactory_spec.rb | 10 +++++++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/lib/vehiclefactory.rb b/lib/vehiclefactory.rb index 8a7709928..582e326d7 100644 --- a/lib/vehiclefactory.rb +++ b/lib/vehiclefactory.rb @@ -8,10 +8,18 @@ def initialize @cars = [] end - def create_vehicles(registrations) - registrations.each do |registration| - @cars << Vehicle.new(registration) + def create_vehicles(vehicle_details) + vehicle_details.each do |vehicle| + new_vehicle = Vehicle.new({ + vehicle_details[:vin], + vehicle_details[:year], + vehicle_details[:make], + vehicle_details[:model], + vehicle_details[:engine] = :ev + }) + if new_vehicle.model == "Prius Plug-in" + @cars << new_vehicle + end end - return @cars end end diff --git a/spec/vehiclefactory_spec.rb b/spec/vehiclefactory_spec.rb index 92cb9c1f7..f9df39ddb 100644 --- a/spec/vehiclefactory_spec.rb +++ b/spec/vehiclefactory_spec.rb @@ -2,6 +2,14 @@ require './lib/vehiclefactory' RSpec.describe Vehicle_factory do + before do + @prius = [{:vin_1_10=>"JTDKN3DP8D", + :dol_vehicle_id=>"229686908", + :model_year=>"2013", + :make=>"TOYOTA", + :model=>"Prius Plug-in"}] + end + describe "#initialize" do it 'can initialize' do vehicle_factory = Vehicle_factory.new @@ -15,7 +23,7 @@ factory = Vehicle_factory.new wa_ev_registrations = DmvDataService.new.wa_ev_registrations factory.create_vehicles(wa_ev_registrations) - expect(factory.cars).to eq([wa_ev_registrations]) + expect(cars[0]).to eq(["JTDKN3DP8D"]) end end end \ No newline at end of file From f630d9a0a81078a3acb9b5e0dcfe1f25d9a467c3 Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Mon, 16 Dec 2024 15:09:43 -0700 Subject: [PATCH 27/34] iteration 2 complete boom baby --- lib/vehiclefactory.rb | 14 +++++++------- spec/vehiclefactory_spec.rb | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/vehiclefactory.rb b/lib/vehiclefactory.rb index 582e326d7..9f87f1264 100644 --- a/lib/vehiclefactory.rb +++ b/lib/vehiclefactory.rb @@ -11,15 +11,15 @@ def initialize def create_vehicles(vehicle_details) vehicle_details.each do |vehicle| new_vehicle = Vehicle.new({ - vehicle_details[:vin], - vehicle_details[:year], - vehicle_details[:make], - vehicle_details[:model], - vehicle_details[:engine] = :ev + :vin => vehicle[:vin_1_10], + :year => vehicle[:model_year], + :make => vehicle[:make], + :model => vehicle[:model], + :engine => :ev }) - if new_vehicle.model == "Prius Plug-in" + # if new_vehicle.model == "Prius Plug-in" @cars << new_vehicle - end + # end end end end diff --git a/spec/vehiclefactory_spec.rb b/spec/vehiclefactory_spec.rb index f9df39ddb..24afe8cfa 100644 --- a/spec/vehiclefactory_spec.rb +++ b/spec/vehiclefactory_spec.rb @@ -2,13 +2,13 @@ require './lib/vehiclefactory' RSpec.describe Vehicle_factory do - before do - @prius = [{:vin_1_10=>"JTDKN3DP8D", - :dol_vehicle_id=>"229686908", - :model_year=>"2013", - :make=>"TOYOTA", - :model=>"Prius Plug-in"}] - end + # before do + # @prius = [{:vin_1_10=>"JTDKN3DP3C", + # :dol_vehicle_id=>"229686908", + # :model_year=>"2013", + # :make=>"TOYOTA", + # :model=>"Prius Plug-in"}] + # end describe "#initialize" do it 'can initialize' do @@ -23,7 +23,7 @@ factory = Vehicle_factory.new wa_ev_registrations = DmvDataService.new.wa_ev_registrations factory.create_vehicles(wa_ev_registrations) - expect(cars[0]).to eq(["JTDKN3DP8D"]) + expect(factory.cars.length).to eq(1000) end end end \ No newline at end of file From bcf42c3db1258c98c2bda92a24c041ea58af8cf0 Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Mon, 16 Dec 2024 15:35:29 -0700 Subject: [PATCH 28/34] iteration 3 start --- lib/dmv.rb | 6 +++++- spec/dmv_spec.rb | 9 +++++++++ spec/spec_helper.rb | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/dmv.rb b/lib/dmv.rb index a5da90e61..d8dd0e8fb 100644 --- a/lib/dmv.rb +++ b/lib/dmv.rb @@ -1,3 +1,5 @@ +require 'pry' + class Dmv attr_reader :facilities def initialize @@ -5,7 +7,9 @@ def initialize end def add_facility(facility) - @facilities << facility + facility_locations.each do |facility| + @facilities << facility + end end def facilities_offering_service(service) diff --git a/spec/dmv_spec.rb b/spec/dmv_spec.rb index 70308d270..cd1b70c31 100644 --- a/spec/dmv_spec.rb +++ b/spec/dmv_spec.rb @@ -40,4 +40,13 @@ expect(@dmv.facilities_offering_service('Road Test')).to eq([@facility_2, @facility_3]) end end + + describe '#add facilities API' do + it 'can add available facilities from an API' do + co_dmv_office_locations = DmvDataService.new.co_dmv_office_locations + expect(@dmv.facilities).to eq([]) + @dmv.add_facility(co_dmv_office_locations) + expect(@dmv.facilities.length).to eq(5) + end + end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 928255386..50e8e63b1 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,3 +3,4 @@ require './lib/facility' require './lib/vehicle' require './lib/dmv_data_service' +require './lib/vehiclefactory' From e7245d83b1fa13a4f4db33077f1871d89b0bb495 Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Mon, 16 Dec 2024 20:07:32 -0700 Subject: [PATCH 29/34] iteration 3 begins --- lib/dmv.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/dmv.rb b/lib/dmv.rb index d8dd0e8fb..8fa852b81 100644 --- a/lib/dmv.rb +++ b/lib/dmv.rb @@ -20,3 +20,4 @@ def facilities_offering_service(service) end +#branch 3 \ No newline at end of file From d070708d71fdaae71ad806827cb9255fd742c272 Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Mon, 16 Dec 2024 20:15:02 -0700 Subject: [PATCH 30/34] fixing it3 --- lib/dmv.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dmv.rb b/lib/dmv.rb index 8fa852b81..76b794d7d 100644 --- a/lib/dmv.rb +++ b/lib/dmv.rb @@ -20,4 +20,4 @@ def facilities_offering_service(service) end -#branch 3 \ No newline at end of file +#branch 3/3 \ No newline at end of file From 5130b5217ae439d9d83e8f30546129df29102fc0 Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Mon, 16 Dec 2024 22:33:29 -0700 Subject: [PATCH 31/34] REAL iteration 3 begins --- lib/dmv.rb | 2 -- lib/vehicle.rb | 18 +++++++++-------- lib/vehicle_factory.rb | 18 +++++++++++++++++ lib/vehiclefactory.rb | 25 ----------------------- spec/dmv_spec.rb | 16 +++++++-------- spec/facility_spec.rb | 27 ++++++++++--------------- spec/spec_helper.rb | 3 ++- spec/vehicle_spec.rb | 40 +++++++++++++++++-------------------- spec/vehiclefactory_spec.rb | 33 +++++++++++++++--------------- 9 files changed, 83 insertions(+), 99 deletions(-) create mode 100644 lib/vehicle_factory.rb delete mode 100644 lib/vehiclefactory.rb diff --git a/lib/dmv.rb b/lib/dmv.rb index 76b794d7d..edff30f89 100644 --- a/lib/dmv.rb +++ b/lib/dmv.rb @@ -7,9 +7,7 @@ def initialize end def add_facility(facility) - facility_locations.each do |facility| @facilities << facility - end end def facilities_offering_service(service) diff --git a/lib/vehicle.rb b/lib/vehicle.rb index d76e8463f..0aef0783c 100644 --- a/lib/vehicle.rb +++ b/lib/vehicle.rb @@ -5,22 +5,24 @@ class Vehicle :year, :make, :model, - :engine + :engine, + :plate_type attr_accessor :registration_date def initialize(vehicle_details) - @vin = vehicle_details[:vin] - @year = vehicle_details[:year] + @vin = vehicle_details[:vin_1_10] + @year = vehicle_details[:model_year] @make = vehicle_details[:make] @model = vehicle_details[:model] @engine = vehicle_details[:engine] - + @plate_type = nil + @registration_date = nil end def antique? - Date.today.year - @year > 25 + Date.today.year - @year.to_i > 25 end def electric_vehicle? @@ -29,11 +31,11 @@ def electric_vehicle? def plate_type if antique? - :antique + @plate_type = :antique elsif @engine == :ev - :ev + @plate_type = :ev else - :regular + @plate_type = :regular end end end diff --git a/lib/vehicle_factory.rb b/lib/vehicle_factory.rb new file mode 100644 index 000000000..d84dfd121 --- /dev/null +++ b/lib/vehicle_factory.rb @@ -0,0 +1,18 @@ +require './lib/vehicle' +require './lib/dmv_data_service' + + +class VehicleFactory +attr_accessor :cars + def initialize + @cars = [] + end + + def create_vehicles(vehicle_details) + vehicle_details.each do |vehicle| + new_vehicle = Vehicle.new(vehicle) + @cars << new_vehicle + end + return @cars + end +end diff --git a/lib/vehiclefactory.rb b/lib/vehiclefactory.rb deleted file mode 100644 index 9f87f1264..000000000 --- a/lib/vehiclefactory.rb +++ /dev/null @@ -1,25 +0,0 @@ -require './lib/vehicle' -require './lib/dmv_data_service' - - -class Vehicle_factory -attr_accessor :cars - def initialize - @cars = [] - end - - def create_vehicles(vehicle_details) - vehicle_details.each do |vehicle| - new_vehicle = Vehicle.new({ - :vin => vehicle[:vin_1_10], - :year => vehicle[:model_year], - :make => vehicle[:make], - :model => vehicle[:model], - :engine => :ev - }) - # if new_vehicle.model == "Prius Plug-in" - @cars << new_vehicle - # end - end - end -end diff --git a/spec/dmv_spec.rb b/spec/dmv_spec.rb index cd1b70c31..cbc522728 100644 --- a/spec/dmv_spec.rb +++ b/spec/dmv_spec.rb @@ -41,12 +41,12 @@ end end - describe '#add facilities API' do - it 'can add available facilities from an API' do - co_dmv_office_locations = DmvDataService.new.co_dmv_office_locations - expect(@dmv.facilities).to eq([]) - @dmv.add_facility(co_dmv_office_locations) - expect(@dmv.facilities.length).to eq(5) - end - end + # describe '#add facilities API' do + # it 'can add available facilities from an API' do + # co_dmv_office_locations = DmvDataService.new.co_dmv_office_locations + # expect(@dmv.facilities).to eq([]) + # @dmv.add_facility(co_dmv_office_locations) + # expect(@dmv.facilities.length).to eq(1) + # end + # end end diff --git a/spec/facility_spec.rb b/spec/facility_spec.rb index 1b8b323d0..56772e10a 100644 --- a/spec/facility_spec.rb +++ b/spec/facility_spec.rb @@ -3,6 +3,9 @@ RSpec.describe Facility do before(:each) do @facility = Facility.new({name: 'DMV Tremont Branch', address: '2855 Tremont Place Suite 118 Denver CO 80205', phone: '(720) 865-4600'}) + @cruz = Vehicle.new({vin_1_10: '123456789abcdefgh', model_year: "2012", make: 'Chevrolet', model: 'Cruz', engine: :ice} ) + @bolt = Vehicle.new({vin_1_10: '987654321abcdefgh', model_year: "2019", make: 'Chevrolet', model: 'Bolt', engine: :ev} ) + @camaro = Vehicle.new({vin_1_10: '1a2b3c4d5e6f', model_year: "1969", make: 'Chevrolet', model: 'Camaro', engine: :ice} ) end describe '#initialize' do it 'can initialize' do @@ -26,32 +29,24 @@ describe '#register vehicle' do it 'can register a vehicle' do - cruz = Vehicle.new({vin: '123456789abcdefgh', year: 2012, make: 'Chevrolet', model: 'Cruz', engine: :ice} ) - @facility.register_vehicle(cruz) - expect(@facility.registered_vehicles).to eq([cruz]) + @facility.register_vehicle(@cruz) + expect(@facility.registered_vehicles).to eq([@cruz]) end end describe '#check registered vehicles' do it 'has an array of vehicles' 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} ) - @facility.register_vehicle(cruz) - @facility.register_vehicle(bolt) - @facility.register_vehicle(camaro) - expect(@facility.registered_vehicles).to eq([cruz, bolt, camaro]) + @facility.register_vehicle(@bolt) + @facility.register_vehicle(@camaro) + expect(@facility.registered_vehicles).to eq([@bolt, @camaro]) end end describe '#check fees' do it 'has a value of collected fees' 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} ) - @facility.register_vehicle(cruz) - @facility.register_vehicle(bolt) - @facility.register_vehicle(camaro) + @facility.register_vehicle(@cruz) + @facility.register_vehicle(@bolt) + @facility.register_vehicle(@camaro) expect(@facility.collected_fees).to eq(325) end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 50e8e63b1..6f429c2c1 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,4 +3,5 @@ require './lib/facility' require './lib/vehicle' require './lib/dmv_data_service' -require './lib/vehiclefactory' +require './lib/vehicle_factory' +require './lib/registrant' \ No newline at end of file diff --git a/spec/vehicle_spec.rb b/spec/vehicle_spec.rb index 1068bbae5..99eb3e6fe 100644 --- a/spec/vehicle_spec.rb +++ b/spec/vehicle_spec.rb @@ -2,15 +2,15 @@ RSpec.describe Vehicle do before(:each) 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} ) + @cruz = Vehicle.new({vin_1_10: '123456789abcdefgh', model_year: "2012", make: 'Chevrolet', model: 'Cruz', engine: :ice} ) + @bolt = Vehicle.new({vin_1_10: '987654321abcdefgh', model_year: "2019", make: 'Chevrolet', model: 'Bolt', engine: :ev} ) + @camaro = Vehicle.new({vin_1_10: '1a2b3c4d5e6f', model_year: "1969", make: 'Chevrolet', model: 'Camaro', engine: :ice} ) end describe '#initialize' do it 'can initialize' do expect(@cruz).to be_an_instance_of(Vehicle) expect(@cruz.vin).to eq('123456789abcdefgh') - expect(@cruz.year).to eq(2012) + expect(@cruz.year).to eq("2012") expect(@cruz.make).to eq('Chevrolet') expect(@cruz.model).to eq('Cruz') expect(@cruz.engine).to eq(:ice) @@ -36,32 +36,28 @@ describe "#has plate type" do it 'checks the plate type' 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} ) - cruz.plate_type - bolt.plate_type - camaro.plate_type + + @cruz.plate_type + @bolt.plate_type + @camaro.plate_type - expect(bolt.plate_type).to eq(:ev) - expect(cruz.plate_type).to eq(:regular) - expect(camaro.plate_type).to eq(:antique) + expect(@bolt.plate_type).to eq(:ev) + expect(@cruz.plate_type).to eq(:regular) + expect(@camaro.plate_type).to eq(:antique) end end describe "#registration date" do it 'has a registration date when registered' 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} ) + facility = Facility.new({name: 'DMV Tremont Branch', address: '2855 Tremont Place Suite 118 Denver CO 80205', phone: '(720) 865-4600'}) - facility.register_vehicle(cruz) - facility.register_vehicle(bolt) - facility.register_vehicle(camaro) + facility.register_vehicle(@cruz) + facility.register_vehicle(@bolt) + facility.register_vehicle(@camaro) - expect(cruz.registration_date).to eq(Date.today.strftime("%m/%d/%Y")) - expect(bolt.registration_date).to eq(Date.today.strftime("%m/%d/%Y")) - expect(camaro.registration_date).to eq(Date.today.strftime("%m/%d/%Y")) + expect(@cruz.registration_date).to eq(Date.today.strftime("%m/%d/%Y")) + expect(@bolt.registration_date).to eq(Date.today.strftime("%m/%d/%Y")) + expect(@camaro.registration_date).to eq(Date.today.strftime("%m/%d/%Y")) end end diff --git a/spec/vehiclefactory_spec.rb b/spec/vehiclefactory_spec.rb index 24afe8cfa..b26a8f759 100644 --- a/spec/vehiclefactory_spec.rb +++ b/spec/vehiclefactory_spec.rb @@ -1,29 +1,28 @@ require 'spec_helper' -require './lib/vehiclefactory' - -RSpec.describe Vehicle_factory do - # before do - # @prius = [{:vin_1_10=>"JTDKN3DP3C", - # :dol_vehicle_id=>"229686908", - # :model_year=>"2013", - # :make=>"TOYOTA", - # :model=>"Prius Plug-in"}] - # end +RSpec.describe VehicleFactory do + before do + @factory = VehicleFactory.new + @wa_ev_registrations = DmvDataService.new.wa_ev_registrations + end + describe "#initialize" do it 'can initialize' do - vehicle_factory = Vehicle_factory.new - expect(vehicle_factory).to be_an_instance_of(Vehicle_factory) + expect(@factory).to be_an_instance_of(VehicleFactory) end end describe "#create vehicles" do it 'can create vehicles and populate with vehicle details' do - - factory = Vehicle_factory.new - wa_ev_registrations = DmvDataService.new.wa_ev_registrations - factory.create_vehicles(wa_ev_registrations) - expect(factory.cars.length).to eq(1000) + @factory.create_vehicles(@wa_ev_registrations) + expect(@factory.cars.length).to eq(1000) + end + end + + describe "#check specific car in array" do + it "check vin of 6th car" do + @factory.create_vehicles(@wa_ev_registrations) + expect(@factory.cars[5].vin).to eq("5YJYGDED6M") end end end \ No newline at end of file From 6d547afc98bec9ac61b28adfb364c887661e527a Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Tue, 17 Dec 2024 11:53:26 -0700 Subject: [PATCH 32/34] iteration 3 looking good. new dmv_facilities class and accompanying spec tests --- lib/dmv.rb | 2 +- lib/dmv_facilities.rb | 19 ++++++++++ lib/facility.rb | 6 ++-- spec/dmv_facilities_spec.rb | 69 +++++++++++++++++++++++++++++++++++++ spec/spec_helper.rb | 3 +- 5 files changed, 94 insertions(+), 5 deletions(-) create mode 100644 lib/dmv_facilities.rb create mode 100644 spec/dmv_facilities_spec.rb diff --git a/lib/dmv.rb b/lib/dmv.rb index edff30f89..ae7de434f 100644 --- a/lib/dmv.rb +++ b/lib/dmv.rb @@ -18,4 +18,4 @@ def facilities_offering_service(service) end -#branch 3/3 \ No newline at end of file +#branch 3/333 \ No newline at end of file diff --git a/lib/dmv_facilities.rb b/lib/dmv_facilities.rb new file mode 100644 index 000000000..ebff6d3d9 --- /dev/null +++ b/lib/dmv_facilities.rb @@ -0,0 +1,19 @@ +require './lib/facility' +require './lib/dmv_data_service' + + +class DmvFacilities + attr_accessor :facilities + def initialize + @facilities = [] + end + + def create_facilities(facility_details) + facility_details.each do |facility| + new_facility = Facility.new(facility) + @facilities << new_facility + end + return @facilities + end + end + \ No newline at end of file diff --git a/lib/facility.rb b/lib/facility.rb index 2adb34154..409f0c415 100644 --- a/lib/facility.rb +++ b/lib/facility.rb @@ -2,9 +2,9 @@ class Facility attr_reader :name, :address, :phone, :services def initialize(facility_details) - @name = facility_details[:name] - @address = facility_details[:address] - @phone = facility_details[:phone] + @name = facility_details[:name] || facility_details[:dmv_office] || facility_details[:office_name] + @address = facility_details[:address] || facility_details[:address_li] || facility_details[:street_address_line_1] || [:address1] + @phone = facility_details[:phone] || facility_details[:public_phone_number] @services = [] @registered_vehicles = [] @collected_fees = 0 diff --git a/spec/dmv_facilities_spec.rb b/spec/dmv_facilities_spec.rb new file mode 100644 index 000000000..8c62e1d45 --- /dev/null +++ b/spec/dmv_facilities_spec.rb @@ -0,0 +1,69 @@ +require 'spec_helper' +require 'pry' + +RSpec.describe DmvFacilities do + before do + @dmvfacility = DmvFacilities.new + @co_dmv_office_locations = DmvDataService.new.co_dmv_office_locations + @ny_dmv_office_locations = DmvDataService.new.ny_dmv_office_locations + @mo_dmv_office_locations = DmvDataService.new.mo_dmv_office_locations + end + + describe "#initialize" do + it 'can initialize' do + expect(@dmvfacility).to be_an_instance_of(DmvFacilities) + end + end + + describe "#create CO facilities" do + it 'can create CO facilities and populate with facility details' do + @dmvfacility.create_facilities(@co_dmv_office_locations) + expect(@dmvfacility.facilities.length).to eq(5) + end + end + + describe "#check specific CO facility in array" do + it "check office of 2nd facility" do + @dmvfacility.create_facilities(@co_dmv_office_locations) + expect(@dmvfacility.facilities[1].name).to eq("DMV Northeast Branch") + end + end + + describe "#create NY facilities" do + it 'can create NY facilities and populate with facility details' do + @dmvfacility.create_facilities(@ny_dmv_office_locations) + expect(@dmvfacility.facilities.length).to eq(173) + end + end + + describe "#check specific NY facility in array" do + it "check office of 2nd facility" do + @dmvfacility.create_facilities(@ny_dmv_office_locations) + expect(@dmvfacility.facilities[1].name).to eq("HUDSON") + end + end + + describe "#create MO facilities" do + it 'can create MO facilities and populate with facility details' do + @dmvfacility.create_facilities(@mo_dmv_office_locations) + expect(@dmvfacility.facilities.length).to eq(174) + end + end + + describe "#check specific MO facility in array" do + it "check office of 2nd facility" do + @dmvfacility.create_facilities(@mo_dmv_office_locations) + expect(@dmvfacility.facilities[1].name).to eq("High Ridge") + end + end + + describe "#adds all facilities" do + it "can add facilities from all states at once" do + @dmvfacility.create_facilities(@mo_dmv_office_locations) + @dmvfacility.create_facilities(@ny_dmv_office_locations) + @dmvfacility.create_facilities(@co_dmv_office_locations) + + expect(@dmvfacility.facilities.length).to eq(352) + end + end +end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6f429c2c1..3e0f63f7c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -4,4 +4,5 @@ require './lib/vehicle' require './lib/dmv_data_service' require './lib/vehicle_factory' -require './lib/registrant' \ No newline at end of file +require './lib/registrant' +require './lib/dmv_facilities' \ No newline at end of file From 39ae304301559067089012759805d4289aafcb1a Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Tue, 17 Dec 2024 13:32:04 -0700 Subject: [PATCH 33/34] iteration 4 begins --- the_dmv_extension_js | 1 + 1 file changed, 1 insertion(+) create mode 160000 the_dmv_extension_js diff --git a/the_dmv_extension_js b/the_dmv_extension_js new file mode 160000 index 000000000..ad378cfe0 --- /dev/null +++ b/the_dmv_extension_js @@ -0,0 +1 @@ +Subproject commit ad378cfe0b12f9066829dc788a9d463e10bf8c31 From 73efab84dbf7f8584ffb99520f093f9a6332fa57 Mon Sep 17 00:00:00 2001 From: Joseph Bloom Date: Tue, 17 Dec 2024 14:48:13 -0700 Subject: [PATCH 34/34] spec tests looking nice on dmv_facilities_spec --- lib/facility.rb | 2 +- spec/dmv_facilities_spec.rb | 68 +++++++++++++++++-------------------- 2 files changed, 33 insertions(+), 37 deletions(-) diff --git a/lib/facility.rb b/lib/facility.rb index 409f0c415..2548ca2b3 100644 --- a/lib/facility.rb +++ b/lib/facility.rb @@ -3,7 +3,7 @@ class Facility def initialize(facility_details) @name = facility_details[:name] || facility_details[:dmv_office] || facility_details[:office_name] - @address = facility_details[:address] || facility_details[:address_li] || facility_details[:street_address_line_1] || [:address1] + @address = facility_details[:address] || facility_details[:address_li] || facility_details[:street_address_line_1] || facility_details[:address1] @phone = facility_details[:phone] || facility_details[:public_phone_number] @services = [] @registered_vehicles = [] diff --git a/spec/dmv_facilities_spec.rb b/spec/dmv_facilities_spec.rb index 8c62e1d45..28c3b038f 100644 --- a/spec/dmv_facilities_spec.rb +++ b/spec/dmv_facilities_spec.rb @@ -3,7 +3,7 @@ RSpec.describe DmvFacilities do before do - @dmvfacility = DmvFacilities.new + @dmvfacilities = DmvFacilities.new @co_dmv_office_locations = DmvDataService.new.co_dmv_office_locations @ny_dmv_office_locations = DmvDataService.new.ny_dmv_office_locations @mo_dmv_office_locations = DmvDataService.new.mo_dmv_office_locations @@ -11,59 +11,55 @@ describe "#initialize" do it 'can initialize' do - expect(@dmvfacility).to be_an_instance_of(DmvFacilities) + expect(@dmvfacilities).to be_an_instance_of(DmvFacilities) end end describe "#create CO facilities" do - it 'can create CO facilities and populate with facility details' do - @dmvfacility.create_facilities(@co_dmv_office_locations) - expect(@dmvfacility.facilities.length).to eq(5) - end - end - - describe "#check specific CO facility in array" do - it "check office of 2nd facility" do - @dmvfacility.create_facilities(@co_dmv_office_locations) - expect(@dmvfacility.facilities[1].name).to eq("DMV Northeast Branch") + it 'can create CO facilities and hold facility details' do + @dmvfacilities.create_facilities(@co_dmv_office_locations) + expect(@dmvfacilities.facilities.length).to eq(5) + expect(@dmvfacilities.facilities[1].name).to eq("DMV Northeast Branch") + expect(@dmvfacilities.facilities[1].phone).to eq("(720) 865-4600") + expect(@dmvfacilities.facilities[1].address).to eq("4685 Peoria Street") end end describe "#create NY facilities" do - it 'can create NY facilities and populate with facility details' do - @dmvfacility.create_facilities(@ny_dmv_office_locations) - expect(@dmvfacility.facilities.length).to eq(173) - end - end - - describe "#check specific NY facility in array" do - it "check office of 2nd facility" do - @dmvfacility.create_facilities(@ny_dmv_office_locations) - expect(@dmvfacility.facilities[1].name).to eq("HUDSON") + it 'can create NY facilities and hold facility details' do + @dmvfacilities.create_facilities(@ny_dmv_office_locations) + expect(@dmvfacilities.facilities.length).to eq(173) + expect(@dmvfacilities.facilities[0].name).to eq("LAKE PLACID") + expect(@dmvfacilities.facilities[1].name).to eq("HUDSON") + expect(@dmvfacilities.facilities[2].name).to eq("RIVERHEAD KIOSK") end end describe "#create MO facilities" do - it 'can create MO facilities and populate with facility details' do - @dmvfacility.create_facilities(@mo_dmv_office_locations) - expect(@dmvfacility.facilities.length).to eq(174) - end - end - - describe "#check specific MO facility in array" do - it "check office of 2nd facility" do - @dmvfacility.create_facilities(@mo_dmv_office_locations) - expect(@dmvfacility.facilities[1].name).to eq("High Ridge") + it 'can create MO facilities and hold facility details' do + @dmvfacilities.create_facilities(@mo_dmv_office_locations) + expect(@dmvfacilities.facilities.length).to eq(174) + expect(@dmvfacilities.facilities[1].name).to eq("High Ridge") + expect(@dmvfacilities.facilities[0].address).to eq("2009 Plaza Dr.") + expect(@dmvfacilities.facilities[2].phone).to eq("(660) 665-0292") end end describe "#adds all facilities" do it "can add facilities from all states at once" do - @dmvfacility.create_facilities(@mo_dmv_office_locations) - @dmvfacility.create_facilities(@ny_dmv_office_locations) - @dmvfacility.create_facilities(@co_dmv_office_locations) + mo_count = @mo_dmv_office_locations.count + ny_count = @ny_dmv_office_locations.count + co_count = @co_dmv_office_locations.count + + @dmvfacilities.create_facilities(@mo_dmv_office_locations) + expect(@dmvfacilities.facilities.length).to eq(mo_count) + + @dmvfacilities.create_facilities(@ny_dmv_office_locations) + expect(@dmvfacilities.facilities.length).to eq(mo_count + ny_count) + + @dmvfacilities.create_facilities(@co_dmv_office_locations) + expect(@dmvfacilities.facilities.length).to eq(mo_count + ny_count + co_count) - expect(@dmvfacility.facilities.length).to eq(352) end end end \ No newline at end of file