Sha256: af461fa796771e7c74c88e882a09cae3180665057f19c7b9adefce966330b11b

Contents?: true

Size: 693 Bytes

Versions: 3

Compression:

Stored size: 693 Bytes

Contents

module Spec
  module Matchers
    class SimpleMatcher
      attr_reader :description

      def initialize(description, &match_block)
        @description = description
        @match_block = match_block
      end

      def matches?(actual)
        @actual = actual
        return @match_block.call(@actual)
      end

      def failure_message()
        return %[expected #{@description.inspect} but got #{@actual.inspect}]
      end

      def negative_failure_message()
        return %[expected not to get #{@description.inspect}, but got #{@actual.inspect}]
      end
    end

    def simple_matcher(message, &match_block)
      SimpleMatcher.new(message, &match_block)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
picolena-0.1.6 rails_plugins/rspec/lib/spec/matchers/simple_matcher.rb
picolena-0.1.7 rails_plugins/rspec/lib/spec/matchers/simple_matcher.rb
picolena-0.1.8 rails_plugins/rspec/lib/spec/matchers/simple_matcher.rb