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

simonpeter
When I try the command to create a pair of migration files I get an error. user=> (create-migration "guestbook") Execution error (Ill...
New
mikecargal
Title: Hands-On Rust (Chapter 11: prefab) Just played a couple of amulet-less games. With a bit of debugging, I believe that your can_p...
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
cro
I am working on the “Your Turn” for chapter one and building out the restart button talked about on page 27. It recommends looking into ...
New
curtosis
Running mix deps.get in the sensor_hub directory fails with the following error: ** (Mix) No SSH public keys found in ~/.ssh. An ssh aut...
New
jskubick
I think I might have found a problem involving SwitchCompat, thumbTint, and trackTint. As entered, the SwitchCompat changes color to hol...
New
oaklandgit
Hi, I completed chapter 6 but am getting the following error when running: thread 'main' panicked at 'Failed to load texture: IoError(O...
New
akraut
The markup used to display the uploaded image results in a Phoenix.LiveView.HTMLTokenizer.ParseError error. lib/pento_web/live/product_l...
New
taguniversalmachine
It seems the second code snippet is missing the code to set the current_user: current_user: Accounts.get_user_by_session_token(session["...
New
Henrai
Hi, I’m working on the Chapter 8 of the book. After I add add the point_offset, I’m still able to see acne: In the image above, I re...
New

Other popular topics Top

malloryerik
Any thoughts on Svelte? Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue...
New
AstonJ
Inspired by this post from @Carter, which languages, frameworks or other tech or tools do you think is killing it right now? :upside_down...
New
Exadra37
I am asking for any distro that only has the bare-bones to be able to get a shell in the server and then just install the packages as we ...
New
AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
New
AstonJ
Seems like a lot of people caught it - just wondered whether any of you did? As far as I know I didn’t, but it wouldn’t surprise me if I...
New
rustkas
Intensively researching Erlang books and additional resources on it, I have found that the topic of using Regular Expressions is either c...
New
PragmaticBookshelf
Author Spotlight James Stanier @jstanier James Stanier, author of Effective Remote Work , discusses how to rethink the office as we e...
New
New
New
AnfaengerAlex
Hello, I’m a beginner in Android development and I’m facing an issue with my project setup. In my build.gradle.kts file, I have the foll...
New

Sub Categories: