Recall & Review
beginner
What is a gem version constraint in Ruby?
A gem version constraint tells RubyGems which versions of a gem are allowed to be installed. It helps control compatibility by specifying version ranges or exact versions.
Click to reveal answer
intermediate
What does the '~> 2.3' version constraint mean?
The '~> 2.3' constraint means any version >= 2.3.0 and < 3.0.0. It allows updates that do not change the leftmost digit before the dot.
Click to reveal answer
beginner
How do you specify an exact gem version in a Gemfile?
You specify an exact version by using the '=' operator, like gem 'rails', '= 6.1.4'. This installs only that exact version.
Click to reveal answer
beginner
What does the version constraint '>= 1.5' mean?
It means any version greater than or equal to 1.5 is allowed. This lets RubyGems install 1.5 or any newer version.
Click to reveal answer
beginner
Why use version constraints in your Gemfile?
Version constraints help keep your app stable by preventing incompatible gem updates. They ensure your app uses gem versions you have tested.
Click to reveal answer
What does the version constraint '~> 1.2.3' allow?
✗ Incorrect
The '~> 1.2.3' constraint allows versions from 1.2.3 up to but not including 1.3.0.
How do you specify a gem version exactly 2.0.1 in a Gemfile?
✗ Incorrect
Using '= 2.0.1' installs exactly version 2.0.1.
What does '>= 3.0' mean in a gem version constraint?
✗ Incorrect
The '>= 3.0' constraint allows version 3.0 and any newer versions.
Which constraint allows any version less than 2.0?
✗ Incorrect
The '< 2.0' constraint allows any version below 2.0.
Why is it important to use version constraints in your Gemfile?
✗ Incorrect
Version constraints help avoid installing gem versions that might break your app.
Explain how the pessimistic version constraint '~>' works in Ruby gems.
Think about how '~>' limits updates to compatible versions.
You got /3 concepts.
Describe why specifying exact or range versions for gems is important in a Ruby project.
Consider what happens if a gem updates with breaking changes.
You got /4 concepts.