Skip to content

Instantly share code, notes, and snippets.

@krisleech
Created October 23, 2017 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krisleech/80ad3432411bf46ea5ff09b3a805203f to your computer and use it in GitHub Desktop.
Save krisleech/80ad3432411bf46ea5ff09b3a805203f to your computer and use it in GitHub Desktop.
Sharing RSpec configuration between multiple codebases

Sharing Standard RSpec configuration between multiple projects.

In our example we have a gem called Oxygen which contains all non-framework code shared between all the codebases (repo's) which make up our system.

module Oxygen
  module RSpec
    def self.configure!
      ::RSpec.configure(&Configuration)
    end

    # Standard RSpec configuration
    #
    # @example
    #  RSpec.configure(&Configuration)
    #
    Configuration = lambda do |config|
      config.warnings = true
      config.example_status_persistence_file_path = "/tmp/core_example.txt"

      # disable `should` syntax
      config.expect_with :rspec do |c|
        c.syntax = :expect
      end

      config.mock_with :rspec do |c|
        c.syntax = :expect
      end

      config.filter_run :focus => true
      config.run_all_when_everything_filtered = true
    end
  end
end

You can use this in spec_helper with:

require 'oxygen/rspec/configuration'
Oxygen::RSpec.configure!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment