Sha256: 04a704b7d5da13ba59de49e8c24a0dcd5c26f87dc3a0e04df2102e984910a01d

Contents?: true

Size: 1.17 KB

Versions: 11

Compression:

Stored size: 1.17 KB

Contents

module Remarkable
  module Specs
    module Matchers
      class SingleContainMatcher < Remarkable::Base
        arguments :value, :block => :iterator

        assertions :is_array?, :included?

        optional :allow_nil
        optional :allow_blank
        optional :values, :splat => true

        after_initialize :set_after_initialize

        before_assert do
          @before_assert = true
          @subject.instance_eval(&@iterator) if @iterator
        end

        protected

          def included?
            return true if @subject.include?(@value)

            @expectation = "#{@value} is not included in #{@subject.inspect}"
            false
          end

          def is_array?
            return true if @subject.is_a?(Array)

            @expectation = "subject is a #{subject_name}"
            false
          end

          def default_options
            { :working => true }
          end

          def set_after_initialize
            @after_initialize = true
          end

      end

      def single_contain(*args, &block)
        SingleContainMatcher.new(*args, &block).spec(self)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
remarkable-3.1.7 spec/matchers/single_contain_matcher.rb
remarkable-3.1.8 spec/matchers/single_contain_matcher.rb
remarkable-3.0.9 spec/matchers/single_contain_matcher.rb
remarkable-3.0.10 spec/matchers/single_contain_matcher.rb
remarkable-3.1.5 spec/matchers/single_contain_matcher.rb
remarkable-3.1.6 spec/matchers/single_contain_matcher.rb
remarkable-3.1.0 spec/matchers/single_contain_matcher.rb
remarkable-3.1.2 spec/matchers/single_contain_matcher.rb
remarkable-3.1.1 spec/matchers/single_contain_matcher.rb
remarkable-3.1.3 spec/matchers/single_contain_matcher.rb
remarkable-3.1.4 spec/matchers/single_contain_matcher.rb