Skip to content
This repository was archived by the owner on Jun 6, 2025. It is now read-only.

Repository files navigation

Archival Notice

This repository will no longer be maintained by UserTesting, and will be archived in the near future. The most recent version of this gem will still be published and available to use. Thank you to everyone who contributed to this project!

racym

TravisCoveralls githubCode Climate maintainability

Rails Application Configuration for Yield Main (RACYM)

racym is used as a shortcut to rails configuration.

Installation

Add this line to your application's Gemfile:

gem"racym"

And then execute:

$ bundleinstall

Usage

Setting config values

In your config/application.rb add config settings:

moduleMyAppclassApplication < Rails::Application
...
# Add a custom config setting here:config.foo="bar"# Or a proc:config.biz=->{DateTime.current}

Getting config values

From anywhere in your Rails application (controllers/helpers/views - should be available anywhere!)

putsracym(:foo)# => "bar"putsracym(:biz)# => Wed, 02 Oct 2019 11:13:20 -0700# ten minutes later:putsracym(:biz)# => Wed, 02 Oct 2019 11:23:20 -0700

Multilevel key/values

Setting:

moduleMyAppclassApplication < Rails::Application
...
config.foo.username="BAR"config.foo.password="BIZ"

Getting:

putsracym(:foo,:username)# => "BAR"putsracym(:foo,:password)# => "BIZ"

Testing

There's some convenient methods you can use to test code using racym:

  • racym_set
  • racym_undo!

For example, to test this simple method:

classFoodefself.hi"Hi #{racym:person_to_hi}"endend
describeFoododescribe".hi"dobefore{racym_set:person_to_hi,"Dave"}specify{expect(Foo.hi).toeq"Hi Dave"}after{racym_undo!}endend

License

MIT.

Library created by UserTesting

UserTesting

Contributing

  1. Fork it ( https://github.com/usertesting/racym/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

Rails Application Configuration for Yield Main

Topics

Resources

Stars

0 stars

Watchers

9 watching

Forks

Releases

Packages

Used by

Contributors

Languages