{"id":13521282,"url":"https://github.com/stackbuilders/stub_shell","last_synced_at":"2025-07-14T02:30:48.582Z","repository":{"id":2200405,"uuid":"3148847","full_name":"stackbuilders/stub_shell","owner":"stackbuilders","description":"Stub shell environment for your rspec test suite.","archived":true,"fork":false,"pushed_at":"2012-02-05T02:29:35.000Z","size":121,"stargazers_count":7,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-21T15:25:30.481Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://github.com/stackbuilders/stub_shell","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/stackbuilders.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-01-10T21:31:19.000Z","updated_at":"2025-04-08T16:57:17.000Z","dependencies_parsed_at":"2022-08-25T15:51:58.363Z","dependency_job_id":null,"html_url":"https://github.com/stackbuilders/stub_shell","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/stackbuilders/stub_shell","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackbuilders%2Fstub_shell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackbuilders%2Fstub_shell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackbuilders%2Fstub_shell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackbuilders%2Fstub_shell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stackbuilders","download_url":"https://codeload.github.com/stackbuilders/stub_shell/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackbuilders%2Fstub_shell/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265175531,"owners_count":23722658,"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-08-01T06:00:32.189Z","updated_at":"2025-07-14T02:30:48.192Z","avatar_url":"https://github.com/stackbuilders.png","language":"Ruby","funding_links":[],"categories":["Mocks"],"sub_categories":[],"readme":"# StubShell [![Build Status](https://secure.travis-ci.org/stackbuilders/stub_shell.png)](http://travis-ci.org/stackbuilders/stub_shell)\n\nStubShell helps you to test your libraries that interact with the system through the Kernel backquote and system methods.  \nIt does this by providing a DSL to describe the messages that you expect the shell to receive in the order that you expect\nto receive them.  StubShell can be used to stub simple interactions, or ones that cause the system that you're working with\nto change state.\n\n## Installation\n\n    gem install stub_shell\n\n## Configuration\n\n    require 'stub_shell'\n\n    RSpec.configure do |config|\n      config.include StubShell::TestHelpers\n    end\n\n## Usage\n\nStubShell can handle simple cases where you want to stub a system call in Ruby or more complex interactions \nwhere commands may change the state and return values of subsequent commands.\n\n### Simple Usage\n\nYou use StubShell simply by describing the commands that you want stubbed out, along with the value that they\nshould return in STDOUT and STDERR, as well as their exit status.\n\n    it ... do\n      stub_shell do\n        command \"ls /tmp/foobar\" do\n          stdout \"hey there\"\n          stderr \"some error\"\n          exitstatus 2\n        end\n      end\n    end\n\nBy default, StubShell assumes that STDOUT and STDERR are nil, and that the exit status is 0 (success), so you \ncan leave these options out if you want.\n\n### Stubbing Complex Shell Interactions\n\nYou can stub more complex interactions with the shell, including cases where commands that you execute will\nchange the output of subsequent commands.\n\n    stub_shell do\n      command 'ls /tmp/foobar' do\n        stdout 'yes, foobar exists'\n      end\n    \n      command \"rm /tmp/foobar\" do\n        stub_shell do\n          command 'ls /tmp/foobar' do\n            stderr 'the file no longer exists'\n            exitstatus 2\n          end\n        end\n      end\n    end\n\nStubShell starts looking for defined commands at the current level of the execution hierarchy, so if you\ninvoke the command to remove /tmp/foobar above, it will always look at the stub_shell context nested below\nthat command for matches to subsequent commands.  If no matching commands are found at that level, StubShell\nsearches recursively upwards in the tree for matches until it either finds one or it runs out of options and \nraises an error indicating that no matches were found.\n\n### Regular Expression Matching of Commands\n\nYou can use regular expressions to match commands in StubShell.\n\n    stub_shell do\n      command /ls \\/tmp.*foo/' do\n        stdout 'yes, your directory exists'\n      end\n    end\n\n### Additional Documentation\n\nWe suggest that you read the acceptance tests included with this library to help understand the \nway that it works.\n\n## Authors\n\nJustin Leitgeb (@jsl) and @itsmeduncan.\n\n## Contribute\n\n1. [Fork](http://help.github.com/forking/) stub_shell\n2. Create a topic branch - `git checkout -b my_branch`\n3. Push to your branch - `git push origin my_branch`\n4. Create a [Pull Request](http://help.github.com/pull-requests/) from your branch\n\n## License\n\nSee LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackbuilders%2Fstub_shell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstackbuilders%2Fstub_shell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackbuilders%2Fstub_shell/lists"}