Module: Fix::Its
- Included in:
- Dsl
- Defined in:
- lib/fix/its.rb
Overview
The word its, added to the language of a specification: a method of
the subject and one expectation about what it returns, on one line.
its(:size) { MUST eq 3 } is on(:size) { it MUST eq 3 }, the result
pointing at the line of its.
Instance Method Summary collapse
Instance Method Details
#its(name, &block) ⇒ nil
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fix/its.rb', line 18 def its(name, *, **, &block) raise ::ArgumentError, "a block must be given" unless block location = caller_locations(1, 1).fetch(0) on(name, *, **) do requirement = instance_exec(&block) unless ::Spectus::Requirement === requirement raise ::ArgumentError, "the block of its gives a requirement: its(:size) { MUST eq(3) }" end it(requirement, location:) end end |