{"id":22980943,"url":"https://github.com/rubyworks/assay","last_synced_at":"2025-04-02T09:42:04.179Z","repository":{"id":62553618,"uuid":"1034744","full_name":"rubyworks/assay","owner":"rubyworks","description":"Class-based Assertions Framework","archived":false,"fork":false,"pushed_at":"2013-03-09T21:17:32.000Z","size":820,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-08T07:53:59.108Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rubyworks.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-10-29T12:24:12.000Z","updated_at":"2014-01-29T14:30:07.000Z","dependencies_parsed_at":"2022-11-03T04:45:22.576Z","dependency_job_id":null,"html_url":"https://github.com/rubyworks/assay","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Fassay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Fassay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Fassay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Fassay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubyworks","download_url":"https://codeload.github.com/rubyworks/assay/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246793006,"owners_count":20834921,"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-12-15T01:46:15.751Z","updated_at":"2025-04-02T09:42:04.138Z","avatar_url":"https://github.com/rubyworks.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Assay\n\n[Website](http://rubyworks.github.com/assay) /\n[Documentation](http://rubydoc.info/gems/assay) /\n[Report Issue](http://github.com/rubyworks/assay/issues) /\n[Source Code](http://github.com/rubyworks/assay)\n\n[![Gem Version](https://badge.fury.io/rb/assay.png)](http://badge.fury.io/rb/assay)\n[![Build Status](https://secure.travis-ci.org/rubyworks/assay.png)](http://travis-ci.org/rubyworks/assay) \u0026nbsp; \u0026nbsp;\n[![Flattr Me](http://api.flattr.com/button/flattr-badge-large.png)](http://flattr.com/thing/324911/Rubyworks-Ruby-Development-Fund)\n\n\n## DESCRIPTION\n\nAssay defines assertions in the same way that Ruby defines\nexceptions. An assertion then is nothing more that an\nextended Exception class. Assay provides a complete set\nof these assertion classes for the most common assertion types.\nIt also provides both TestUnit-style assertion methods and\nRSpec-compatiable matchers built from these assertion classes\nfor use in your preferred test harness. Assay is compatible with\nTestUnit, MiniTest, RSpec and other test frameworks.\n\n\n## FEATURES\n\n* Patterned after the Ruby exception system.\n* Allows assertions specialized error messages.\n* Supports any variety of assertion \"grammers\".\n* Can be used with almost any test framework. \n\n\n## LIMITATIONS\n\n* Assay is Ruby 1.9+ only!\n\n\n## INSTALLATION\n\nTo install with RubyGems simply open a console and type:\n\n    $ gem install assay\n\nSite installation with the tarball can be done with Ruby Setup\n(gem install setup). See http://rubyworks.github.com/setup.\n\n\n## UTILIZATION\n\n### Assay Classes\n\nAssay consists of a set of Assertion subclasses known as *assays*. They\nare akin to Ruby's Exception subclasses, indeed the +Assertion+ base class\nis a subclass of Exception. But assays have special class methods that are\nused to make assertions.\n\nConsider the +EqualityAssay+ class. It defines methods for asserting equality\nvia the `#==` method.\n\n    EqualityAssay.assert!(1,1)\n\nAdditionally, we can check the assertion's test without actually raising the\nassertion if it fails using the query method.\n\n    EqualityAssay.pass?(1,1)    #=\u003e true\n\nAssays also provide the opposite method `#refute!` along with `#fail?`.\n\n    EqualityAssay.refute!(1,2)\n\n    EqualityAssay.fail?(1,2)    #=\u003e true\n\nAssay instances are test matchers, which can be conveniently defined with `#[]`.\n\n    EqualityAssay[1] =~ 1\n\nNotice in the example we have used `#=~` to apply the matcher which makes\nthe `#assert!` call to the Assay object. Likewise `#!~` can be used to\ncall `#refute!` instead. And note that `#===` is also an alias for `#=~`.\n\n    EqualityAssay[1] === 1\n\nWhich means assay matchers can be used in case statments.\n\n    case 10\n    when InstanceAssay[Fixnum]\n    when EqualityAssay[10.0]\n    end\n\nPretty neat.\n\n### Framework Adapters\n\nAssay follows a standard practice of defining assertion error classes with\nan `#assertion?` method that returns +true+. This can be used by any test \nframework to easily detect when a raised error is an assertion rather than\nan ordinary error. To add support for this to common test frameworks Assay\nprovides adapters.\n\nFor example, to use assay with MiniTest framework add to your test helper\nscript:\n\n    require 'assay/adapter/minitest'\n\nLikewise for TestUnit.\n\n    require 'assay/adapter/testunit'\n\nAn RSpec adadpter is in the works, and should be out with the next release.\n\nNote that even without the adapter, you can still use Assay with other test\nframeworks. They will simply count Assay's assertions as regular errors.\n\n### Customized Grammars\n\nOf course the classes are interesting and clearly make for a sound foundation,\nbut in the end we want to write assertions more easily and concisely. For this\nwe turn to separate \"grammar\" projects that depend on Assay's classes. The\nfirst of these, created as a spin-off project to demonstrate Assay's prowess,\nis {Fluidity}[http://rubyworks.github.com/fluidity]. Here is a quick taste of\nthat gem's functionality.\n\n    require 'fluidity'\n\n    10.should.be.kind_of(Integer)\n\nBut is you are acustom to MiniTest's spec methods, you might prefer `must`.\n\n    10.must.be.kind_of(Integer)\n\nAnd to satisfy all those technical aficionados (like yours truly) there is `assert`.\n\n    10.assert.kind_of(Integer)\n\nThre are also compatibility grammar projects available, spun-off from Assay, that\nprovide compatability with legacy test frameworks which can serve as transition\nto Assay from these other frameworks. Follow the links below for each:\n\n* [Assay TestUnit](http://github.com/rubyworks/assay-testunit)\n* [Assay MiniTest](http://github.com/rubyworks/assay-minitest)\n* [RSpecial](http://github.com/rubyworks/rspecial)\n\nUsage is essentially the same for any one of them. For example,\n\n    require 'assay/rspec'\n\n    include Assay::Matchers\n\n    10.should be_kind_of(Integer)\n\nNote that the compatibility modules are not yet 100% compatable, lacking some\nof the more esoteric and complex features. But they are very nearly so, and\nwill become more so in time.\n\nThese are just a few possible grammars. There is no reason not to build\nyour own grammar on top of Assay's classes if you have another approach in mind.\nIndeed, please do! That, after all, is the main purpose of having such\na set of reusable assertion classes!\n\n### Learning More\n\nThere's more learn about Assay, mainly the variety of assay classes available,\nbut also a few other bits of functionality not comvered here. To learn\nabout these check out the {QED documentation}[http://github.com/rubyworks/assay]\nwhich provides an overiew of functionality with working examples, and the\nthe {API documentation}[http://rubydoc.info/gems/asasy] for a more in depth look\nunder the hood.\n\n\n## LICENSE \u0026 COPYRIGHT\n\nCopyright (c) 2010 Rubyworks\n\nThis program is ditributed under the terms of the *BSD-2-Cluase* license.\n\nSee LICENSE.txtfile for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyworks%2Fassay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubyworks%2Fassay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyworks%2Fassay/lists"}