diff --git a/.idea/Episode6.iml b/.idea/Episode6.iml new file mode 100644 index 0000000..9e2bdf8 --- /dev/null +++ b/.idea/Episode6.iml @@ -0,0 +1,220 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..e206d70 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..78d2e82 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..80603f8 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..c80f219 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/models/Motorcycle.rb b/models/Motorcycle.rb new file mode 100644 index 0000000..e0a9ea7 --- /dev/null +++ b/models/Motorcycle.rb @@ -0,0 +1,10 @@ +require_relative('Vehicle.rb') +class Motorcycle < Vehicle + +attr_accessor :tires + + def initialize + @tires = 2 + end + +end \ No newline at end of file diff --git a/models/Vehicle.rb b/models/Vehicle.rb new file mode 100644 index 0000000..56f9f38 --- /dev/null +++ b/models/Vehicle.rb @@ -0,0 +1,22 @@ +class Vehicle + attr_accessor :tires, :wheels, :colour, :make, :year, :model + + def initialize (args={}) + @tires = args.fetch(:tires) + @wheels = args.fetch(:wheels) + @colour = args.fetch(:colour) + @make = args.fetch(:make) + @year = args.fetch(:year) + @model = args.fetch(:model) + end + + def update(args = {}) + @tires = args.fetch(:tires) + @wheels = args.fetch(:wheels) + @colour = args.fetch(:colour) + @make = args.fetch(:make) + @year = args.fetch(:year) + @model = args.fetch(:model) + end + +end \ No newline at end of file diff --git a/models/automobile.rb b/models/automobile.rb new file mode 100644 index 0000000..5bd28a6 --- /dev/null +++ b/models/automobile.rb @@ -0,0 +1,12 @@ +require_relative('Vehicle.rb') +class Automobile < Vehicle + attr_accessor :wheels, :carspecifications, :colour, :make, :year + + def initialize(args = {}) + super(args) + end + + def update(args = {}) + super(args) + end +end \ No newline at end of file diff --git a/spec/automobile_spec.rb b/spec/automobile_spec.rb new file mode 100644 index 0000000..2648dd4 --- /dev/null +++ b/spec/automobile_spec.rb @@ -0,0 +1,39 @@ +require 'rspec' +require_relative('../models/automobile.rb') + + +describe 'Automobile' do + carspecs = {wheels: 4, colour: "Red", make: "Shiznit", year: "1970", model: "Skoda"} + myauto = Vehicle.new(carspecs) + + it "should have a model" do + myauto.model.should == "Skoda" + end + + it 'should return the number of wheels' do + myauto.wheels.should be_a_kind_of Numeric + end + + it "should have a colour" do + myauto.colour.should == carspecs[:colour] + end + + it "should have a make" do + myauto.make.should == carspecs[:make] + end + + it "should have a year" do + myauto.year.should == carspecs[:year] + end + + it "should update specs" do + newspecs = {wheels: 4, colour: "Yellow", make: "Toyota", model: "Corolla", year: "2003"} + myauto.update(newspecs) + myauto.tires.should == newspecs[:tires] + myauto.wheels.should == newspecs[:wheels] + myauto.colour.should == newspecs[:colour] + myauto.make.should == newspecs[:make] + myauto.model.should == newspecs[:model] + myauto.year.should == newspecs[:year] + end + end \ No newline at end of file diff --git a/spec/motorcycle_spec.rb b/spec/motorcycle_spec.rb new file mode 100644 index 0000000..8eab818 --- /dev/null +++ b/spec/motorcycle_spec.rb @@ -0,0 +1,9 @@ +require_relative('../models/Motorcycle.rb') +require 'rspec' + +describe Motorcycle do + it 'should return number of tires' do + Motorcycle.new.tires.should == 2 + end + +end \ No newline at end of file diff --git a/spec/vehicle_spec.rb b/spec/vehicle_spec.rb new file mode 100644 index 0000000..0e9032a --- /dev/null +++ b/spec/vehicle_spec.rb @@ -0,0 +1,43 @@ +require_relative('../models/Vehicle.rb') +require 'rspec' + +describe Vehicle do + carspecs = {tires: 4, wheels: 4, colour: "Red", make: "Shiznit", year: "1970", model: "Skoda"} + myvehicle = Vehicle.new(carspecs) + + it 'should return number of tires' do + myvehicle.tires.should be_a_kind_of Numeric + end + + it "should have a model" do + myvehicle.model.should == "Skoda" + end + + it 'should return the number of wheels' do + myvehicle.wheels.should be_a_kind_of Numeric + end + + it "should have a colour" do + myvehicle.colour.should == carspecs[:colour] + end + + it "should have a make" do + myvehicle.make.should == carspecs[:make] + end + + it "should have a year" do + myvehicle.year.should == carspecs[:year] + end + + it "should update specs" do + newspecs = {tires: 4, wheels: 4, colour: "Yellow", make: "Toyota", model: "Corolla", year: "2003"} + myvehicle.update(newspecs) + myvehicle.tires.should == newspecs[:tires] + myvehicle.wheels.should == newspecs[:wheels] + myvehicle.colour.should == newspecs[:colour] + myvehicle.make.should == newspecs[:make] + myvehicle.model.should == newspecs[:model] + myvehicle.year.should == newspecs[:year] + end + end +