set configurations for using cucumber and selenium

if you want to run it, update your database.yml to include cucumber and selenium environments (like in the .tmpl) and run

RAILS_ENV=selenium cucumber -p selenium
This commit is contained in:
Reinier Balt 2010-02-02 22:52:32 +01:00
parent 502e60c9a1
commit 8f349d3b6b
9 changed files with 60 additions and 20 deletions

View file

@ -16,7 +16,7 @@
:url => note_path(note), :url => note_path(note),
:method => :delete, :method => :delete,
:confirm => "Are you sure that you want to delete the note \'#{note.id.to_s}\'?" }, :confirm => "Are you sure that you want to delete the note \'#{note.id.to_s}\'?" },
{ :class => 'delete_note' }) -%>  { :class => 'delete_note', :title => "delete note" }) -%> 
<%= link_to_function(image_tag( "blank.png", :title => "Edit item", :class=>"edit_item"), <%= link_to_function(image_tag( "blank.png", :title => "Edit item", :class=>"edit_item"),
"$('##{dom_id(note)}').toggle(); $('##{dom_id(note, 'edit')}').show(); $('##{dom_id(note, 'edit_form')} textarea').focus();" ) + " | " %> "$('##{dom_id(note)}').toggle(); $('##{dom_id(note, 'edit')}').show(); $('##{dom_id(note, 'edit_form')} textarea').focus();" ) + " | " %>
<%= link_to("In: " + note.project.name, project_path(note.project), :class=>"footer_link" ) %>&nbsp;|&nbsp; <%= link_to("In: " + note.project.name, project_path(note.project), :class=>"footer_link" ) %>&nbsp;|&nbsp;

View file

@ -1,8 +1,9 @@
<% <%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : "" rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format progress features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}" rerun_opts = rerun.to_s.strip.empty? ? "--format progress features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
std_opts = "#{rerun_opts} --format rerun --out rerun.txt --strict --tags ~@wip" requires = "-r features/support/env.rb -r features/step_definitions"
std_opts = "#{rerun_opts} #{requires} --format rerun --out rerun.txt --strict --tags ~@wip"
%> %>
default: <%= std_opts %> --tags ~@selenium default: <%= std_opts %> --tags ~@selenium
selenium: <%= std_opts %> --tags @selenium selenium: <%= std_opts %> --tags @selenium -r features/support/selenium.rb
wip: --tags @wip:3 --wip features wip: --tags @wip:3 --wip features

View file

@ -15,3 +15,9 @@ production:
host: localhost host: localhost
username: root username: root
password: password:
cucumber:
<<: *TEST
selenium:
<<: *TEST

View file

@ -0,0 +1,29 @@
# Edit at your own peril - it's recommended to regenerate this file
# in the future when you upgrade to a newer version of Cucumber.
# IMPORTANT: Setting config.cache_classes to false is known to
# break Cucumber's use_transactional_fixtures method.
# For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165
config.cache_classes = true
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error reports and disable caching
config.action_controller.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Disable request forgery protection in test environment
config.action_controller.allow_forgery_protection = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
config.gem 'cucumber-rails', :lib => false, :version => '>=0.2.3' unless File.directory?(File.join(Rails.root, 'vendor/plugins/cucumber-rails'))
config.gem 'database_cleaner', :lib => false, :version => '>=0.2.3' unless File.directory?(File.join(Rails.root, 'vendor/plugins/database_cleaner'))
config.gem 'webrat', :lib => false, :version => '>=0.6.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/webrat'))
config.gem 'rspec', :lib => false, :version => '>=1.2.9' unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec'))
config.gem 'rspec-rails', :lib => false, :version => '>=1.2.9' unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec-rails'))

View file

@ -31,7 +31,7 @@ Feature: View, add, remove notes
When I go to the notes page When I go to the notes page
And I delete the first note And I delete the first note
Then the first note should disappear Then the first note should disappear
Then the badge should show 1 And the badge should show 1
@selenium @selenium
Scenario: Link to note Scenario: Link to note

View file

@ -1,9 +1,9 @@
Given /^I have logged in as "(.*)" with password "(.*)"$/ do |username, password| Given /^I have logged in as "(.*)" with password "(.*)"$/ do |username, password|
visit login_path visit login_path
fill_in "login", :with => username fill_in "Login", :with => username
fill_in "password", :with => password fill_in "Password", :with => password
click_button "Sign in" click_button
response.body.should =~ /Login successful/m response.should contain(/Login successful/)
@current_user = User.find_by_login(username) @current_user = User.find_by_login(username)
end end

View file

@ -38,14 +38,18 @@ end
Given /^I have a project "([^\"]*)" with (.*) notes?$/ do |project_name, num| Given /^I have a project "([^\"]*)" with (.*) notes?$/ do |project_name, num|
project = @current_user.projects.create!(:name => project_name) project = @current_user.projects.create!(:name => project_name)
num.to_i.downto 0 do |i| 0.upto num.to_i do |i|
project.notes.create!(:user_id => @current_user.id, :body => "A note #{i}") project.notes.create!(:user_id => @current_user.id, :body => "A note #{i+1}")
end end
end end
When /^I delete the first note$/ do When /^I delete the first note$/ do
# need selenium for this to check on the js click_link "delete note"
pending end
Then /^the first note should disappear$/ do
# the first note contains "A note 1"
Then "I should not see \"A note 1\""
end end
Given /^I have one project "([^\"]*)" with 1 note$/ do |arg1| Given /^I have one project "([^\"]*)" with 1 note$/ do |arg1|
@ -99,12 +103,6 @@ visits '/notes'
should_see "new exam note" should_see "new exam note"
end end
Then "the first note should disappear" do
wait_for_ajax_and_effects
should_not_see 'exam note 1'
end
Then "he should see the note text" do Then "he should see the note text" do
should_see 'exam note 1' should_see 'exam note 1'
end end

View file

@ -0,0 +1,6 @@
Webrat.configure do |config|
config.mode = :selenium
config.application_environment = :selenium
end
Cucumber::Rails::World.use_transactional_fixtures = false

View file

@ -49,7 +49,7 @@ $.fn.clearForm = function() {
* Unobtrusive jQuery written by Eric Allen * Unobtrusive jQuery written by Eric Allen
****************************************/ ****************************************/
/* Set up authenticity token proplery */ /* Set up authenticity token properly */
$(document).ajaxSend(function(event, request, settings) { $(document).ajaxSend(function(event, request, settings) {
if ( settings.type == 'POST' ) { if ( settings.type == 'POST' ) {
if(typeof(AUTH_TOKEN) != 'undefined'){ if(typeof(AUTH_TOKEN) != 'undefined'){