{"id":15146428,"url":"https://github.com/apexatoll/zirconia","last_synced_at":"2026-01-21T16:03:31.449Z","repository":{"id":200497558,"uuid":"705845812","full_name":"apexatoll/zirconia","owner":"apexatoll","description":"Lightweight testing utility for synthesising Ruby gems","archived":false,"fork":false,"pushed_at":"2023-10-26T20:24:11.000Z","size":31,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-10T01:41:28.017Z","etag":null,"topics":["bundler","rspec","ruby","ruby-gem","ruby-gems","rubygem","testing","testing-tools"],"latest_commit_sha":null,"homepage":"","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/apexatoll.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-16T19:59:17.000Z","updated_at":"2024-01-23T17:19:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"8c7ceba4-c7ce-4bab-8fd7-d27253553ae6","html_url":"https://github.com/apexatoll/zirconia","commit_stats":null,"previous_names":["apexatoll/zirconia"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/apexatoll/zirconia","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apexatoll%2Fzirconia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apexatoll%2Fzirconia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apexatoll%2Fzirconia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apexatoll%2Fzirconia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apexatoll","download_url":"https://codeload.github.com/apexatoll/zirconia/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apexatoll%2Fzirconia/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28635926,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T15:01:31.228Z","status":"ssl_error","status_checked_at":"2026-01-21T14:42:58.942Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["bundler","rspec","ruby","ruby-gem","ruby-gems","rubygem","testing","testing-tools"],"created_at":"2024-09-26T12:01:36.457Z","updated_at":"2026-01-21T16:03:31.432Z","avatar_url":"https://github.com/apexatoll.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Zirconia: A Ruby Gem Synthesiser for RSpec\n\nZirconia is a lightweight testing utility that is capable of generating\\ temporary Ruby Gem applications from within the test suite. \n\nZirconia offers an intuitive interface around the synthetic gem allowing them to be configured and coded from within the test environment.\n\nUse cases include:\n- Testing frameworks written in Ruby\n- Testing autoloaders\n- Testing gem-gem interaction\n- Testing metaprogramming-heavy modules and classes\n\nCurrently, only `RSpec` is supported.\n\n\n## Quick Start\n\n- Add `zirconia` to your Gemfile:\n\n```ruby\nsource \"https://rubygems.org\"\n\ngem \"zirconia\"\n```\n\n- Require `zirconia/rspec` in your spec_helper:\n```ruby\nrequire \"zirconia/rspec\"\n```\n\n- Instantiate a Zirconia Gem in your spec using the `with_gem: gem_name` metadata:\n```ruby\nrequire 'spec_helper'\n\nRSpec.describe \"Some Gem\", with_gem: :some_gem do\n  it \"instantiates a Zirconia Gem\" do\n    expect(gem).to be_a(Zirconia::Application)\n  end\nend\n```\n\nThat's it! You can now interact with your newly spun up gem (through `gem`) in `before`/`after` hooks or in the tests themselves.\n\nNote that calling `:with_gem` without a name argument is valid as well. In this case the gem name will be set to the default (`SomeGem`).\n\n\n## Overview\n\nInteraction, configuration and coding of your fake gem is executed through the `gem` variable set by Zirconia when the `with_gem` RSpec metadata is specified.\n\nGems are created using the `bundle gem` command within your system's temp directory. As gem creation is delegated to `bundler`, your local system `bundler` configuration will be respected. Gems are removed and Gem modules unsourced around each test.\n\nAdding code to the fake gem is achieved by writing files to their respective path before loading the gem into memory. The `gem` object (an instance of `Zirconia::Application`) defines several instance methods that return `Pathname` objects at canonical locations in the gem filetree. Conventionally these are:\n\n```\n|-+temp_dir/            gem.dir\n  |-+ some_gem/         gem.gem_path\n    |-+ lib/            gem.lib_path\n      |-- some_gem.rb   gem.main_file\n      |-+ some_gem/     gem.path\n        |-- foobar.rb   gem.path(\"foobar\")\n```\n\n### Path Methods\n\nThese path methods are return a `Pathname` objects. `Pathname` is a Ruby standard library, and offers a simple interface for paths in a filetree. Of importance may be:\n- `write(string)`: Writes `string` to the file at path\n- `read`: Reads the contents of the file at path\n- `exist?`: Returns whether a file \n- `mkdir`: Make (non recursive) a directory at the current path\n\nThe `_path` methods can be called with a variable amount of string path fragments and an optional extension. String fragments will be joined into the path, whilst the extension will be appended to the path\n\n\n### Methods\n\n#### dir\n- The (temporary) directory that contains the gem\n\n#### gem_path\n- Returns `Pathname` objects for paths in the root gem directory\n- In a conventional Ruby gem filetree this is `some_gem/*.ext`\n\n#### lib_path\n- Returns `Pathname` objects for paths in the gem lib directory\n- In a conventional Ruby gem filetree this is `some_gem/lib/*.ext`\n\n#### path\n- Returns `Pathname` objects for paths in the gem named lib directory\n- In a conventional Ruby gem filetree this is `some_gem/lib/some_gem/*.ext`\n\n#### spec_path\n- Returns `Pathname` objects for paths in the gem spec directory\n- In a conventional Ruby gem filetree this is `some_gem/spec/*.ext`\n\n#### main_file\n- Returns a `Pathname` object\n- This is the entrypoint to the gem application:\n- In a conventional Ruby gem filetree this is `some_gem/lib/some_gem.rb`\n\n#### load!\n- This method requires the fake gem into your current Ruby scope.\n- Note that this process is not idempotent as gems will not be reloaded.\n\n#### exec\n- Accepts a string argument, which is passed to `bundle exec`.\n- Returns the string output of the command\n\n## Example\n\nSay we are creating a fancy new testing framework `spectacular`, and we want to test how it behaves when included in target Ruby gem applications. `spectacular` defines an `Initialiser` class that is run when the gem is included into its target gem.\n\nWith `zirconia`, we can spin up a target Gem, write some Ruby code to be injected into the Gem entrypoint, and then test how it behaves when run. This could look something like:\n\n```ruby\nRSpec.describe Spectacular::Initialiser, :with_gem do\n  before do\n    gem.main_file.write(\u003c\u003c~RUBY)\n      require \"spectacular\"\n\n      module SomeGem\n        extend Spectacular::Initialiser\n      end\n    RUBY\n  end\n\n  describe \"requiring Spectacular\" do\n    subject(:require_spectacular) { gem.load! }\n\n    it \"loads the gem\" do\n      expect { require_spectacular }\n        .to change { Object.const_defined?(:SomeGem) }\n        .from(false)\n        .to(true)\n    end\n  end\nend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapexatoll%2Fzirconia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapexatoll%2Fzirconia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapexatoll%2Fzirconia/lists"}