{"id":15679722,"url":"https://github.com/jhawthorn/ttytest","last_synced_at":"2025-05-07T10:20:29.230Z","repository":{"id":56897136,"uuid":"77347977","full_name":"jhawthorn/ttytest","owner":"jhawthorn","description":"An acceptance test framework for interactive console applications","archived":false,"fork":false,"pushed_at":"2019-08-15T23:44:32.000Z","size":61,"stargazers_count":11,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-30T21:56:08.256Z","etag":null,"topics":["ruby","terminal","test","tmux"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jhawthorn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-26T00:26:00.000Z","updated_at":"2022-10-27T18:39:51.000Z","dependencies_parsed_at":"2022-08-20T17:40:31.852Z","dependency_job_id":null,"html_url":"https://github.com/jhawthorn/ttytest","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhawthorn%2Fttytest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhawthorn%2Fttytest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhawthorn%2Fttytest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhawthorn%2Fttytest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jhawthorn","download_url":"https://codeload.github.com/jhawthorn/ttytest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252856770,"owners_count":21814899,"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":["ruby","terminal","test","tmux"],"created_at":"2024-10-03T16:34:53.599Z","updated_at":"2025-05-07T10:20:29.209Z","avatar_url":"https://github.com/jhawthorn.png","language":"Ruby","readme":"TTYtest is an acceptance test framework for interactive console applications. It's like [capybara](https://github.com/teamcapybara/capybara) for the terminal.\n\nIt works by running commands inside a tmux session, capturing the pane, and comparing the content. The assertions will wait a specified amount of time (default 2 seconds) for the expected content to appear.\n\n[![Gem Version](https://badge.fury.io/rb/ttytest.svg)](https://rubygems.org/gems/ttytest)\n\n## Requirements\n\n* tmux \u003e= 1.8\n* Ruby \u003e= 2.1\n\n## Usage\n\n### Example\n\n``` ruby\n@tty = TTYtest.new_terminal(%{PS1='$ ' /bin/sh}, width: 80, height: 24)\n@tty.assert_row(0, '$')\n@tty.assert_cursor_position(x: 2, y: 0)\n\n@tty.send_keys(%{echo \"Hello, world\"\\n})\n\n@tty.assert_contents \u003c\u003cTTY\n$ echo \"Hello, world\"\nHello, world\n$\nTTY\n@tty.assert_cursor_position(x: 2, y: 2)\n\np @tty.rows # =\u003e [\"$ echo \\\"Hello, world\\\"\", \"Hello, world\", \"$\", \"\", \"\", \"\", ...]\n```\n\nSee also [fzy's integration test](https://github.com/jhawthorn/fzy/blob/master/test/integration/integration_test.rb) for a full example.\n\n### Assertions\n\nThe main way to use TTYtest is through assertions. When called on a `TTYtest::Terminal`, each of these will be retried (for up to 2 seconds by default).\n\nAvailable assertions:\n* `assert_row(row_number, expected_text)`\n* `assert_cursor_position(x: x, y: y)`\n* `assert_cursor_visible`\n* `assert_cursor_hidden`\n* `assert_contents(lines_of_terminal)`\n\n## TravisCI\n\nTTYtest can run on [TravisCI](https://travis-ci.org/), but the version of tmux made available with their default ubuntu 12.04 environment is too old. However the TravisCI ubuntu 14.04 \"trusty\" image provides tmux 1.8, which works great.\n\nEnsure the following is in your `.travis.yml` (see [this project's .travis.yml](./.travis.yml) for an example)\n\n``` yaml\ndist: trusty\naddons:\n  apt:\n    packages:\n    - tmux\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/jhawthorn/ttytest.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjhawthorn%2Fttytest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjhawthorn%2Fttytest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjhawthorn%2Fttytest/lists"}