BernardK

BernardK

Programming Ruby 3.2 (5th Edition): B1.0 page 269, cd gems/aaagmnr

@noelrappin

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

noelrappin

Author of Modern Front-End Development for Rails

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

Where Next?

Popular Pragmatic Bookshelf topics Top

abtin
page 20: … protoc command… I had to additionally run the following go get commands in order to be able to compile protobuf code using go...
New
jimmykiang
This test is broken right out of the box… — FAIL: TestAgent (7.82s) agent_test.go:77: Error Trace: agent_test.go:77 agent_test.go:...
New
yulkin
your book suggests to use Image.toByteData() to convert image to bytes, however I get the following error: "the getter ‘toByteData’ isn’t...
New
raul
Page 28: It implements io.ReaderAt on the store type. Sorry if it’s a dumb question but was the io.ReaderAt supposed to be io.ReadAt? ...
New
conradwt
First, the code resources: Page 237: rumbl_umbrella/apps/rumbl/mix.exs Note: That this file is missing. Page 238: rumbl_umbrella/app...
New
jskubick
I think I might have found a problem involving SwitchCompat, thumbTint, and trackTint. As entered, the SwitchCompat changes color to hol...
New
adamwoolhether
I’m not quite sure what’s going on here, but I’m unable to have to containers successfully complete the Readiness/Liveness checks. I’m im...
New
jonmac
The allprojects block listed on page 245 produces the following error when syncing gradle: “org.gradle.api.GradleScriptException: A prob...
New
jwandekoken
Book: Programming Phoenix LiveView, page 142 (157/378), file lib/pento_web/live/product_live/form_component.ex, in the function below: d...
New
davetron5000
Hello faithful readers! If you have tried to follow along in the book, you are asked to start up the dev environment via dx/build and ar...
New

Other popular topics Top

DevotionGeo
I know that -t flag is used along with -i flag for getting an interactive shell. But I cannot digest what the man page for docker run com...
New
New
AstonJ
poll poll Be sure to check out @Dusty’s article posted here: An Introduction to Alternative Keyboard Layouts It’s one of the best write-...
New
AstonJ
There’s a whole world of custom keycaps out there that I didn’t know existed! Check out all of our Keycaps threads here: https://forum....
New
Exadra37
On modern versions of macOS, you simply can’t power on your computer, launch a text editor or eBook reader, and write or read, without a ...
New
PragmaticBookshelf
Rails 7 completely redefines what it means to produce fantastic user experiences and provides a way to achieve all the benefits of single...
New
PragmaticBookshelf
Author Spotlight Rebecca Skinner @RebeccaSkinner Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
New
PragmaticBookshelf
Author Spotlight: Karl Stolley @karlstolley Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
New
DevotionGeo
I have always used antique keyboards like Cherry MX 1800 or Cherry MX 8100 and almost always have modified the switches in some way, like...
New
AstonJ
This is cool! DEEPSEEK-V3 ON M4 MAC: BLAZING FAST INFERENCE ON APPLE SILICON We just witnessed something incredible: the largest open-s...
New

Sub Categories: