Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tcfg

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tcfg

  • 0.2.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

TCFG

TCFG (pronounced "tee config") is test suite configuration for the real world. TCFG offers:

  • Support for easily controlling which environment your tests execute against

  • A tiered structure to configuration which allows for every kind of configuration scenario to be supported.

  • Support for easily integrating standalone test suites into common Continuous Integration platforms like Jenkins.

Background

The Wiki contains more in depth information. Some good places to start:

  • Test suite configuration manifesto

  • The tiers of configuration in TCFG

Getting started

Using in RSpec

Start by installing the gem:

$ gem install tcfg

In the project root, make a yaml file called tcfg.yml that contains all configuration you want to be able to control. For a selenium suite, it might look something like this:

---
#start with basic defaults
BROWSER: firefox
BASE_URL: http://localhost:8080
LOG_LEVEL: INFO

#This is a special section with overrides by 'environment'
t_environments:
  QA:
    BASE_URL: http://qa.mysite.com

  Production:
    BASE_URL: https://mysite.com

Then configure RSpec to use tcfg in your spec helper file (typically called spec/spec_helper.rb):

require 'tcfg'

RSpec.configure do |config|
  config.include TCFG::Helper
end

Now you can access configuration in any before, after, or it block, like:

require 'selenium-webdriver'
RSpec.configure do |config|
  config.before(:all) do
    @browser = Selenium::WebDriver.for tcfg['BROWSER']
  end

  config.before(:each) do
    @browser.get tcfg['BASE_URL']
  end

end

If you need to access configuration outside of a before, after, or it block you can use the TCFG module directly:

Log.level = TCFG['LOG_LEVEL']

To control your test suite, you can use environment variables. To change the browser used:

#To execute with all default configuration
$ rspec

#To change the browser used
$ T_BROWSER=chrome rspec

#To change which environment the tests execute against:
$ T_ENVIRONMENT=QA rspec

Other uses

TCFG is a general purpose configuration framework. It should be possible to use with most Ruby test frameworks or even for non testing uses. If you have a use and aren't sure how to handle it with tcfg, file an issue we'll see if we can help you out.

Examples

TCFG is used in several projects that demonstrate it's capabilities.

FAQs

Package last updated on 11 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc