Sha256: e70d60139acdc210d83da2a384076d00d77f671acd5773cfae1c71d0a3b60758
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 KB
Contents
module Remarkable class Base include Remarkable::Messages extend Remarkable::DSL def spec(binding) @spec = binding self end private # Returns the subject class if it's not one. def subject_class nil unless @subject @subject.is_a?(Class) ? @subject : @subject.class end # Returns the subject name based on its class. If the class respond to # human_name (which is usually localized) returns it. def subject_name nil unless @subject subject_class.respond_to?(:human_name) ? subject_class.human_name : subject_class.name end # Iterates over the collection given yielding the block and return false # if any of them also returns false. def assert_matcher_for(collection) collection.each do |item| return false unless yield(item) end true end # Asserts that the given collection contains item x. If x is a regular # expression, ensure that at least one element from the collection matches x. # # assert_contains(['a', '1'], /\d/) => passes # assert_contains(['a', '1'], 'a') => passes # assert_contains(['a', '1'], /not there/) => fails # def assert_contains(collection, x) # :nodoc: collection = [collection] unless collection.is_a?(Array) case x when Regexp collection.detect { |e| e =~ x } else collection.include?(x) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
remarkable-3.0.0 | lib/remarkable/base.rb |