Skip to content
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

Done(Panda, Tiger, Eagle) #14

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Conversation

var114
Copy link

@var114 var114 commented Nov 19, 2013

No description provided.

describe Vehicle do

it "should start with no wheels" do
Vehicle.wheels.should eq(nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In RSpec, it has cool matchers that I like to point out. You could rewrite this methot as:

Vehicle.wheels.should be_nil

@jwo
Copy link
Member

jwo commented Nov 19, 2013

Looks pretty great!

The only thing I wasn't 100% on was the self.wheels --- In it, you are setting a variable and returning it.

class Vehicle
  @@wheels = 0

  def self.wheels
    @@wheels
  end
end

Then in your motorcycle, you can override the @@wheels

class Motorcylcle < Vehicle
  @@wheels = 2
end

Vehicle.wheels
=> 0

Motorcycle.wheels
=> 2

OR, possibly event simpler (but without using class variables):

class Vehicle
  WHEEL_COUNT = 0

  def self.wheels
    WHEEL_COUNT
  end
end
class Motorcycle < Vehicle
  WHEEL_COUNT = 2
end

puts Motorcycle.wheels
=> 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants