Module: PatternRuby::TestHelpers
- Defined in:
- lib/pattern_ruby/rails/test_helpers.rb
Instance Method Summary collapse
- #assert_extracts_entity(entity_name, expected_value, input, router:, message: nil) ⇒ Object
- #assert_matches_intent(expected_intent, input, router:, message: nil) ⇒ Object
- #refute_matches(input, router:, message: nil) ⇒ Object
Instance Method Details
#assert_extracts_entity(entity_name, expected_value, input, router:, message: nil) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/pattern_ruby/rails/test_helpers.rb', line 10 def assert_extracts_entity(entity_name, expected_value, input, router:, message: nil) result = router.match(input) msg = || "Expected entity :#{entity_name} to be #{expected_value.inspect}" assert result.matched?, "Input #{input.inspect} did not match any intent" assert_equal expected_value, result.entities[entity_name.to_sym], msg end |
#assert_matches_intent(expected_intent, input, router:, message: nil) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/pattern_ruby/rails/test_helpers.rb', line 3 def assert_matches_intent(expected_intent, input, router:, message: nil) result = router.match(input) msg = || "Expected input #{input.inspect} to match intent :#{expected_intent}, but got :#{result.intent}" assert result.matched?, msg assert_equal expected_intent, result.intent, msg end |
#refute_matches(input, router:, message: nil) ⇒ Object
17 18 19 20 21 |
# File 'lib/pattern_ruby/rails/test_helpers.rb', line 17 def refute_matches(input, router:, message: nil) result = router.match(input) msg = || "Expected input #{input.inspect} not to match, but matched :#{result.intent}" refute result.matched?, msg end |