Class: Typ::RSpec::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/typ/rspec/matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(typ_class) ⇒ Matcher

Returns a new instance of Matcher.



7
8
9
# File 'lib/typ/rspec/matcher.rb', line 7

def initialize typ_class
  @typ_class = typ_class
end

Instance Method Details

#descriptionObject



21
22
23
# File 'lib/typ/rspec/matcher.rb', line 21

def description
  "be #{@typ_class}"
end

#failure_messageObject



17
18
19
# File 'lib/typ/rspec/matcher.rb', line 17

def failure_message
  @it.ai + "\n" + Formatter.new(@typ).to_s
end

#matches?(it) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
# File 'lib/typ/rspec/matcher.rb', line 11

def matches? it
  @it = it
  @typ = @typ_class.new it
  @typ.ok?
end