Giter VIP home page Giter VIP logo

ruby-exercises's Introduction

The Odin Project

The Odin Project (TOP) is an open-source curriculum for learning full-stack web development. Our mission is to provide a comprehensive curriculum to learn web development for free. We help users learn the skills and build the impressive portfolio of projects they need to get hired as a web developer.

Some of the topics we cover include:

  • Ruby
  • Ruby on Rails
  • SQL
  • HTML and CSS
  • Javascript
  • Node
  • React
  • How to go about getting a job in the industry

This repo contains the TOP app which pulls in lesson content as well as front-end and back-end code. To see the actual lesson content that gets pulled in, please go to the TOP curriculum repo.

Our community can be found on the TOP Discord server.

Contributing

Build Status

The Odin Project depends on open-source contributions to improve, grow, and thrive. We welcome contributors of all experience levels and backgrounds to help maintain this awesome curriculum and community. If you would like to contribute to our curriculum, be sure to thoroughly read our contributing guide.

Feel free to also watch this scrimba walkthrough of The Odin Project web app repo, which will give you an introduction to this repository. Note that since this scrimba was recorded, the content and/or structure may have changed in this repo. The focus of this scrimba is less on the actual content, but more of a high level overview.

ruby-exercises's People

Contributors

adub648 avatar alexaldearroyo avatar asartea avatar austinmccallister avatar bananakiu avatar c-auri avatar chargrilledchook avatar couchoftomato avatar edimossilva avatar eduardo06sp avatar joaquinrponce avatar joshdevhub avatar kellydanma avatar kevinmulhern avatar leila-alderman avatar lynn-otto avatar maheshkumar-novice avatar marvingay avatar mgrigoriev8109 avatar msespos avatar rlmoser99 avatar scheals avatar thatblindgeye avatar wise-king-sullyman avatar zachmmeyer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ruby-exercises's Issues

Array exercises

On line 22 in the array_exercises.rb file, the task is to return the second index of the array - the test passes on array[2] when asking for the second index, when it should be passing on array[1]

Chore: Documentation For How to Set the Project Up

Description

We need instructions in the root README on what the student needs to do to set the project up

Acceptance Criteria

  1. The README should include an introduction explaining what the repo is for and what it contains
  2. The README should include an installations section explaining how to set the project up on their machine, git clone, running bundle install etc.
  3. The README should include a section on how the student can run their first test.

Additional Notes

Our older archived test first ruby repo might be a good example to follow: https://github.com/TheOdinProject/learn_ruby

Bug - Could not locate Gemfile or .bundle/ directory

Complete the following REQUIRED checkboxes:

  • [✔] I have thoroughly read and understand The Odin Project Contributing Guide
  • [✔] The title of this issue follows the Bug - location of bug: brief description of bug format, e.g. Bug - Exercises: File type incorrect for all test files

The following checkbox is OPTIONAL:

  • I would like to be assigned this issue to work on it

1. Description of the Bug:

I'm aware of this discussion: Debugging exercises with bundle exec commands #72
and this pull request: Provide instructions to install and use RSpec globally #80

So I can see why the decision of removing the Gemfile has been done.
I do have experience with Rails, but it's been a while since I've used Ruby on its own.
Maybe there is a way to make Rspec run without a Gemfile, but I'm struggling to find how.
And apparently, I'm not the only one: https://stackoverflow.com/questions/12307097/how-to-use-rspec-without-rails

2. How To Reproduce:

Following the instructions this happens:

❯ gem install rspec
Successfully installed rspec-3.12.0
Parsing documentation for rspec-3.12.0
Done installing documentation for rspec after 0 seconds
1 gem installed
❯ rspec
Could not locate Gemfile or .bundle/ directory

3. Expected Behavior:

❯ git checkout e365f82 (note from Salomanuel - that commit is * / e365f82 - Fri, 21 Oct 2022 21:25:56 -0500 (4 months ago) PR Template: Flip order of checklist and details (#79))
You are in 'detached HEAD' state. blablabla
❯ bundle install
blablabla
Bundle complete! 1 Gemfile dependency, 7 gems now installed.
❯ rspec
blablabla
Finished in 0.03875 seconds (files took 0.13611 seconds to load)
32 examples, 2 failures, 28 pending

4. Desktop/Device:

❯ ruby -v
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
❯ gem install rspec
Successfully installed rspec-3.12.0

OS: Ubuntu 20.04.5 LTS on Windows 10 x86_64
Shell: zsh 5.8

5. Additional Information:

Bug - Exercise`hash_exercises.rb`:`favorite_list` should be renamed to `favorite_hash`

Complete the following REQUIRED checkboxes:

  • I have thoroughly read and understand The Odin Project Contributing Guide
  • The title of this issue follows the Bug - location of bug: brief description of bug format, e.g. Bug - Exercises: File type incorrect for all test files

The following checkbox is OPTIONAL:

  • I would like to be assigned this issue to work on it

1. Description of the Bug:

Using the parameter name favorite_hash instead of favorite_list would leave the least amount of room for ambiguity.

It's not obvious that favorite_list is meant to be a hash, as opposed to a list of hashes.

It's also unclear because the first method to be implemented is called create_favorite_hash(), not create_favorite_list().

Everything was clear once I checked hash_exercises_spec.rb. But from the perspective of someone who is brand new to programming and doesn't necessarily understand how to read a test file, this may not be obvious.

(I do recognize that this is more of an opinion than a bug, as someone who is more familiar with Python and thinks of arrays as lists, and hashes as dictionaries.)

2. How To Reproduce:

Open ruby_basics/7_hashes/exercises/hash_exercises.rb.

3. Expected Behavior:

I would have expected the method argument to be named favorite_hash if the expected input is to be a hash.

4. Desktop/Device: N/A for this bug, but ok :)

  • Device: Macbook Pro
  • OS: Ventura
  • Browser: Chrome
  • Version:

5. Additional Information:

Fix test case for #find_favorite in nested array exercises

In the Odin discord, someone posted the following "solution" to the #find_favorite exercise in nested_array_exercises.rb where the goal is to write a method that takes an array of hash objects and returns the hash object with the key: value pair of is_my_favorite?: true -- or nil if no such hash object exists.

def find_favorite(array_of_hash_objects)
  array_of_hash_objects.each do |data|
    if data[:is_my_favorite?] == true
      return data
    else
      return nil
    end
  end
end

The case that's true for the first element in array_of_hash_objects is what will get returned from the method, which doesn't solve the problem of returning the hash with the key: value pair of is_my_favorite?: true. However since the tests for this method (which are here) only ever provide an array with a hash holding :is_my_favorite?: true at the 0th index, the tests pass for this solution just fine. I'd like to submit a PR that properly fails the above code by either:

  1. Adding a test case that has the { name: 'Ruby', is_my_favorite?: true } hash at a non-zero index of the let array.
  2. Just changing the existing test case to place the { name: 'Ruby', is_my_favorite?: true} at a non-zero index of the let array. I think it could be fine to just stick with the one case and place it in the middle of the array at index 1, as it seems unlikely someone would stumble into writing something that passes with it in the middle of the array while also not being a true solution to the problem.

Let me know what you think 👍

Specs: specs from numbers_exercises_spec have only one test case for some methods

  • I have thoroughly read and understand The Odin Project Contributing Guide
  • The title of this issue follows the location for request: brief description of request format, e.g. Exercises: Add exercise on XYZ
  • I would like to be assigned this issue to work on it

1. Description of the Feature Request:
The methods add, subtract, multiply, divide and float_division have only one test case for them.

e.g. I suggested to a student to do the numbers exercise and the student did the following code:

def add(a, b)
  a = 1
  b = 2
  a + b
end

2. Acceptance Criteria:

  • Add additional specs for the methods add, subtract, multiply, divide and float_division to prevent hard coded solutions

e.g. Two specs for the sum method

   it 'adds two numbers' do
      expect(add(1, 2)).to eq(3)
      expect(add(4, 3)).to eq(7)
    end

Debugging exercises with bundle exec commands

Currently, the instructions for these exercises want users to install rspec from the Gemfile using bundle install and then from there, run tests using bundle exec rspec path_to/file_spec.rb. This works fine up until users start the debugging content, where the user cannot access their global install of pry-byebug while running commands prefixed with bundle exec -- leading to require bugs that learners at this stage have a difficult time figuring out. Here's an example from the discord server today, but it has happened multiple times since the debugging exercises were introduced.

I think there are two good ways to approach fixing the problem:

  1. Go ahead and have the users globally install RSpec -- this is done later down the line anyway -- and then forgo the use of bundle exec entirely.
  2. Place pry-byebug in the Gemfile. It will then be installed in the users' local repo when they initially run bundle install, which will eliminate require errors when using bundle exec.

Would be glad to submit a PR for whichever method is preferable. Also definitely open to other ideas if there are other ways to make this work more smoothly.

Verbose instructions in ruby_basics

The instructions for running a test suite are verbose for sections with 1 file. It may be worth explaining to students that bundler is aware of all *_spec.rb files.

For example, the following suffices when there is a single *_spec.rb file :

$ cd 6_arrays
$ bundle exec rspec

This could be added as a tip after the current usage instructions. Note that the same command will execute all *_spec.rb files if there are multiple, so specifying the path is still a good way to run a single test file.

Ruby Course - Basic Data Types - Assignment - 1_data_types exercises

First of all, I just wanted to say that it's great to have the solutions for the exercises in the Ruby course, so I thank the team for that!

I've arrived to different solutions for the purposed exercises, and I was wondering if you would consider including more than one correct answer to the solutions branch.

For example, in the string_exercises.rb file:

  • I have this solution for line 8:
"Hello #{string}!"
  • And this one for line 13
word[0..3]

Feature: Numbers Exercises for Basic Data Types

Description

After the student has gone through the Basic Data Types Lesson it would be good for them to practice what they have learnt by completing a few exercises.

Acceptance Criteria

The following exercises should be created for numbers:

  • An exercise for adding
  • An exercise for subtracting
  • An exercise for multiplying
  • An exercise for dividing
  • An exercise that uses the Modulus operator
  • Another exercise for dividing, but the expected output should be a float.
  • An exercise for converting a string to a number with to_i
  • An exercise for checking if a number is even
  • An exercise for checking if a number is odd

Bonus:

  • Circumference of a circle exercise
  • Celsius to fahrenheit exercise and vice versa

Additional Notes

We have an example exercise and test which demonstrates the pattern that should be followed for the numbers exercises.

Add nested collections exercises

Lesson:
https://www.theodinproject.com/paths/full-stack-ruby-on-rails/courses/ruby-programming/lessons/nested-collections

For this lesson, let's use two different files, one for nested arrays and one for nested hashes. Write at least 2 tests for each method, possibly even another one to handle edge cases (sometimes the documentation for a method provides insight for edge cases).

Nested Arrays

  • Create a new array that is not mutable
  • Add an element to one (or more) nested array
  • Add another nested array
  • Delete an element of one (or more) nested arrays
  • Delete a nested array
  • Iterate over a nested array (use any method previously introduced or can include a hint for a new one)
  • Access data and/or iterate with an example of a hash inside the array, such as:
people = [
 { 
    name: "Barry",
    age: 65,
    hobbies: ["Fishing", "Beat Boxing"],
    country: "USA"
  },
  {
    name: "Janet",
    age: 34,
    hobbies: ["Bob Sledding", "Parkour"],
    country: "UK"
  }
]

Nested Hashes

  • Add key/value pair to one (or more) nested hash
  • Add another nested hash
  • Delete key/value pair of one (or more) nested hash
  • Delete one (ore more) of the nested hashes
  • Iterate over a nested hash (use any method previously introduced or can include a hint for a new one)
  • Access data and/or iterate with an example of an array inside the hash (like the 1st reading assignment)

Tip: The more realistic the method & parameter names the better for these examples. The earlier lessons were a little difficult to accomplish this, but as the lessons progressed, the easier it was to come up with meaningful names.

Feature: Strings Exercises for Basic Data Types

Description

After the student has gone through the Basic Data Types Lesson it would be good for them to practice what they have learnt by completing a few exercises.

Acceptance Criteria

The following exercises should be created for strings:

  • An exercise for sub strings
  • An exercise that uses some escape characters - the newline escape character is the most practical
  • An exercise for capitalising the given string
  • An exercise for upper casing the given string
  • An exercise for down casing the given string
  • An exercise for checking if a given string is empty
  • An exercise for checking the length of a given string
  • An exercise for reversing a string
  • An exercise for stripping a given string of white space.

Additional Notes

These exercises should go in the existing string_exercises file.

We have an example exercise and test which demonstrates the pattern that should be followed for the strings exercises.

Subtraction exercise in 1_data_types is incorrect

This passes the check:

def subtract(a, b)
/# return the result of subtracting a from b
a-b
end

However, "subtracting a from b" means b-a. The comment and the code checker are opposite each other.

incorrect wording hash_exercises


  describe 'update favorite number exercise' do

    it 'returns hash with a new key/value pair when not included' do
      my_favorites = { color: 'blue', number: 65 }
      result = { color: 'blue', number: 65, movie: 'Avengers: Endgame' }
      expect(update_favorite_movie(my_favorites, 'Avengers: Endgame')).to eq(result)
    end

    it 'returns hash with an updated key/value pair when included' do
      my_favorites = { color: 'emerald green', movie: 'Avengers: Endgame' }
      result = { color: 'emerald green', movie: 'Avengers: Infinity War' }
      expect(update_favorite_movie(my_favorites, 'Avengers: Infinity War')).to eq(result)
    end
  end

This is described as favorite number but it calls favorite movie

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.