Skip to content

Conversation

@tomoneill32
Copy link

Tom O'Neill

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).

  • User story 1: "I want to instruct a plane to land at an airport"
  • User story 2: "I want to instruct a plane to take off from an airport and confirm that it is no longer in the airport"
  • User story 3: "I want to prevent landing when the airport is full"
  • User story 4: "I would like a default airport capacity that can be overridden as appropriate"
  • User story 5: "I want to prevent takeoff when weather is stormy"
  • User story 6: "I want to prevent landing when weather is stormy"

README checklist

Does your README contains instructions for

Here is a pill that can help you write a great README!

end

it 'Will not do so if the airport is full' do
Airport::CAPACITY.times { subject.land(Plane.new) }

Choose a reason for hiding this comment

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

Good use of constant instead of magic number


describe '#depart' do
it 'Can instruct a stored plane to take off from the airport' do
plane = Plane.new

Choose a reason for hiding this comment

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

Since you are initialising a plane multiples times in the spec, you could consider using let to define a plane variable and then refer to that

let(:plane) { Plane.new }

expect(subject.stored_planes).to eq []
end

it 'Will not do so if there are no planes in the airport' do

Choose a reason for hiding this comment

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

Could reword the it statement to be less wordy and easier to read, perhaps by using should ( e.g. 'should not depart if there are no planes') or consider a context block to set the stage for multiple tests where the airport is empty.

@@ -0,0 +1,46 @@
require_relative 'plane'

Choose a reason for hiding this comment

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

Believe if you require the files in the spec_helper you don't need to require them on each individual file as well


def land(plane)
fail 'Airport full!' if full?
fail 'Cannot land - stormy weather!' if @weather == 'Stormy'

Choose a reason for hiding this comment

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

Consider refactoring the condition into it's own method (SRP)

end

def empty?
@stored_planes == []

Choose a reason for hiding this comment

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

You could use .empty? which might be cleaner


def set_weather
die = rand(100)
die > 100 ? 'Stormy' : 'Sunny'

Choose a reason for hiding this comment

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

Consider if there is a way to write this without the ternary

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