Challenge - 5 Problems
Gemfile Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Gemfile dependency version resolution?
Given this Gemfile snippet, what version of the 'rails' gem will Bundler install?
source 'https://rubygems.org' gem 'rails', '~> 6.1.0' gem 'rails', '>= 6.1.3'
Ruby
source 'https://rubygems.org' gem 'rails', '~> 6.1.0' gem 'rails', '>= 6.1.3'
Attempts:
2 left
💡 Hint
The '~>' operator means 'compatible with', and the '>= 6.1.3' means minimum version 6.1.3.
✗ Incorrect
The '~> 6.1.0' means any version >= 6.1.0 and < 6.2.0. The '>= 6.1.3' means minimum 6.1.3. Bundler picks the intersection, so versions >= 6.1.3 and < 6.2.0.
🧠 Conceptual
intermediate1:30remaining
Which source declaration is correct in a Gemfile?
You want to specify the source for gems in your Gemfile. Which of these is the correct way to declare the source?
Attempts:
2 left
💡 Hint
Look for the keyword used to specify gem sources in Gemfile syntax.
✗ Incorrect
The correct syntax to specify the gem source is using the 'source' keyword followed by the URL in quotes.
🔧 Debug
advanced2:00remaining
Why does this Gemfile cause a syntax error?
Examine this Gemfile snippet and identify why it causes a syntax error:
source 'https://rubygems.org' gem 'nokogiri', '~> 1.12.0' gem 'puma', '~> 5.0' gem 'rails', '~> 6.1.0' end
Ruby
source 'https://rubygems.org' gem 'nokogiri', '~> 1.12.0' gem 'puma', '~> 5.0' gem 'rails', '~> 6.1.0' end
Attempts:
2 left
💡 Hint
Check if all keywords and blocks are properly opened and closed.
✗ Incorrect
There is no block opened that requires an 'end'. The 'end' keyword is extra and causes a syntax error.
🚀 Application
advanced2:00remaining
How to specify a gem from a Git repository in Gemfile?
You want to use a gem directly from a GitHub repository instead of RubyGems. Which Gemfile line correctly specifies this?
Attempts:
2 left
💡 Hint
Look for the keyword that specifies a git repository in gem declaration.
✗ Incorrect
The correct syntax uses the 'git:' option to specify the git repository URL.
❓ Predict Output
expert2:30remaining
How many gems will be installed by Bundler from this Gemfile?
Consider this Gemfile snippet:
How many gems will Bundler install when running in the test environment?
source 'https://rubygems.org' group :development, :test do gem 'rspec' gem 'pry' end group :production do gem 'puma' end gem 'rails'
How many gems will Bundler install when running in the test environment?
Ruby
source 'https://rubygems.org' group :development, :test do gem 'rspec' gem 'pry' end group :production do gem 'puma' end gem 'rails'
Attempts:
2 left
💡 Hint
Bundler installs gems in the default group plus the groups for the current environment.
✗ Incorrect
In the test environment, Bundler installs gems in the default group (rails) plus the :test and :development groups (rspec, pry). The :production group gems are excluded.