{"id":19725318,"url":"https://github.com/bodacious/oughta","last_synced_at":"2026-06-12T00:31:31.178Z","repository":{"id":56887123,"uuid":"331015243","full_name":"Bodacious/oughta","owner":"Bodacious","description":"Oughtomatically generate shoulda validation and association tests","archived":false,"fork":false,"pushed_at":"2021-10-18T21:53:44.000Z","size":109,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-03T23:02:46.996Z","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/Bodacious.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"Bodacious","patreon":"gavinmorrice","custom":["https://www.buymeacoffee.com/gavinmorrice"]}},"created_at":"2021-01-19T14:56:22.000Z","updated_at":"2021-10-18T21:53:47.000Z","dependencies_parsed_at":"2022-08-20T13:50:06.734Z","dependency_job_id":null,"html_url":"https://github.com/Bodacious/oughta","commit_stats":null,"previous_names":["katanacode/oughta"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bodacious%2Foughta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bodacious%2Foughta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bodacious%2Foughta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bodacious%2Foughta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bodacious","download_url":"https://codeload.github.com/Bodacious/oughta/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241045854,"owners_count":19899735,"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-11-11T23:29:23.184Z","updated_at":"2026-06-12T00:31:31.042Z","avatar_url":"https://github.com/Bodacious.png","language":"Ruby","funding_links":["https://github.com/sponsors/Bodacious","https://patreon.com/gavinmorrice","https://www.buymeacoffee.com/gavinmorrice"],"categories":[],"sub_categories":[],"readme":"# Oughta\n\nAutomatically generate missing unit tests for Rails models.\n\nDid you _forget_ to write test for your Rails models? Oughta can help, by automatically\ngenerating a lot of the test files and assertions for you.\n\nUsing the collection of matchers from [Thoughtbot's Shoulda](https://github.com/thoughtbot/shoulda \"Shoulda by Thoughtbot\"), oughta will parse your model code and oughta-matically generate assertions for your existing code.\n\n[![Maintainability](https://api.codeclimate.com/v1/badges/d888832c2964be09cc54/maintainability)](https://codeclimate.com/github/Bodacious/oughta/maintainability)\n\n## Example\n\nSuppose you have a model like this:\n\n``` ruby\nclass User \u003c ApplicationRecord\n  # ==============================================================================\n  # = Associations =\n  # ==============================================================================\n  has_many :comments, dependent: :delete_all\n\n  belongs_to :company, required: true\n\n  # ==============================================================================\n  # = Validations =\n  # ==============================================================================\n  validates :name, presence: { on: :update }\n\n  validates :username, uniqueness: { scope: 'company_id' }, presence: true\n\n  validates :age, numericality: { allow_nil: true, greater_than: 17 }\n\n  validates :email, length: { in: 15..50 }\nend\n```\n\nOughta will automatically generate a spec file that looks like this:\n\n``` ruby\nrequire \"rails_helper\"\n\nRSpec.describe User, type: :model do\n  describe \"validations\" do\n    it { should validate_presence_of(:company).with_message(:required) }\n\n    it { should validate_presence_of(:name).on(:update) }\n\n    it { should validate_uniqueness_of(:username).scoped_to(:company_id) }\n\n    it { should validate_presence_of(:username) }\n\n    it { should validate_numericality_of(:age).allow_nil.is_greater_than(17) }\n\n    it { should validate_length_of(:email).is_at_least(15).is_at_most(50) }\n  end\n  describe \"associations\" do\n    it { should have_many(:comments).dependent(:delete_all) }\n\n    it { should belong_to(:company).required }\n  end\nend\n```\n\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngroup :development do\n  gem 'oughta'\nend\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install oughta\n\n## Usage\n\nTo generate specs for a model, use the following command:\n\n```\n$ rails g oughta:model_spec [YourModel]\n```\n\n## Feature requests\n\nTo request a new feature or a change to an existing feature, please start a discussion here: https://github.com/Bodacious/oughta/discussions/\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/bodacious/oughta.\n\nLet's make the world a better place, by reducing the amount of untested code.\n\n## Support\n\nIf Oughta has saved you some time or made your life easier, please consider supporting future development with a small contribution to [Buy Me a Coffee](https://www.buymeacoffee.com/gavinmorrice) :coffee:.\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%2Fbodacious%2Foughta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbodacious%2Foughta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbodacious%2Foughta/lists"}