Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6210779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:13:13+00:00 2026-05-24T06:13:13+00:00

I have written a custom Ruby Gem to hook into our company’s authentication and

  • 0

I have written a custom Ruby Gem to hook into our company’s authentication and authorization system and am starting to develop the unit tests for the gem.

In our rails app, the Gem can be configured via environment.rb and a custom initializer and yaml file containing the configuration values.

I need to translate the configuration of the Gem in rails to test the standalone Gem. How do I translate this over to Rspec to perform integration testing??

Gem configuration in rails

# environment.rb
MyGem.configure do |config|
  config.url = MY_CONFIG ['url']
  config.application_name = MY_CONFIG ['app_name']
  config.application_id = MY_CONFIG ['app_id']
  config.logger = Rails.logger
  config.log_level = :debug


# Rails config/initalizers/load_config.rb
# Custom config file loading automatically done via initializers
MY_CONFIG = YAML.load_file("#{Rails.root.to_s}/config/my_config.yml")[Rails.env]

# config/my_config.yml
defaults: &defaults
  url: http://url/to/service
  app_name: my app
  app_id: 1

development:
  <<: *defaults

test:
  <<: *defaults

production:
  <<: *defaults

end

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:13:14+00:00Added an answer on May 24, 2026 at 6:13 am

    Here’s a simple project where you can see how you’d go by doing it: multiplier

    First and foremost, if you’re doing the gem management by yourself, please don’t, use helper tools like jeweler to do it for you. Install the jeweler gem (gem install jeweler) and once you have it installed, create your gem projet:

    jeweler --rspec your_gem_name
    

    With this, it’s going to setup a skeleton gem that’s going to have a single main file (where you would require your necessary gem files) and the spec folder.

    At the spec folder there’s spec_helper.rb, that’s where our configuration lives, what I did was:

    $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
    $LOAD_PATH.unshift(File.dirname(__FILE__))
    require 'rspec'
    require 'multiplier'
    
    # Requires supporting files with custom matchers and macros, etc,
    # in ./support/ and its subdirectories.
    Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
    
    RSpec.configure do |config|
    
    end
    
    Multiplier.configure do |config| #these are the only lines I added myself
      config.multiplier 4
    end
    

    So, here lives the config for our gem, but you could even do it on each spec, if you’d need it. But if you want to use a single config for all specs this is where you should place it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a custom preference class which contains a simple progress bar in
I have written a custom CodeActivity for .net Workflow 4.0, and one of my
I have written a custom View which is used to display a tileable pattern,
I have written a custom Validator that expects an attribute to be set. I
I have written a custom interceptor that does some parameter validation. I want to
I have written code for onClick method for Custom Dialog top of the another
Simple performance test, I have installed ruby-prof and no other gems are missing, rake
I created a custom skin with overlaying transparent images and TransparencyKey. http://jesconsultancy.nl/vb.rar (Only right
I know this may be a silly question. but stil i have a confusion.
All, I am getting the com.mysql.jdbc.Driver exception when trying to load the Driver class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.