I recently discovered SitePrism via the rubyweekly email. It looks amazing. I can see its going to be the future.
The examples I have seen are mostly for cucumber steps. I am trying to figure out how one would go about using SitePrism with rspec.
Assuming @home_page for the home page, and @login_page for the login_page I can understand that
@home_page.load # => visit @home.expanded_url
however, the part I am not sure about, is if I think click on for example the "login" link, and the browser in Capybara goes to the login page - how I can then access an instance of the login page, without loading it.
@home_page = HomePage.new
@home_page.load
@home.login_link.click
# Here I know the login page should be loaded, so I can perhaps do
@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 like it might work. So, when you know you are supposed to be on a specific page, you create an instance of that page, and somehow the capybara "page" context, as in page.find("a[href='/sessions/new']") is transferred to the last SitePrism object?
I just feel like I am missing something here. I'll play around and see what I can figure out - just figured I might be missing something. I am looking through the source, but if anyone has figured this out... feel free to share :)