{"id":13879752,"url":"https://github.com/amatsuda/still_life","last_synced_at":"2025-05-16T00:00:23.399Z","repository":{"id":59156494,"uuid":"176476317","full_name":"amatsuda/still_life","owner":"amatsuda","description":"Rails upgrade's best friend","archived":false,"fork":false,"pushed_at":"2024-11-17T06:51:54.000Z","size":114,"stargazers_count":224,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-09T02:11:53.840Z","etag":null,"topics":["capybara","minitest","rspec","ruby","ruby-on-rails","test-unit"],"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/amatsuda.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","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":"2019-03-19T09:35:42.000Z","updated_at":"2025-01-07T05:29:43.000Z","dependencies_parsed_at":"2024-08-02T16:55:10.713Z","dependency_job_id":"95936e47-acc2-441a-97dc-4a5982ce35f0","html_url":"https://github.com/amatsuda/still_life","commit_stats":{"total_commits":99,"total_committers":1,"mean_commits":99.0,"dds":0.0,"last_synced_commit":"8939f673e7e47a498d7bf2cb10eb30889edb7055"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amatsuda%2Fstill_life","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amatsuda%2Fstill_life/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amatsuda%2Fstill_life/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amatsuda%2Fstill_life/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amatsuda","download_url":"https://codeload.github.com/amatsuda/still_life/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254442854,"owners_count":22071877,"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":["capybara","minitest","rspec","ruby","ruby-on-rails","test-unit"],"created_at":"2024-08-06T08:02:31.607Z","updated_at":"2025-05-16T00:00:23.291Z","avatar_url":"https://github.com/amatsuda.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# still_life\n\n## What's This?\n\nstill_life is a testing framework enhancements for test-unit, minitest, RSpec, and Capybara that records all HTML response body texts that are rendered during E2E or unit test executions.\n\n\n## So What?\n\nYou can compare actually rendered HTML results before and after any app updates.\n\n\n## For What?\n\nBy comparing all these HTML files that are processed before and after any kind of code change, you can make sure that you did not (or you did) introduce any new user-facing incompatibilities.\nThis may greatly help you for example, refactoring your app, replacing external libraries, or upgrading libraries.\nMy personal use case that made me gemifying still_life was that I wanted to make sure that [my own template engine](https://github.com/amatsuda/himl) renders the same HTML as the one that I was using.\n\nBut indeed, the real sweet spot of this tiny library is IMO \"Rails upgrade\".\nIn fact, The first original version of this tool was implemented as an RSpec monkeypatch while we were upgrading a huge Rails application from Rails 2 to Rails 3.\n\n\n## Installation\n\nBundle `still_life` gem to your Rails app's `:test` environment.\n\n```ruby\ngem 'still_life', group: :test\n```\n\n\n## Usage\n\nRun tests with an envvar `STILL_LIFE`. Then still_life creates some HTML files under `tmp/html/#{ENV['STILL_LIFE']}/` directory.\nEach .html file is named from the location in your test code where the request was made.\n\nFor instance, if you run the tests against a simple scaffold app, the generated files will be like this:\n\n```sh\n% STILL_LIFE=rails52 rails test:system test\n% tree tmp/html\ntmp/html\n└── rails52\n    └── test\n        ├── controllers\n        │   ├── users_controller_test.rb-14.html\n        │   ├── users_controller_test.rb-20.html\n        │   ├── users_controller_test.rb-27.html\n        │   ├── users_controller_test.rb-32.html\n        │   ├── users_controller_test.rb-37.html\n        │   ├── users_controller_test.rb-43.html\n        │   └── users_controller_test.rb-9.html\n        └── system\n            ├── users_test.rb-14.html\n            ├── users_test.rb-18.html\n            ├── users_test.rb-21.html\n            ├── users_test.rb-25.html\n            ├── users_test.rb-26.html\n            ├── users_test.rb-29.html\n            ├── users_test.rb-32.html\n            ├── users_test.rb-36.html\n            ├── users_test.rb-37.html\n            └── users_test.rb-9.html\n\n4 directories, 17 files\n```\n\nAnd each file content is just an HTML.\n```html\n% cat tmp/html/rails52/test/system/users_test.rb-18.html\n\u003c!DOCTYPE html\u003e\u003chtml xmlns=\"http://www.w3.org/1999/xhtml\"\u003e\u003chead\u003e\n    \u003ctitle\u003eStillLifeTest\u003c/title\u003e\n    \n    \n\n    \u003clink rel=\"stylesheet\" media=\"all\" href=\"/assets/application-35729bfbaf9967f119234595ed222f7ab14859f304ab0acc5451afb387f637fa.css\" data-turbolinks-track=\"reload\" /\u003e\n    \u003cscript src=\"/assets/application-3c2e77f06bf9a01c87fc8ca44294f3d3879d89483d83b66a13a89fc07412dd59.js\" data-turbolinks-track=\"reload\"\u003e\u003c/script\u003e\n  \u003c/head\u003e\n\n  \u003cbody\u003e\n    \u003cp id=\"notice\"\u003eUser was successfully created.\u003c/p\u003e\n\n\u003cp\u003e\n  \u003cstrong\u003eName:\u003c/strong\u003e\n  MyString\n\u003c/p\u003e\n\n\u003ca href=\"/users/980190963/edit\"\u003eEdit\u003c/a\u003e |\n\u003ca href=\"/users\"\u003eBack\u003c/a\u003e\n\n  \n\n\u003c/body\u003e\u003c/html\u003e\n```\n\n\n## Usage Scenario\n\nConsider you have a well-tested Rails 5.2 app, and you want to upgrade its Rails version to 6.0 without introducing any user-facing incompatibilities.\nThen the workflow will be as follows:\n\n### 1. Draw a still_life with the 5.2 app\n\n```sh\n% STILL_LIFE=rails52 rails test:system test\n```\n\n### 2. Do the upgrade job\n\n```sh\n% bundle u\n% rails app:update\n```\nand push some more commits...\n\n### 3. Draw another still_life with the 6.0 app\n\n```sh\n% STILL_LIFE=rails60 rails test:system test\n```\n\n### 4. Compare the results, and make sure there's no unexpected diffs\n\n```sh\n% git diff --no-index --color-words tmp/html/rails52/ tmp/html/rails60/\n```\n\n\n## Notes\n### git diff\nAs written in the above example, `git diff --no-index --color-words` should perfectly work for recursively comparing two output directories.\n\n### Random Values\n\nIf your response includes some kind of random values, the test results may change between each test runs.\nIn such case, maybe you could specify a random seed, or mock the random source in your app.\n\n\n## TODOs / Known Issues\n- The Capybara monkeypatch sometimes fails to get the `page.body` due to Capybara timing problem\n- Support older versions of Rails, Capybara, and Ruby\n- Fix the CI with RSpec + headless Chrome\n\n\n## Contributing\n\nPull requests are welcome on GitHub at https://github.com/amatsuda/still_life.\n\n\n## Credit\n\nThe original idea of this library was implemented as a 10 LOC anonymous module by [@hotchpotch](https://github.com/hotchpotch) at Cookpad Inc. back in 2011 as written in [this slide](https://speakerdeck.com/a_matsuda/the-recipe-for-the-worlds-largest-rails-monolith?slide=129).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famatsuda%2Fstill_life","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famatsuda%2Fstill_life","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famatsuda%2Fstill_life/lists"}