i've updated page titles static text render dynamic variables apps pages. example:
static:
<% title "job" %> dynamic:
<% title "job in #{@job.address.state}" %> my old rspec test pretty simple:
it 'can see jobs page' expect(page).to have_title('job') end my page title helper looks this:
# page title helper def title(page_title) content_for (:title) { page_title } end def yield_or_default(section, default = "") content_for?(section) ? content_for(section) : default end what best way test dynamic page titles rspec? i've tried use included matcher test page title string includes jobs in couldn't work.
i hard code expectations. way, aren't testing ability write same method chain same way twice, testing printed on page user see.
it 'can see jobs page' expect(page).to have_title('job in alaska') end if reason have not called methods correctly, test break , you'll know fix. if seems hard do, remember can use factory or set address state inside test whatever need be.
Comments
Post a Comment