Class: Phlex::Sorbet::RSpec::Matchers::AcceptProps
- Inherits:
-
Object
- Object
- Phlex::Sorbet::RSpec::Matchers::AcceptProps
- Defined in:
- lib/phlex/sorbet/rspec/matchers.rb
Overview
Matcher for validating that a component accepts specific props
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(props) ⇒ AcceptProps
constructor
A new instance of AcceptProps.
- #matches?(component_class) ⇒ Boolean
Constructor Details
#initialize(props) ⇒ AcceptProps
Returns a new instance of AcceptProps.
170 171 172 |
# File 'lib/phlex/sorbet/rspec/matchers.rb', line 170 def initialize(props) @props = props end |
Instance Method Details
#description ⇒ Object
196 197 198 |
# File 'lib/phlex/sorbet/rspec/matchers.rb', line 196 def description "accept props #{@props.inspect}" end |
#failure_message ⇒ Object
187 188 189 190 |
# File 'lib/phlex/sorbet/rspec/matchers.rb', line 187 def "expected #{@actual} to accept props #{@props.inspect}, " \ "but it raised #{@raised_error.class}: #{@raised_error.}" end |
#failure_message_when_negated ⇒ Object
192 193 194 |
# File 'lib/phlex/sorbet/rspec/matchers.rb', line 192 def "expected #{@actual} not to accept props #{@props.inspect}, but it did" end |
#matches?(component_class) ⇒ Boolean
174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/phlex/sorbet/rspec/matchers.rb', line 174 def matches?(component_class) @actual = component_class component_class.build_props(**@props) true rescue Phlex::Sorbet::InvalidPropsError, Phlex::Sorbet::PropsNotDefinedError, ArgumentError, TypeError => e @raised_error = e false end |