-
Notifications
You must be signed in to change notification settings - Fork 22
Feature: Panda and Tiger #17
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| require_relative('Vehicle.rb') | ||
| class Motorcycle < Vehicle | ||
|
|
||
| attr_accessor :tires | ||
|
|
||
| def initialize | ||
| @tires = 2 | ||
| end | ||
|
|
||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| class Vehicle | ||
| attr_accessor :tires | ||
|
|
||
| def initialize (tires) | ||
| @tires = tires | ||
| end | ||
|
|
||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| require_relative('Vehicle.rb') | ||
| class Automobile < Vehicle | ||
| attr_accessor :wheels, :carspecifications, :colour, :make, :model, :year | ||
|
|
||
| def initialize(wheels, carspecifications={}) | ||
| @carspecifications = carspecifications | ||
| @wheels = wheels | ||
| @colour = @carspecifications[:colour] | ||
| @make = @carspecifications[:make] | ||
| @model = @carspecifications[:model] | ||
| @year = @carspecifications[:year] | ||
| end | ||
|
|
||
| def update(newspecs = {}) | ||
| @newspecs = newspecs | ||
| @colour = @newspecs[:colour] | ||
| @make = @newspecs[:make] | ||
| @model = @newspecs[:model] | ||
| @year = @newspecs[:year] | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| require 'rspec' | ||
| require_relative('../models/automobile.rb') | ||
|
|
||
|
|
||
| describe 'Automobile' do | ||
| carspecs = {colour: "Red", make: "Skoda", model: "Shiznit", year: "1970"} | ||
| mycar = Automobile.new(5, carspecs) | ||
|
|
||
| it 'should return the number of wheels' do | ||
| mycar.wheels.should be_a_kind_of Numeric | ||
| end | ||
|
|
||
| it "should have a colour" do | ||
| mycar.colour.should == carspecs[:colour] | ||
| end | ||
|
|
||
| it "should have a make" do | ||
| mycar.make.should == carspecs[:make] | ||
| end | ||
|
|
||
| it "should have a model" do | ||
| mycar.model.should == carspecs[:model] | ||
| end | ||
|
|
||
| it "should have a year" do | ||
| mycar.year.should == carspecs[:year] | ||
| end | ||
|
|
||
| it "should update specs" do | ||
| newspecs = {colour: "Yellow", make: "Toyota", model: "Corolla", year: "2003"} | ||
| mycar.update(newspecs) | ||
| mycar.colour.should == newspecs[:colour] | ||
| mycar.make.should == newspecs[:make] | ||
| mycar.model.should == newspecs[:model] | ||
| mycar.year.should == newspecs[:year] | ||
| end | ||
|
|
||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| require_relative('../models/Vehicle.rb') | ||
| require 'rspec' | ||
|
|
||
| describe Vehicle do | ||
| it 'should return number of tires' do | ||
| Vehicle.new(4).tires.should be_a_kind_of Numeric | ||
| end | ||
|
|
||
| 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.
Do you need to keep on to the
carspecificationshash after you've initialized?