{"id":28509131,"url":"https://github.com/atomicobject/birdbath","last_synced_at":"2025-08-19T20:17:47.204Z","repository":{"id":1122563,"uuid":"995351","full_name":"atomicobject/birdbath","owner":"atomicobject","description":"A rails gem for verifying migrations with rspec or Test::Unit","archived":false,"fork":false,"pushed_at":"2011-08-09T20:29:17.000Z","size":183,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-08-16T08:34:56.593Z","etag":null,"topics":[],"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/atomicobject.png","metadata":{"files":{"readme":"README.rdoc","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":"2010-10-17T20:17:36.000Z","updated_at":"2024-11-28T16:28:17.000Z","dependencies_parsed_at":"2022-07-18T18:42:23.119Z","dependency_job_id":null,"html_url":"https://github.com/atomicobject/birdbath","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/atomicobject/birdbath","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicobject%2Fbirdbath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicobject%2Fbirdbath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicobject%2Fbirdbath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicobject%2Fbirdbath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atomicobject","download_url":"https://codeload.github.com/atomicobject/birdbath/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicobject%2Fbirdbath/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271215037,"owners_count":24720098,"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","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-06-08T22:07:31.642Z","updated_at":"2025-08-19T20:17:47.176Z","avatar_url":"https://github.com/atomicobject.png","language":"Ruby","readme":"= Birdbath\n\nBirdbath provides methods which let you assert the current state of the schema and run your migrations against the _test_ database.\n\n== Install\n\n  gem install birdbath\n\nIf you're using it outside of a Rails environment (for whatever reason) include the Birdbath module in your tests:\n\n  require 'test/unit'\n  require 'birdbath'\n\n  class MyTest \u003c Test::Unit::TestCase\n    include Birdbath\n    \n    def test_something\n      ...\n    end\n  end\n\n== Use\n\n*assert_schema*: verifies the schema of the database exactly matches the one specified.\n\n  def test_the_schema\n    assert_schema do |s|\n      s.table :books do |t|\n        t.column :id,     :integer\n        t.column :title,  :string, :limit =\u003e 5\n        t.column :author, :string\n      end\n\n      s.table :reviews do |t|\n        t.column :id,      :integer\n        t.column :book_id, :integer\n        t.column :body,    :text\n        t.column :rating,  :integer, :default =\u003e 0\n        t.index  :book_id, :name =\u003e 'index_book_id_on_reviews'\n      end\n    end\n  end\n\nThis would verify there are only two tables defined in the test database: _books_ and _reviews_ (schema_info is ignored).  It will also verify that the _book_ table has the three columns, _id_, _title_ and _author_, each with their respective types. Indexes are verified too.\n\n\n*assert_table*: verify a table is found exactly as specified:\n\n  assert_table :books do |t|\n    t.column :id,     :integer\n    t.column :title,  :string, :limit =\u003e 5\n    t.column :author, :string\n    t.index  :author, :name =\u003e 'index_author_on_books'\n  end\n\n\n*drop_all_tables*: does just what it says to your _test_ database.\n\n\n*migrate*: executes the migrations against the test database using the same mechanism as rake db:migrate.\n\n  def test_the_migrations\n    migrate\n    migrate :version =\u003e 0\n    migrate :version =\u003e 10\n    migrate\n  end\n  \n\nThis would do the same thing as running the following rake commands, but within a test case:\n\n  rake db:migrate\n  rake db:migrate VERSION=0\n  rake db:migrate VERSION=10\n  rake db:migrate\n  \n\nBy combining the two helpers you can write a test that shows you can run all your migrations and get the final schema:\n\n  def test_should_be_able_to_migrate_from_an_empty_schema\n    drop_all_tables\n\n    # we shouldn't have any tables\n    assert_schema do |s|\n    end\n\n    migrate  \n\n    assert_schema do |s|\n      s.table :books do |t|\n        t.column :id,     :integer\n        t.column :title,  :string\n        t.column :author, :string\n      end\n\n      s.table :reviews do |t|\n        t.column :id,      :integer\n        t.column :book_id, :integer\n        t.column :body,    :text\n        t.column :rating,  :integer\n        t.index  :book_id, :name =\u003e 'index_book_id_on_reviews'\n      end\n    end\n  end\n\n\nThe *migrate* helper can also be useful for testing data tranformation migrations:\n\n  def test_should_get_rid_of_bad_data\n    drop_all_tables\n    migrate :version =\u003e 7\n    Book.reset_column_information\n    book = Book.create! :title =\u003e \"bad title\\nwith\\todd    spacing\"\n    migrate :version =\u003e 8 # should cleanse spacing in book titles\n    book.reload\n    assert_equal \"bad title with odd spacing\", book.title\n  end \n\n== Authors\n\n* Micah Alles (alles@atomicobject.com)\n* David Crosby (crosby@atomicobject.com)\n* Patrick Bacon (bacon@atomicobject.com)\n* © 2007-2011 {Atomic Object}[http://www.atomicobject.com]\n* More Atomic Object {open source}[http://www.atomicobject.com/pages/Software+Commons] projects\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomicobject%2Fbirdbath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatomicobject%2Fbirdbath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomicobject%2Fbirdbath/lists"}