--- !ruby/object:RI::ClassDescription attributes: [] class_methods: [] comment: - !ruby/struct:SM::Flow::P body: Assertion is a special subclass of Exception used to raise assertion errors. - !ruby/struct:SM::Flow::P body: "Assertions are generally invoked via the #assert or #should functors. For instance to assert that 4 == 4 use:" - !ruby/struct:SM::Flow::VERB body: " 4.assert == 4\n" - !ruby/struct:SM::Flow::P body: If the assertion does not hold true an Assertion exception will be raised. - !ruby/struct:SM::Flow::P body: You can also create your own assertion "macros" simply by defining applicable methods resuing previous assertion methods. - !ruby/struct:SM::Flow::VERB body: " class Module\n def should_be_enumerable(module)\n should < Enumerable\n instance_methods.should.include?('each')\n end\n end\n" - !ruby/struct:SM::Flow::P body: "As fancy as assertion functors may seem, under the hood they translate into quite simple code. Consider this valid macro:" - !ruby/struct:SM::Flow::VERB body: " def assert_fail_every_time\n raise Assertion, "this will fail every time"\n end\n" - !ruby/struct:SM::Flow::P body: Not very useful, but completely valid. - !ruby/struct:SM::Flow::H level: 2 text: Concerning Nomenclature - !ruby/struct:SM::Flow::P body: Unfortunately there's a bit of rift in the naming scheme of assertion methods. With TDD the term 'assert' became the standard. However, with the advent of BDD, 'should' has become the dominant term. - !ruby/struct:SM::Flow::P body: If I had my druthers I would probably have picked 'must' since it is short and carries the semantics of enforcement. constants: [] full_name: Assertion includes: [] instance_methods: [] name: Assertion superclass: Exception