Search code examples
site-prism

When using site_prism, how do I properly set_url so that I can use the rspec .to be_displayed matcher?


My page model looks like this:

class ViewPage < SitePrism::Page
  set_url "events{/event_id}/whosecoming"
  element :flash_messages, 'div#flash_messages'
  section :event_info, EventInfoSection, 'div#event'
  iframe :map_iframe, MapIframe, '#map'
  section :hasher_listing, HasherListing, 'div#hashers'
end

When I use

expect(ViewPage.new).to be_displayed

It does not match with an observed url of 'events/1/whosecoming'

Everything on the page loads fine, I believe I just don't understand how set_url should be used with paramerization.


Solution

  • Answer was in a nearby section of the Site Prism documentation.

    The set url was correct, what I needed was to pass the parameter to the expectation.

    expect(ViewPage.new).to be_displayed(event_id: 3)