Skip to content

Latest commit

 

History

History
41 lines (31 loc) · 1.68 KB

README.md

File metadata and controls

41 lines (31 loc) · 1.68 KB

Rubocop: The Future of Standards Enforcement

Skill Level: Beginner - Intermediate

Time Limit: 45 minutes

This is a challenge for learning Rubocop and how to do things the 'ruby' way. You will also learn about refactoring and why it's important.

Instructions

You have been tasked to clean up Gem City. Luckily, your boss has paired you up with the newest advancement in code enforcement technology, Rubocop.

  1. Install the required gems
gem install bundler
bundle install
  1. Run rspec with rspec gem_city_spec.rb and then get a feel for the code that's passing.
  2. Run rubocop with rubocop or rubocop <filename> and see what's failing.
  3. Correct all rubocop errors.
  4. Rerun the tests and rubocop. If there are no complaints, congratulations you've successfully cleaned up the streets of Gem City. There are 3 lines in the rspec file that you can change, leave the rest.

Bonus: Write the city demographics feature

  • Uncomment the block of code at the end of the spec file
  • Write the code to make the test pass.
  • Run rubocop and then make the corrections.
  • Rerun your test. If it passes, you've successfully refactored your function.

Advanced Challenge: See how short you can make the GemCity class while still passing Rubocop and rspec tests

Things to think about

  • Why would you want to follow standards?
  • What is the purpose of refactoring, if it works, why refactor?
  • How can refactoring help us expand our code?
  • The bonus challenge follows a process called Red, Green, Refactor.

Resources