A simulation of a toy robot moving on a square tabletop. Programming exercise for REA job application.
Running demo at: floating-cove-6107.herokuapp.com
-
5x5 table
-
No obstructions
-
Any movement resulting in the robot falling off the table are to be ignored. Further input accepted.
-
Commands: PLACE, MOVE, LEFT, RIGHT, REPORT
-
PLACE(X, Y, FACING) places the robot on the table facing the direction input
-
MOVE the robot 1 space forward
-
LEFT rotate the robot 90 degrees
-
RIGHT rototate the robot 90 degrees
-
REPORT announces the X, Y and direction the robot is facing
-
-
Origin position 0,0 the Southwest corner
-
Robot must be placed on the table
-
Ignore all commands until a valid PLACE command
-
Robot can be re-placed on the table
-
Input source developer’s choice (standard input, file etc.)
-
Graphical representation not required
-
Web application!
-
Thread-safe (i.e. each session has it’s own state)
-
Actions call friendly URLs via AJAX
-
Deployed to the cloud (Heroku)
-
REA visuals
-
Chaos Robot! (similar to Chaos Monkey, randomly performs 10 actions)
-
-
Supports variable table dimensions
-
Full code comments, rdoc, static methods, removed unused autogenerated code
-
Skeleton for ability to add many robots to a table
-
Table aware of Robot(s)
-
Actions have placeholders for Robot IDs to diferentiate
-
-
For demonstration purposes only, monkey patched Array core class to demonstrate novel approach for rotation (LinkedList-type functionality instead of an easy switch statement)
-
Also patched the JavaScript Array object!
-
-
Read up on Minitest v RSpec, decided to choose Minitest DSL with standard matchers/mocks for simplicity
-
Easy enough to leverage Mocha, Shoulda etc.
-
TDD unit & integration tests
-
One assertion per test
-
No parenthesis for cleaner readability
-
-
Input ignores case
-
Multiple robots on the table at once (although basic foundations of ID are in place)
-
Functional tests on the ad-hoc web components (view, thin controller)
-
Proper Javascript (module pattern, tests)
-
blog.arvidandersson.se/2012/03/28/minimalicous-testing-in-ruby-1-9 (Minitest introduction, Spec-only)
-
ruby.awsblog.com/post/TxUMU0234OS1Q3/From-RSpec-to-Minitest (pro Minitest, Spec-only)
-
brandonhilkert.com/blog/7-reasons-why-im-sticking-with-minitest-and-fixtures-in-rails/ (pro Minitest and Fixtures)
-
code.tutsplus.com/tutorials/ruby-for-newbies-testing-with-rspec–net-21297 (simple RSpec guide)
-
www.agileventures.org/articles/testing-with-rspec-stubs-mocks-factories-what-to-choose (Mocks)
-
www.mattsears.com/articles/2011/12/10/minitest-quick-reference (Minitest cheat sheet)
-
regex101.com/ (regular expression tester)