dontfidget/rspec-change_to_now

View on GitHub
lib/rspec/change_to_now/matchers/as_matcher.rb

Summary

Maintainability
A
0 mins
Test Coverage
require 'rspec/core'
require 'rspec/expectations'

module RSpec
  module ChangeToNow::Matchers
    # Decorator that wraps a matcher and raises a syntax error if the matcher is not a matcher.
    #
    # @api private
    class AsMatcher < RSpec::Matchers::MatcherDelegator
      include RSpec::Matchers::Composable

      def initialize(expected)
        expected = RSpec::Matchers::BuiltIn::Match.new(expected) unless RSpec::Matchers.is_a_matcher?(expected)
        super(expected)
      end
    end
  end
end