
BernardK
Programming Ruby 3.2 (5th Edition): B1.0 page 269, cd gems/aaagmnr
page 269, running rspec
These tests pass (after you update the .gemspec file):
$ rspec spec/aaagmnr/options_spec.rb
It would be worth to explicitly mention to cd
to code/gems/aaagmnr
before running the test. As I work in code
, I had an error :
% rspec -fd gems/aaagmnr/spec/aaagmnr/options_spec.rb
An error occurred while loading ./gems/aaagmnr/spec/aaagmnr/options_spec.rb.
Failure/Error:
RSpec.describe Options do
...
NameError:
uninitialized constant Aaagmnr::Options
...
0 examples, 0 failures, 1 error occurred outside of examples
I was able to solve it by adding
require_relative '../../lib/aaagmnr'
in options_spec.rb
, but it’s not what you have planned.
The trick is that if we are in code/gems/aaagmnr
, RSpec can silently load .rspec
--format documentation
--color
--require spec_helper
which requires spec/spec_helper.rb
. Thanks to require "aaagmnr"
in spec_helper
, all the required files are loaded.
Without this infrastructure in code/gems/aaagmnr
, for example if I delete .rspec
or spec_helper.rb
, nothing works :
% rspec spec/aaagmnr/options_spec.rb
Resolving dependencies...
An error occurred while loading spec_helper.
Failure/Error: __send__(method, file)
LoadError:
cannot load such file -- spec_helper
First Post!

noelrappin
I think we’ll just note that you should run the specs from the root directory of the gem. Thanks!
Popular Prag Prog topics










Other popular topics










Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /ash
- /centos
- /php
- /deepseek
- /scala
- /zig
- /html
- /debian
- /nixos
- /lisp
- /agda
- /sublime-text
- /react-native
- /textmate
- /kubuntu
- /arch-linux
- /ubuntu
- /revery
- /manjaro
- /spring
- /django
- /diversity
- /nodejs
- /lua
- /c
- /slackware
- /julia
- /neovim