{"id":29955040,"url":"https://github.com/foca/expectacular","last_synced_at":"2025-08-03T17:09:32.234Z","repository":{"id":576883,"uuid":"209349","full_name":"foca/expectacular","owner":"foca","description":"Expectations for your Test::Unit tests (DSL to use instead of \"assert\" and friends)","archived":false,"fork":false,"pushed_at":"2009-05-26T15:34:46.000Z","size":88,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-04-10T10:19:50.494Z","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/foca.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":"2009-05-25T04:25:15.000Z","updated_at":"2016-09-22T18:46:47.000Z","dependencies_parsed_at":"2022-07-08T02:06:41.616Z","dependency_job_id":null,"html_url":"https://github.com/foca/expectacular","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/foca/expectacular","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foca%2Fexpectacular","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foca%2Fexpectacular/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foca%2Fexpectacular/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foca%2Fexpectacular/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/foca","download_url":"https://codeload.github.com/foca/expectacular/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foca%2Fexpectacular/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268578914,"owners_count":24273089,"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-03T02:00:12.545Z","response_time":2577,"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-08-03T17:09:20.350Z","updated_at":"2025-08-03T17:09:32.225Z","avatar_url":"https://github.com/foca.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= Expectacular\n\nA small DSL to write meaningful assertions on your test/unit tests.\n\n== Usage\n\n    require \"expectacular\"\n\n    class TestFoo \u003c Test::Unit::TestCase\n      include Expectacular::TestCaseMethods\n\n      def test_obviousness\n        expect(1).to == 1\n\texpect(5).to.be \u003e 3\n\texpect(nil).to.be_nil\n\texpect(5).not_to == 4\n      end\n    end\n\n== Expectations\n\nIncluding \u003ctt\u003eExpectacular::TestCaseMethods\u003c/tt\u003e will add your test cases a\nsingle method: \u003ctt\u003eexpect\u003c/tt\u003e, which takes any object as an argument and\nreturns an \u003ctt\u003eExpectacular::Expectation\u003c/tt\u003e in return. You can do assertions\non expectations, by calling the methods \u003ctt\u003eExpectation#to\u003c/tt\u003e and \n\u003ctt\u003eExpectation#not_to\u003c/tt\u003e.\n\n    expect(1).to == 1\n    expect(3).not_to == 0\n\n\u003ctt\u003eto\u003c/tt\u003e and \u003ctt\u003enot_to\u003c/tt\u003e return an \u003ctt\u003eAssertion\u003c/tt\u003e. In its context\nyou can call several methods to test the behavior of your objects.\n\n== Assertions\n\nExpectacular comes with some assertions bundled:\n\n* Predicates (\u003ctt\u003ebe_foo\u003c/tt\u003e to check that \u003ctt\u003efoo?\u003c/tt\u003e returns true)\n* \u003ctt\u003ebe_a(Foo)\u003c/tt\u003e to test ancestorship (\u003ctt\u003eis_a?(Foo)\u003c/tt\u003e)\n\nWhenever you call a method that is not one of the above, the method (and any\narguments) get forwared to the object in which you set the expectation, and the\nresult is treated as the assertion (if it returns true the test is considered\nto pass, if it returns false it considers the assertion to fail -- unless you\nare using \u003ctt\u003enot_to\u003c/tt\u003e, in which case it's the other way around.)\n\nFor example, Expectacular doesn't define any operator assertions, those are\nforwarded to the object you're setting expectations on. So the following:\n\n    expect(foo).to =~ /bar/\n    expect(foo).not_to == \"bars\"\n\nJust calls \u003ctt\u003efoo =~ /bar/\u003c/tt\u003e and \u003ctt\u003e!(foo == \"bars\")\u003c/tt\u003e and makes an\nassertion for each of those.\n\n== Writing your own assertions it's stupidly easy\n\n    module MyAwesomeAssertion\n      THRESHOLD = 10_000\n\n      def be_very_awesome\n        assert(object.awesomeness \u003e= THRESHOLD,\n\t       \"Expected #{object} to be very awesome\")\n      end\n    end\n\n    Expectacular::Assertion.add MyAwesomeAssertion\n\n    expect(foo).to.be_very_awesome\n\nAssertions have access to the following two methods:\n\n\u003ctt\u003eobject\u003c/tt\u003e:: which returns the object on which you're setting the \n                  expectation.\n\u003ctt\u003eassert\u003c/tt\u003e:: which takes a boolean value and a failure message.\n\nYou can also pass a block to \u003ctt\u003eAssertion.add\u003c/tt\u003e with the method \ndefinitions, so the above example could also be written as:\n\n    Expectacular::Assertion.add do\n      THRESHOLD = 10_000\n\n      def be_very_awesome\n        assert(object.awesomeness \u003e= THRESHOLD,\n               \"Expected #{object} to be very awesome\")\n      end\n    end\n\n    expect(foo).to.be_very_awesome\n\n== Why?\n\nMostly, as an experiment, also, I usually don't like libraries that mess around\nwith core classes, so this one doesn't :)\n\n== Credits\n\nThanks to Daniel Cadenas (github[http://github.com/dcadenas]) for design and \nsyntax ideas.\n\nAuthor:: Nicolás Sanguinetti (github[http://github.com/foca])\nLicense:: MIT. See attached LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoca%2Fexpectacular","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoca%2Fexpectacular","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoca%2Fexpectacular/lists"}