Skip to content

Instantly share code, notes, and snippets.

@vfolunin
Created December 18, 2012 20:10
Show Gist options
  • Save vfolunin/4331506 to your computer and use it in GitHub Desktop.
Save vfolunin/4331506 to your computer and use it in GitHub Desktop.
Capybara test for http://acm.khpnets.info
# encoding: utf-8
# capybara test for http://acm.khpnets.info
require 'rubygems'
require 'capybara'
require 'capybara/rspec'
Capybara.configure do |c|
c.default_driver = :selenium
end
feature 'viewing' do
scenario 'view the articles' do
visit('http://acm.khpnets.info')
first(:link, 'Тренировочная олимпиада').click
page.should have_content('Тренировочная олимпиада — это полноценное соревнование по программированию формата ACM ICPC')
click_link 'мануал в картинках'
within first('div[@class="entry"]') do
page.should have_selector('img', :count => 7)
end
end
end
feature 'searching' do
scenario 'successful search' do
visit('http://acm.khpnets.info')
fill_in 'Найти:', :with => 'ACM ICPC'
find_field('s').native.send_key(:enter)
page.should have_content('Тренировочная олимпиада')
end
scenario 'unsuccessful search' do
visit('http://acm.khpnets.info')
fill_in 'Найти:', :with => 'MCA CPCI'
find_field('s').native.send_key(:enter)
page.should have_content('Извините, нет записей, удовлетворяющих вашим условиям')
end
end
feature 'commenting' do
scenario 'try to leave a comment' do
visit('http://acm.khpnets.info/?p=104')
fill_in 'Name', :with => 'Capybara'
fill_in 'Mail', :with => '[email protected]'
fill_in 'Website', :with => 'Capyba.ra'
fill_in 'CAPTCHA', :with => 'CAPTCHA'
find('#comment').set 'New Comment'
click_button 'Submit Comment'
page.should have_content('You entered in the wrong CAPTCHA phrase.')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment