Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Functional testing with capybara

Functional testing with capybara

Functional testing with capybara, shown by examples from the metaflop project.

koffeinfrei

August 22, 2012
Tweet

More Decks by koffeinfrei

Other Decks in Programming

Transcript

  1. dsl

  2. interacting with forms fill_in('Username', :with => 'user') choose('A Radio Button')

    check('A Checkbox') attach_file('Image', '/path/to/image.jpg') select('Option', :from => 'Select Box')
  3. querying (rspec matchers) page.should have_selector('table tr') page.should have_selector( :xpath, '//table/tr')

    page.should have_xpath('//table/tr') page.should have_css('table tr.foo') page.should have_content('foo')
  4. Capybara.default_driver = :selenium # sinatra Capybara.app = App # remote

    app Capybara.app_host = 'http://www.google.com'
  5. per spec Capybara.javascript_driver = :selenium # ... describe 'requires js',

    :js => true do it 'will use the default js driver' it 'will switch to one specific driver', :driver => :webkit end
  6. metaflop web based platform for metafonts and related type projects

    modulator experimental font generation export as otf, webfont
  7. spec sample 1 context 'when i change the unit width'

    do it 'should show the loading indicator' do fill_in 'param-unit-width', :with => 2 page.should have_selector( '.preview-loading-text') end end
  8. spec sample 2 context 'when i enable anatomy' do it

    'shows the anatomy image' do within '#menu' do click_link 'on' end page.should have_selector '#info-panel' end end
  9. spec sample 3 context 'when i click the "webfont" link'

    do it 'should call the font generator url' do click_link('webfont') current_url.should include 'modulator/export/font/web' end end
  10. selenium slow, startup slow, random errors no http response no

    .trigger() (e.g. mouse over) installation