-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Airport challenge #2496
base: main
Are you sure you want to change the base?
Airport challenge #2496
Conversation
def initialize(capacity=DEFAULT_CAPACITY) | ||
@airplanes = [] | ||
@capacity = capacity | ||
condition = Weather.new |
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.
I would maybe think about creating the Weather instance when the plane takes off/lands, rather than creating the weather the same time the airport is created. As the weather will most likely not be the same as it was the day the airport was created.
end | ||
|
||
def land_plane(airplane) | ||
fail "Airport is full" if airplanes.length == capacity |
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.
Good :)
|
||
def land_plane(airplane) | ||
fail "Airport is full" if airplanes.length == capacity | ||
fail "Can't land as weather is stormy" unless sunny |
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.
I can't see the instance variable sunny relating to anything, should it be weather.sunny?
fail "Can't land as weather is stormy" unless sunny | ||
fail "Airplane is already here" if airplane.landed | ||
airplane.landed = true | ||
airplanes << airplane |
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.
This seems good!
end | ||
|
||
def takeoff_plane(airplane) | ||
fail "Weather Stormy cannot take off" unless sunny |
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.
Same comment as above regarding sunny instance variable
subject.sunny = true | ||
allow(airplane).to receive(:landed).and_return(false) | ||
Airport::DEFAULT_CAPACITY.times { subject.land_plane(airplane) } | ||
expect{subject.land_plane(airplane)}.to raise_error "Airport is full" |
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.
good :)
expect{subject.land_plane(airplane)}.to raise_error "Airport is full" | ||
end | ||
|
||
it "Check to see if you can fill, remove then fill airport" do |
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.
This test description seems a little confusing
end | ||
|
||
it "Overwrite default airport capacity to 30" do | ||
expect(subject.capacity=30).to eq 30 |
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.
You could also test a new instance of airport with capacity as paramater. I would also consider changing this number, as the default capacity is already set to 30
require '../lib/plane.rb' | ||
|
||
describe Plane do | ||
|
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.
Here you could add some tests to see if the plane is in the air or if it's landed
let(:weather) {double :weather, :sunny= => true, sunny?: true} | ||
|
||
it "Check weather = sunny" do | ||
expect(weather).to be_sunny |
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.
good
Your name
Please write your full name here to make it easier to find your pull request.
User stories
Please list which user stories you've implemented (delete the ones that don't apply).
README checklist
Does your README contains instructions for
Here is a pill that can help you write a great README!