Skip to content

Add the AE notation, and fix fluent assertions that never failed - #5

Merged
trans merged 2 commits into
masterfrom
ae-notation
Nov 23, 2026
Merged

trans merged 2 commits into
masterfrom
ae-notation

Conversation

@trans

@trans trans commented Nov 23, 2026

Copy link
Copy Markdown
Member

Two commits.

Fix fluent assertions on methods every object has

In assay/fluidity, an assertion using a method that Object already has asserted nothing:

10.assert.kind_of?(String)      # returned false, no failure
10.should.be.nil?               # likewise
10.assert != 10                 # likewise

The grammar classes inherited from Object, so the grammar object answered kind_of?, instance_of?, nil?, eql?, equal?, respond_to?, is_a?, frozen? and != itself. The Fluidity gem always had this flaw; the demos only asserted true cases.

  • The grammar is built on BasicObject now, and != is an UnequalAssay.
  • The RSpec notation's operator delegate had the same flaw (expect(10).to.kind_of?(String) returned false). It is a NoMethodError now, since that notation has matchers for named methods.
  • The fluent fallback to an object's own query method passes keyword arguments and shows the arguments in its message.
  • New demo demo/fluidity/05_object_methods.md asserts the failing cases.

Add the AE notation

require 'assay/ae' gives the AE gem's notation on Assay's classes:

x.assert == y              # fails with EqualAssay
a.assert.include?(e)       # fails with IncludeAssay
x.refute.nil?              # fails with NilAssay
10.assert.odd?             # no assay class: fails with Assertion

expect ArgumentError do
  Integer("x")
end
  • Assay::AE::Assertor is AE's Assertor. The object's own method decides the result, as in AE; the Assay class registered for that operator, if any, is the class of the failure. AE's own words map too (eq?, case?, equal?, in_delta?, in_epsilon?, raised?, thrown?).
  • If the object lacks the method but Assay has an assertion by that operator or name (x.assert.like?(y), x.assert.kind_of(K)), the Assay class makes the test.
  • assert accepts an Assay matcher: 10.assert EqualAssay[10].
  • Loaded separately: assay/ae/should, assay/ae/must, assay/ae/check.
  • Counts go to $ASSERTION_COUNTS, as with every notation.
  • Left out: ae/legacy (there is assay/testunit), ae/pry, and AE's adapters (Assay has its own).

The AE gem is untouched and stays independent. assay/ae and assay/fluidity both define assert, should and must on Object, so it is one or the other; the README says so.

Testing

AE's own demos, adapted, are demo/ae (plus 09_assay.md for the typed failures): 8 demos, 165 steps. rake on Ruby 3.4.9: all seven demo sets, 138 unit tests and the adapter check pass.

🤖 Generated with Claude Code

trans and others added 2 commits November 23, 2026 01:11
The fluent grammar classes inherited from Object, so kind_of?, nil?,
eql?, respond_to?, != and the like were answered by the grammar object
and asserted nothing. They are built on BasicObject now, as is the
RSpec notation's operator delegate.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
assay/ae is the AE gem's notation (x.assert == y, expect, and optionally
should, must and ok/no) built on Assay's classes. The object's own method
decides the result; where an Assay class covers the method, the failure
is of that class.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@trans
trans merged commit a3dbbcd into master Nov 23, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant