Beta

Basic Router With Named Segments

Description
Loading description...
Data Structures
Regular Expressions
Algorithms
View
AllIssues4QuestionsSuggestionsShow Resolved
  • Please sign in or sign up to leave a comment.
  • Voile Avatar

    This comment has been hidden.

  • Voile Avatar

    Needs true random tests. The current "random" tests just consists of different values of the same route.

    Also needs more fixed tests. There is only ever 1 route hash tested for the kata.

  • Voile Avatar

    The methological and design of the kata is incorrect: segments refer to URL segments, which is the path of the URL further delimited by dashes. Hence a method named .segments should not return the named hash, it should return an array of the URL segments. The named segments would be the params captured by the route.

    Even then, storing the params in the object as a mutable state on Router is insane design, because it doesn't belong to Router, but specific to a request itself. Instead of returning ["CommentsController", :edit] and storing { slug: "test-post", id: "12" } into .segments the method should really return ["CommentsController", :edit, { slug: "test-post", id: "12" }] (with empty hash or nil as the third element when no named segments exist). Every MVC framework does this so the action will actually get the params as it is invoked by the framework.

  • Voile Avatar

    Test.expect should not be used.

  • bkim8815 Avatar

    Took me a bit. but figured it out. thank you!

  • westoncooper Avatar

    Thank you for the fun Kata!

  • julescopeland Avatar

    The explanation could use a little work. Maybe break down the methods into separate sections.

    I also think that the fact that you have to save the request_info in an instance variable in the route? method is kinda ganky.

  • sayfidz Avatar

    In retrospect, I am guessing that the intention is for the solution to handle various different ROUTES hashes in this format rather than the example ROUTES hash exclusively. If my interpretation is correct, some additional test cases would be beneficial to weed out solutions that do not handle variations.