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?

    protected
      def is_included?
        @subject.include?(@value)
      end
  end

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?

    protected
      def is_included?
        @subject.include?(@value)
      end
  end

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

Methods

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.

[Source]

     # File lib/remarkable/dsl/assertions.rb, line 281
281:       def matches?(subject)
282:         @subject = subject
283: 
284:         run_before_assert_callbacks
285: 
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
291: 
292:         matches_collection_assertions?
293:       end

Protected Instance methods

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

[Source]

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

[Validate]