This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DetachmentSystemTest { | |
testRespondsToDetachFailing() { | |
detachment_system = DetachmentSystem.new(parachute = mock(Parachute)) | |
parachute.stubs().detach().to_raise(AnyException) | |
this_block { | |
detachment_system.handle_acceleration_report(-50.ms2) | |
}.should raise(AnyException) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
testAccelerometerCanRespondToFailureWhenReportingAcceleration() { | |
accelerometer = Accelerometer.new() | |
accelerometer.add_observer(observer = mock(AccelerationObserver)) | |
observer.stubs().handle_acceleration_report().to_raise(AnyException) | |
this_block { | |
accelerometer.report_acceleration(-50.ms2) | |
}.should raise(AnyException) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
testLanderDeceleratesRespondsToFailure() { | |
accelerometer = mock(Accelerometer) | |
lander = Lander.new(accelerometer) | |
accelerometer.stubs().report_acceleration().to_raise(AnyException) | |
this_block { | |
lander.decelerate() | |
}.should raise(AnyException) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
testOpenParachuteRespondsToFailure() { | |
parachute = Parachute.new(lander = mock(Lander)) | |
lander.stubs().decelerate().to_raise(AnyException) | |
this_block { | |
parachute.open() | |
}.should raise(AnyException) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
testDetachingWhileNotLanded() { | |
parachute = Parachute.new(lander = mock(Lander)) | |
lander.stubs().has_landed().to_return(false) | |
this_block { | |
parachute.detach() | |
}.should raise("You broke the lander, idiot.") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
testDoNotDetachWhenTheLanderIsTooHighUp() { | |
altimeter = mock(Altimeter) | |
altimeter.stubs().altitude().to_return(5.m) | |
DetachmentSystem.new(parachute = mock(Parachute)) | |
parachute.expects(no_invocations_of).detach() | |
detachment_system.handle_acceleration_report(-50.ms2) | |
// ??? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
testDoNotDetachWhenTheLanderIsTooHighUp() { | |
DetachmentSystem.new(parachute = mock(Parachute), altimeter = mock(Altimeter)) | |
altimeter.stubs().altitude().to_return(5.m) | |
parachute.expects(no_invocations_of).detach() | |
detachment_system.handle_acceleration_report(-50.ms2) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DetachmentSystem acts as AccelerationObserver { | |
needs a parachute | |
needs an altimeter // NEW! | |
handle_acceleration_report(acceleration) {} | |
if (acceleration <= -50.ms2 and altimeter.altitude() < 5.m) { | |
parachute.detach() | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "the logical view" do | |
context "when the user tries to register" do | |
context "when the user is under 13 years of age" do | |
it "should prevent the user from submitting the form" do | |
# Code to set up the logical view and application elided | |
application.should_not_receive(:post) | |
form.age = 12 | |
form.submit | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "/registration/new" do | |
context "when deciding whether to enable the submit button" do | |
it "should disable it when the user is under 13" do | |
# Code to set up the form elided | |
form.age = 12 | |
form.buttons[:submit].should_not be_enabled | |
end | |
it "should enable it when the user is at least 13" do | |
# Code to set up the form elided |