Class: Expects::Handlers::Regex

Inherits:
Expects::Handler show all
Includes:
Expects
Defined in:
lib/expects/handlers/regex.rb

Constant Summary

Constants included from Expects

VERSION

Instance Attribute Summary

Attributes inherited from Expects::Handler

#objects, #subject

Instance Method Summary collapse

Methods included from Expects

included

Methods inherited from Expects::Handler

#accept!, #reject!

Constructor Details

#initialize(subject, objects) ⇒ Regex

Returns a new instance of Regex.



6
7
8
9
10
# File 'lib/expects/handlers/regex.rb', line 6

def initialize(subject, objects)
  expects subject, String
  expects objects, Regexp
  super
end

Instance Method Details

#build_messageObject



16
17
18
# File 'lib/expects/handlers/regex.rb', line 16

def build_message
  "Expected #{@subject.inspect} match \"#{@objects.inspect}\""
end

#valid?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/expects/handlers/regex.rb', line 12

def valid?
  @subject.match(@objects)
end