在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:jdeslangles/wdi-koans开源软件地址:https://github.com/jdeslangles/wdi-koans开源编程语言:Ruby 100.0%开源软件介绍:¶ ↑Neo Ruby KoansThe Ruby Koans walk you along the path to enlightenment in order to learn Ruby. The goal is to learn the Ruby language, syntax, structure, and some common functions and libraries. We also teach you culture. Testing is not just something we pay lip service to, but something we live. It is essential in your quest to learn and do great things in the language. ¶ ↑The StructureThe koans are broken out into areas by file, hashes are covered in about_hashes.rb, modules are introduced in about_modules.rb, etc. They are presented in order in the path_to_enlightenment.rb file. Each koan builds up your knowledge of Ruby and builds upon itself. It will stop at the first place you need to correct. Some koans simply need to have the correct answer substituted for an incorrect one. Some, however, require you to supply your own answer. If you see the method ¶ ↑Installing RubyIf you do not have Ruby setup, please visit ruby-lang.org/en/downloads/ for operating specific instructions. In order to run this you need ruby and rake installed. To check the installations simply type: *nix platforms from any terminal window: [~] $ ruby --version [~] $ rake --version Windows from the command prompt (cmd.exe) c:\ruby --version c:\rake --version If you don't have rake installed, just run `gem install rake` Any response for Ruby with a version number greater than 1.8 is fine (should be around 1.8.6 or more). Any version of rake will do. ¶ ↑Generating the KoansA fresh checkout will not include the koans, you will need to generate them. [ruby_koans] $ rake gen # generates the koans directory If you need to regenerate the koans, thus wiping your current `koans`, [ruby_koans] $ rake regen # regenerates the koans directory, wiping the original ¶ ↑The Path To EnlightenmentYou can run the tests through rake or by calling the file itself (rake is the recommended way to run them as we might build more functionality into this task). *nix platforms, from the koans directory [ruby_koans] $ rake # runs the default target :walk_the_path [ruby_koans] $ ruby path_to_enlightenment.rb # simply call the file directly Windows is the same thing c:\ruby_koans\rake # runs the default target :walk_the_path c:\ruby_koans\ruby path_to_enlightenment.rb # simply call the file directly ¶ ↑Red, Green, RefactorIn test-driven development the mantra has always been, red, green, refactor. Write a failing test and run it (red), make the test pass (green), then refactor it (that is look at the code and see if you can make it any better). In this case you will need to run the koan and see it fail (red), make the test pass (green), then take a moment and reflect upon the test to see what it is teaching you and improve the code to better communicate its intent (refactor). The very first time you run it you will see the following output: [ ruby_koans ] $ rake (in /Users/person/dev/ruby_koans) /usr/bin/ruby1.8 path_to_enlightenment.rb AboutAsserts#test_assert_truth has damaged your karma. The Master says: You have not yet reached enlightenment. The answers you seek... <false> is not true. Please meditate on the following code: ./about_asserts.rb:10:in `test_assert_truth' path_to_enlightenment.rb:38:in `each_with_index' path_to_enlightenment.rb:38 mountains are merely mountains your path thus far [X_________________________________________________] 0/280 You have come to your first stage. If you notice it is telling you where to look for the first solution: Please meditate on the following code: ./about_asserts.rb:10:in `test_assert_truth' path_to_enlightenment.rb:38:in `each_with_index' path_to_enlightenment.rb:38 We then open up the about_asserts.rb file and look at the first test: # We shall contemplate truth by testing reality, via asserts. def test_assert_truth assert false # This should be true end We then change the In this case the goal is for you to see that if you pass a value to the ¶ ↑InspirationA special thanks to Mike Clark and Ara Howard for inspiring this project. Mike Clark wrote an excellent blog post about learning Ruby through unit testing. This sparked an idea that has taken a bit to solidify, that of bringing new rubyists into the community through testing. Ara Howard then gave us the idea for the Koans in his ruby quiz entry on Meta Koans (a must for any rubyist wanting to improve their skills). Also, “The Little Lisper” taught us all the value of the short questions/simple answers style of learning.
¶ ↑Other Resources
¶ ↑Other stuff
¶ ↑LicenseRubyKoans is released under a Creative Commons, Attribution-NonCommercial-ShareAlike, Version 3.0 (creativecommons.org/licenses/by-nc-sa/3.0/) License. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论