No release in over a year
capybara-restore_state offers the ability to execute a block where the initial capybara state on entering the block is returned after the block is executed. This makes it possible to test things like clicking on the same button twice.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 2.1.0
>= 0.6
 Project Readme

capybara-restore_state¶ ↑

capybara-restore_state offers the ability to execute a block where the initial capybara state on entering the block is returned after the block is executed. This makes it possible to test things like clicking on the same button twice.

This only works for the rack-test driver, other drivers can use the back buttons provided by the browser.

Installation¶ ↑

gem install capybara-restore_state

Source Code¶ ↑

Source code is available on GitHub at github.com/jeremyevans/capybara-restore_state

Examples¶ ↑

require 'capybara'
require 'capybara/restore_state'

describe Capybara::RestoreState do
  include Rack::Test::Methods
  include Capybara::DSL
  include Capybara::RestoreState

  def app
    MyRackApp
  end

  it "should allow restoring of state" do
    # Assume Submit button takes you /a
    visit '/'
    page.current_path # => '/'

    restore_state do
      page.current_path # => '/'
      click_button 'Submit'
      page.current_path # => '/a'
    end

    page.current_path # => '/'
    click_button 'Submit'
    page.current_path # => '/a'
  end
end

License¶ ↑

MIT

Author¶ ↑

Jeremy Evans <code@jeremyevans.net>