{"id":15405594,"url":"https://github.com/krisleech/spec_requirer","last_synced_at":"2025-03-24T21:41:23.646Z","repository":{"id":18032864,"uuid":"21071637","full_name":"krisleech/spec_requirer","owner":"krisleech","description":"Explicitly require files and manage LOAD_PATH in tests which do not boot a framework","archived":false,"fork":false,"pushed_at":"2014-07-07T14:23:13.000Z","size":184,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-17T04:44:47.124Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/krisleech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-21T15:25:57.000Z","updated_at":"2014-09-30T12:14:19.000Z","dependencies_parsed_at":"2022-08-26T10:51:45.453Z","dependency_job_id":null,"html_url":"https://github.com/krisleech/spec_requirer","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krisleech%2Fspec_requirer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krisleech%2Fspec_requirer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krisleech%2Fspec_requirer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krisleech%2Fspec_requirer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krisleech","download_url":"https://codeload.github.com/krisleech/spec_requirer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245359248,"owners_count":20602322,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T16:17:24.625Z","updated_at":"2025-03-24T21:41:23.618Z","avatar_url":"https://github.com/krisleech.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SpecRequirer\n\n[![Gem Version](https://badge.fury.io/rb/spec_requirer.png)](http://badge.fury.io/rb/spec_requirer)\n[![Code Climate](https://codeclimate.com/github/krisleech/spec_requirer.png)](https://codeclimate.com/github/krisleech/spec_requirer)\n[![Build Status](https://travis-ci.org/krisleech/spec_requirer.png?branch=master)](https://travis-ci.org/krisleech/spec_requirer)\n[![Coverage Status](https://coveralls.io/repos/krisleech/spec_requirer/badge.png?branch=master)](https://coveralls.io/r/krisleech/spec_requirer?branch=master)\n\nHelps require files and manage the `LOAD_PATH` of application unit tests which \ndo not boot the framework.\n\nFor example in Rails if you want fast unit tests you do not boot Rails.\nHowever this means that \"app/models\" etc. are not added to the `LOAD_PATH`. \nThis typically means you need to either add the paths or use `require_relative`.\n\n* Explicit requiring of files\n* Additional meta-information about the required files\n* Adds paths to the `LOAD_PATH`\n\nRequire only what you need, keep it light and explicit.\n\n## Installation\n\n```ruby\ngem 'spec_requirer', group: :test, github: 'krisleech/requirer', tag: 'v0.0.1'\n```\n\nThis is not released to Rubygems yet.\n\n## Usage\n\nIn your `test_helper` / `spec_helper`:\n\n```ruby\nrequire 'pathname'\nrequire 'spec_requirer'\n\nSpecRequirer.setup(app_root: Pathname(File.dirname(__FILE__)).join('..'),\n                   components: ['models', 'services', 'presenters'])\n```\n\nIn a Rails app the `app_root` would be the `app` directory.\n\n### Require helpers\n\nFor each component a require helper is added which lets you do:\n\n```ruby\nrequire_models 'user', 'reward', 'prize'\n\nrequire_presenters 'user_presenter'\n\nrequire_services 'create_user'\n```\n\n### $LOAD_PATH helpers\n\nSimilarly a \"uses\" method is added which adds a directory to the `$LOAD_PATH`:\n\n```ruby\nuses_models\nuses_presenters\nuses_services\n\nrequire 'user'\nrequire 'user_presenter'\nrequire 'create_user'\n```\n\nOr you can use the one-line version as such:\n\n```ruby\nuses :models, :presenters, :services\n```\n\n## Configuration\n\nCommented out options are not yet implemented.\n\n```ruby\nrequire 'pathname'\nrequire 'spec_requirer'\n\nSpecRequirer.configure do |config|\n  config.app_root = Pathname(__FILE__).join('..')\n  # config.add_components(in: ‘app’, except: %’w(views, assets))\n  # config.add_component('config/initializers', as: 'initializer')\n  # config.patch_kernel = true\nend\n\nSpecRequirer.setup\n```\n\nYou can also pass some configuration directly to `setup` as such:\n\n```ruby\nSpecRequirer.setup(app_root: app_root, components: ['models', 'presenters'])\n```\n\n## Contributing\n\n1. Fork it ( https://github.com/[my-github-username]/spec_requirer/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrisleech%2Fspec_requirer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrisleech%2Fspec_requirer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrisleech%2Fspec_requirer/lists"}