Airport challenge - #2496
Conversation
| def initialize(capacity=DEFAULT_CAPACITY) | ||
| @airplanes = [] | ||
| @capacity = capacity | ||
| condition = Weather.new |
There was a problem hiding this comment.
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 |
|
|
||
| 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.
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 |
| end | ||
|
|
||
| def takeoff_plane(airplane) | ||
| fail "Weather Stormy cannot take off" unless sunny |
There was a problem hiding this comment.
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" |
| 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.
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.
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.
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 |
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!