Skip to content

Instantly share code, notes, and snippets.

View jeffersongirao's full-sized avatar
🏠
Working from home

Jefferson Girão jeffersongirao

🏠
Working from home
View GitHub Profile
@jeffersongirao
jeffersongirao / test.rb
Created May 27, 2009 19:42
Dependências para o Cucumber
config.gem "polyglot", :lib => false, :version => ">= 0.2.5" # Necessária para a internacionalização
config.gem "hpricot", :lib => false, :version => ">= 0.8.1" # Ferramenta de parsing necessária
config.gem "treetop", :lib => false, :version => ">= 1.2.5" # Metalinguagem
# É um componente esssencial do cucumber
config.gem "term-ansicolor", :lib => false, :version => ">= 1.0.3" # Utilizada para colorir a saída no terminal
config.gem "webrat", :lib => false, :version => ">= 0.4.4" # Ferramenta para testes funcionais
Funcionalidade: Gerenciar Contatos
Como um usuário
Eu quero gerenciar contatos
Para contatar as pessoas mais facilmente
Contexto:
Dado que existem os seguintes registros de contato:
| nome | email |
| Contato de Teste 1 | contatoteste1@exemplo.com.br |
| Contato de Teste 2 | contatoteste2@exemplo.com.br |
Dado /^que existe\(m\) (\d+) registro\(s\) de (.+)$/ do |n, model_str|
model_str = model_str.gsub(/\s/, '_')
model_sym = model_str.to_sym
classe = eval(model_str.camelize)
classe.transaction do
classe.destroy_all
n.to_i.times do
Factory(model_sym)
end
end
<%
@selenium_opts = '-r features/support/selenium.rb'
@webrat_opts = '-r features/support/webrat.rb'
@rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
def rerun?
!@rerun.to_s.strip.empty?
end
unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
vendored_cucumber_bin = Dir["#{RAILS_ROOT}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
begin
require 'cucumber/rake/task'
namespace :cucumber do
namespace :webrat do
<%
@selenium_opts = '-r features/support/selenium.rb -e features/step_definitions/webrat'
@webrat_opts = '-r features/support/webrat.rb -e features/step_definitions/selenium'
@rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
def rerun?
!@rerun.to_s.strip.empty?
end
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
vendored_cucumber_bin = Dir["#{RAILS_ROOT}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
ENV["RAILS_ENV"] ||= "cucumber"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
Webrat.configure do |config|
config.mode = :selenium
end
Cucumber::Rails::World.use_transactional_fixtures = false
World(Webrat::Selenium::Matchers)
require 'database_cleaner'
DatabaseCleaner.strategy = :truncation
Webrat.configure do |config|
config.mode = :rails
config.open_error_files = false # Set to true if you want error pages to pop up in the browser
end