Module: Katalyst::Kpop::Matchers

Defined in:
lib/katalyst/kpop/matchers.rb,
lib/katalyst/kpop/matchers/base.rb,
lib/katalyst/kpop/matchers/src_matcher.rb,
lib/katalyst/kpop/matchers/title_finder.rb,
lib/katalyst/kpop/matchers/frame_matcher.rb,
lib/katalyst/kpop/matchers/modal_matcher.rb,
lib/katalyst/kpop/matchers/title_matcher.rb,
lib/katalyst/kpop/matchers/stream_matcher.rb,
lib/katalyst/kpop/matchers/capybara_parser.rb,
lib/katalyst/kpop/matchers/chained_matcher.rb,
lib/katalyst/kpop/matchers/capybara_matcher.rb,
lib/katalyst/kpop/matchers/redirect_matcher.rb,
lib/katalyst/kpop/matchers/response_matcher.rb

Defined Under Namespace

Classes: Base, CapybaraMatcher, CapybaraParser, ChainedMatcher, FrameMatcher, ModalMatcher, RedirectMatcher, ResponseMatcher, SrcMatcher, StreamMatcher, TitleFinder, TitleMatcher

Instance Method Summary collapse

Instance Method Details

#have_kpop_src(location, id: "kpop") ⇒ Object

Passes if ‘response` contains a kpop turbo frame src set. Supports matching on:

* id – turbo frame id
* location - modal location (path)

Examples:

Matching a response that will async load ‘/cart` as a modal

expect(response).to have_kpop_src("/cart")


28
29
30
# File 'lib/katalyst/kpop/matchers.rb', line 28

def have_kpop_src(location, id: "kpop") # rubocop:disable Naming/PredicatePrefix
  ChainedMatcher.new(ResponseMatcher, CapybaraParser, FrameMatcher.new(id:), SrcMatcher.new(location))
end

#render_kpop_frame(id: "kpop", title: nil) ⇒ Object

Passes if ‘response` contains a turbo frame with a kpop modal. Supports matching on:

* id – turbo frame id
* title - modal title

Examples:

Matching turbo stream response with a Shopping Cart modal

expect(response).to render_kpop_frame(title: "Shopping Cart")


14
15
16
17
18
# File 'lib/katalyst/kpop/matchers.rb', line 14

def render_kpop_frame(id: "kpop", title: nil)
  matcher = ChainedMatcher.new(ResponseMatcher, CapybaraParser, FrameMatcher.new(id:), ModalMatcher)
  matcher << TitleFinder << TitleMatcher.new(title) if title.present?
  matcher
end