ruby on rails - Best practice for testing capybara visit page -


so wondering best way go testing page visited using capybara

describe "pages"   subject { page }   describe "home page"     "should have title 'my home page'"       visit root_path       expect(page).to have_title('my home page')           end   end end 

now seems standard way test compare title of page (as above). doesn't seem super robust though, if page title changes, break tests reference this.

is standard practice? or there way test it.

thanks, matt

i don't think example gave standard way test page visited. standard way see if page's title match expect =p

if want make assertion path in capybara, more reliable way using current_path. so, can rewrite example follows:

describe "pages"   describe "home page"     "will visit root_path"       visit root_path       expect(current_path).to eql root_path     end   end end 

notice not valuable test though. know capybara tested , visit root_path if tell so. anyways, if want make sanity check or something, right way go.

i hope helps !


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -