Class: RSpec::JsonMatchers::Expectations::Private::MatchingRegexp

Inherits:
Core::SingleValueCallableExpectation show all
Defined in:
lib/rspec/json_matchers/expectations/private.rb

Overview

Takes exactly one object Use stored regexp for checking value

Instance Method Summary collapse

Methods inherited from Core::SingleValueCallableExpectation

[]

Methods inherited from Core::CallableExpectation

[]

Methods inherited from RSpec::JsonMatchers::Expectation

build, build_many

Instance Method Details

#expect?(value) ⇒ Boolean

Returns:

  • (Boolean)


104
105
106
107
108
# File 'lib/rspec/json_matchers/expectations/private.rb', line 104

def expect?(value)
  # regex =~ string seems to be fastest
  # @see https://stackoverflow.com/questions/11887145/fastest-way-to-check-if-a-string-matches-or-not-a-regexp-in-ruby
  value.is_a?(String) && regexp =~ value
end