title: Gem testing with Rspec
body: <p>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.</p>
  
  <p>In our rails app, the Gem can be configured via <strong>environment.rb</strong> and a custom initializer and yaml file containing the configuration values.</p>
  
  <p>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??</p>
  
  <p>Gem configuration in rails</p>
  
  <pre><code># 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: &amp;defaults
    url: http://url/to/service
    app_name: my app
    app_id: 1
  
  development:
    &lt;&lt;: *defaults
  
  test:
    &lt;&lt;: *defaults
  
  production:
    &lt;&lt;: *defaults
  </code></pre>
  
  <p>end</p>