ruby - Using SitePrism with Rspec and Capybara feature specs -


i discovered siteprism via rubyweekly email. looks amazing. can see going future.

the examples have seen cucumber steps. trying figure out how 1 go using siteprism rspec.

assuming @home_page home page, , @login_page login_page can understand

@home_page.load # => visit @home.expanded_url 

however, part not sure about, if think click on example "login" link, , browser in capybara goes login page - how can access instance of login page, without loading it.

    @home_page = homepage.new     @home_page.load     @home.login_link.click     # here know login page should loaded, can perhaps       @login_page = loginpage.new     @login_page.should be_displayed     @login_page.email_field.set("some@email.com")     @login_page.password_field.set("password")     @login_page.submit_button.click  etc... 

that seems might work. so, when know supposed on specific page, create instance of page, , somehow capybara "page" context, in page.find("a[href='/sessions/new']") transferred last siteprism object?

i feel missing here. i'll play around , see can figure out - figured might missing something. looking through source, if has figured out... feel free share :)

what you've assumed turns out how siteprism works :) though may want check epilogue of readme explains how save having instantiate page objects on test code. here's example:

# our pages  class home < siteprism::page   #... end  class searchresults < siteprism::page   #... end  # here's app class represents our entire site:  class app   def home     home.new   end    def results_page     searchresults.new   end end  # , here's how use it:  #first line of test... @app = app.new @app.home.load @app.home.search_field.set "sausages" @app.home.search_button.click @app.results_page.should be_displayed 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -