Gem with multiple requirements in gemfile

So, I have this stone, and it depends on many other gems. Although gemspec says

s.add_dependency "haml" ... 

the package doesn't seem to care, so I have to redo this dependency in the Gemfile. Is there a syntax requiring multiple gems? Something like this (doesn't work):

 gem "so-and-so", :git => "some-repo", :require => ["this-gem", "that-gem", "and-what-not"] 

require seems to only allow one object

+4
source share
3 answers

According to the Gemfile documentation Gemfile you can simply pass an array of requests. I address this issue by examining RSpec as syntactic sugar for Minitest and noting what I need:

 require 'minitest/spec' require 'minitest/autorun' 

To make it work. I have never tried a few queries in the Gemfile before, and googling led me here to this question, and more Googling led me to Gemfile that say:

 REQUIRE AS (:require) Each gem MAY specify files that should be used when autorequiring via Bundler.require. You may pass an array with multiple files, or false to prevent any file from being autorequired. gem "sqlite3-ruby", :require => "sqlite3" gem "redis", :require => ["redis/connection/hiredis", "redis"] gem "webmock", :require => false 

So in my Gemfile I turned on

 group :test do gem 'minitest', require: ['minitest/autorun', 'minitest/spec'] gem 'rack-test', require: 'rack/test' gem 'simplecov', require: false end 

Which works fine and allows me to write a test like

 describe 'basic crud' do it 'must create a user with valid details' do User.transaction do user = User.create!(username: 'test', password: 'pass') user.username.must_equal 'test' user.destroy end end end 

What I find reads better than assert_equals user.username, 'test' and gives me access to my familiar methods of preparing and cleaning before :each do… and after :all do…

+4
source

I'm sure Bundler is looking at gems to manage his addictions. The idea is that you don't need syntax to define dependencies, because the stone does this for you in the gemspec file. As stated in the bundler docs , the require keyword is used for: "If the main gem file is different from the gem name, specify how to request it.

If gem has s.add_dependency 'haml' ... and it doesn’t work, then either the gem gempsec file has an error, or the bundler version has an error (or it is too outdated to know about dependencies or something). I would report this to the authors of the gem.

One workaround that you could use until you figure out what's wrong with the gem or its dependencies is to put the gem and other necessary gems that it uses in the group and add a comment to the Gemfile that mentions why you do it.

What pearls are you having problems with? If you provide a name that others can verify that you are experiencing, or give you the best help. Also, what happens when trying a gem dependency gem_name in a shell?

0
source

You should tell the provider to use your gemspec as a source for dependencies. To do this, just paste it into your Gemfile

 source "http://rubygems.org" # require this gem dependencies gemspec 

Typically for a gem, this is the only content of the Gemfile .

0
source

Source: https://habr.com/ru/post/1394392/


All Articles