Module Remarkable::DSL::Assertions
In: lib/remarkable/dsl/assertions.rb

This module is responsable to create a basic matcher structure using a DSL.

A matcher that checks if an element is included in an array can be done just with:

  class IncludedMatcher < Remarkable::Base
    arguments :value
    assertion :is_included?

      def is_included?

As you have noticed, the DSL also allows you to remove the messages from matcher. Since it will look for it on I18n yml file.

If you want to create a matcher that accepts multile values to be tested, you just need to do:

  class IncludedMatcher < Remarkable::Base
    arguments :collection => :values, :as => :value
    collection_assertion :is_included?

      def is_included?

Notice that the :is_included? logic didn‘t have to change, because Remarkable handle this automatically for you.


Classes and Modules

Module Remarkable::DSL::Assertions::ClassMethods

Public Instance methods

This method is responsable for connecting arguments, assertions and collection_assertions.

It‘s the one that executes the assertions once, executes the collection assertions for each element in the collection and also responsable to set the I18n messages.


     # File lib/remarkable/dsl/assertions.rb, line 281
281:       def matches?(subject)
282:         @subject = subject
284:         run_before_assert_callbacks
286:         assertions = self.class.matcher_single_assertions
287:         unless assertions.empty?
288:           value = send_methods_and_generate_message(assertions)
289:           return negative? if positive? == !value
290:         end
292:         matches_collection_assertions?
293:       end

Protected Instance methods

You can overwrite this instance method to provide default options on initialization.


     # File lib/remarkable/dsl/assertions.rb, line 300
300:         def default_options
301:           {}
302:         end