Permalink
Browse files

Updating

  • Loading branch information...
1 parent 6e8c448 commit 077d44fcfde580c1242930b5ad520a6f8f1eb680 @kevincolyar committed Dec 22, 2009
@@ -3,14 +3,12 @@ def manifest
record do |m|
m.directory 'features'
m.directory 'features/support'
- m.directory 'features/plain'
- m.directory 'features/enhanced'
m.directory 'features/environments'
m.directory 'features/step_definitions'
m.file 'cucumber.yml', 'cucumber.yml'
m.file 'features/support/env.rb', 'features/support/env.rb'
- m.file 'features/environments/plain.rb', 'features/environments/plain.rb'
- m.file 'features/environments/enhanced.rb', 'features/environments/enhanced.rb'
+ m.file 'features/environments/webrat.rb', 'features/environments/webrat.rb'
+ m.file 'features/environments/selenium.rb', 'features/environments/selenium.rb'
m.file 'features/support/paths.rb', 'features/support/paths.rb'
m.file 'features/step_definitions/webrat_steps.rb', 'features/step_definitions/webrat_steps.rb'
end
@@ -1,5 +1,10 @@
-default: -r features/support -r features/environments/plain.rb -r features/step_definitions features/plain
-selenium: -r features/support -r features/environments/enhanced.rb -r features/step_definitions features/enhanced
-autotest: -r features/support -r features/environments/plain.rb -r features/step_definitions --color --format pretty --tags ~@selenium
-autotest-all: -r features/support -r features/environments/plain.rb -r features/step_definitions --color --format progress --tags ~@selenium
+default: -r features/support -r features/environments/webrat.rb -r features/step_definitions features --tags ~@selenium
+selenium: -r features/support -r features/environments/selenium.rb -r features/step_definitions features --tags @selenium
+autotest: -r features/support -r features/environments/webrat.rb -r features/step_definitions --color --format pretty --tags ~@selenium
+autotest-all: -r features/support -r features/environments/webrat.rb -r features/step_definitions --color --format progress --tags ~@selenium
+kmb: -r features/support -r features/environments/webrat.rb -r features/step_definitions features --tags ~@selenium,@kmb
+kmbs: -r features/support -r features/environments/selenium.rb -r features/step_definitions features --tags @selenium,@kmb
+
+ksc: -r features/support -r features/environments/webrat.rb -r features/step_definitions features --tags @ksc
+kscs: -r features/support -r features/environments/selenium.rb -r features/step_definitions features --tags @selenium,@ksc
@@ -0,0 +1,48 @@
+require 'database_cleaner'
+require 'database_cleaner/cucumber'
+
+Webrat.configure do |config|
+ config.mode = :selenium
+ # Selenium defaults to using the selenium environment. Use the following to override this.
+ config.application_environment = :test
+
+ # config.application_address = "localhost"
+ # config.application_port = "3001"
+
+ #config.selenium_server_address = "localhost"
+ #config.selenium_server_port = "4444"
+
+# config.selenium_browser_key = "*firefox"
+end
+
+# this is necessary to have webrat "wait_for" the response body to be available
+# when writing steps that match against the response body returned by selenium
+World(Webrat::Selenium::Matchers)
+
+# This is needed for cucumber/selenium tests
+Cucumber::Rails::World.use_transactional_fixtures = false
+
+DatabaseCleaner.strategy = :truncation
+
+Before do
+ # truncate your tables here, since you can't use transactional fixtures*
+ DatabaseCleaner.clean
+end
+
+# This is helpful when using the same cucumber steps with differing methods for selenium and normal webrat
+def selenium_env?
+ true
+end
+
+class Webrat::SeleniumSession
+
+ # Selenium version of request_path
+ def request_path
+ selenium.get_location.gsub("http://localhost:3001", "")
+ end
+
+end
+
+# Make the request_path method available to the steps
+Webrat::Methods.delegate_to_session :request_path
+
@@ -0,0 +1,20 @@
+#Cucumber::Rails.use_transactional_fixtures
+#Cucumber::Rails.bypass_rescue # Comment out this line if you want Rails own error handling
+
+Webrat.configure do |config|
+ config.mode = :rails
+end
+# (e.g. rescue_action_in_public / rescue_responses / rescue_from)
+
+
+Cucumber::Rails::World.use_transactional_fixtures = false
+require 'database_cleaner'
+After do
+ # Truncate the data from the minerva_test database tables listed below
+ ActiveRecord::Base.establish_connection('minerva_test')
+ DatabaseCleaner.clean_with :truncation, {:only => %w[customer]}
+
+ # Truncate all the data from the test database
+ ActiveRecord::Base.establish_connection(ENV['RAILS_ENV'])
+ DatabaseCleaner.clean_with :truncation
+end
@@ -0,0 +1,7 @@
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
+
+Then /^I should see "([^\"]*)" in "([^\"]*)"$/ do |text, selector|
+ selenium.wait_for_condition('selenium.browserbot.getCurrentWindow().jQuery.active == 0', $max_selenium_timeout)
+ response_body.should have_tag(selector, /#{Regexp.escape(text)}/)
+end
+
@@ -1,3 +1,8 @@
+# IMPORTANT: This file was generated by Cucumber 0.4.3
+# Edit at your own peril - it's recommended to regenerate this file
+# in the future when you upgrade to a newer version of Cucumber.
+# Consider adding your own code to a new file instead of editing this one.
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
# Commonly used webrat steps
@@ -19,37 +24,62 @@
click_link(link)
end
+When /^I follow "([^\"]*)" within "([^\"]*)"$/ do |link, parent|
+ click_link_within(parent, link)
+end
+
When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
- fill_in(field, :with => value)
+ fill_in(field, :with => value)
+end
+
+When /^I fill in "([^\"]*)" for "([^\"]*)"$/ do |value, field|
+ fill_in(field, :with => value)
+end
+
+# Use this to fill in an entire form with data from a table. Example:
+#
+# When I fill in the following:
+# | Account Number | 5002 |
+# | Expiry date | 2009-11-01 |
+# | Note | Nice guy |
+# | Wants Email? | |
+#
+# TODO: Add support for checkbox, select og option
+# based on naming conventions.
+#
+When /^I fill in the following:$/ do |fields|
+ fields.rows_hash.each do |name, value|
+ When %{I fill in "#{name}" with "#{value}"}
+ end
end
When /^I select "([^\"]*)" from "([^\"]*)"$/ do |value, field|
- select(value, :from => field)
+ select(value, :from => field)
end
# Use this step in conjunction with Rail's datetime_select helper. For example:
-# When I select "December 25, 2008 10:00" as the date and time
+# When I select "December 25, 2008 10:00" as the date and time
When /^I select "([^\"]*)" as the date and time$/ do |time|
select_datetime(time)
end
-# Use this step when using multiple datetime_select helpers on a page or
+# Use this step when using multiple datetime_select helpers on a page or
# you want to specify which datetime to select. Given the following view:
# <%= f.label :preferred %><br />
# <%= f.datetime_select :preferred %>
# <%= f.label :alternative %><br />
# <%= f.datetime_select :alternative %>
# The following steps would fill out the form:
-# When I select "November 23, 2004 11:20" as the "Preferred" data and time
-# And I select "November 25, 2004 10:30" as the "Alternative" data and time
+# When I select "November 23, 2004 11:20" as the "Preferred" date and time
+# And I select "November 25, 2004 10:30" as the "Alternative" date and time
When /^I select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label|
select_datetime(datetime, :from => datetime_label)
end
# Use this step in conjunction with Rail's time_select helper. For example:
# When I select "2:20PM" as the time
# Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
-# will convert the 2:20PM to 14:20 and then select it.
+# will convert the 2:20PM to 14:20 and then select it.
When /^I select "([^\"]*)" as the time$/ do |time|
select_time(time)
end
@@ -75,11 +105,11 @@
end
When /^I check "([^\"]*)"$/ do |field|
- check(field)
+ check(field)
end
When /^I uncheck "([^\"]*)"$/ do |field|
- uncheck(field)
+ uncheck(field)
end
When /^I choose "([^\"]*)"$/ do |field|
@@ -94,22 +124,66 @@
response.should contain(text)
end
+Then /^I should see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
+ within(selector) do |content|
+ content.should contain(text)
+ end
+end
+
+Then /^I should see \/([^\/]*)\/$/ do |regexp|
+ regexp = Regexp.new(regexp)
+ response.should contain(regexp)
+end
+
+Then /^I should see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
+ within(selector) do |content|
+ regexp = Regexp.new(regexp)
+ content.should contain(regexp)
+ end
+end
+
Then /^I should not see "([^\"]*)"$/ do |text|
response.should_not contain(text)
end
-Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
- field_labeled(field).value.should =~ /#{value}/
+Then /^I should not see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
+ within(selector) do |content|
+ content.should_not contain(text)
+ end
+end
+
+Then /^I should not see \/([^\/]*)\/$/ do |regexp|
+ regexp = Regexp.new(regexp)
+ response.should_not contain(regexp)
+end
+
+Then /^I should not see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
+ within(selector) do |content|
+ regexp = Regexp.new(regexp)
+ content.should_not contain(regexp)
end
+end
+
+Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
+ field_labeled(field).value.should =~ /#{value}/
+end
Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value|
- field_labeled(field).value.should_not =~ /#{value}/
- end
-
+ field_labeled(field).value.should_not =~ /#{value}/
+end
+
Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
field_labeled(label).should be_checked
end
+Then /^the "([^\"]*)" checkbox should not be checked$/ do |label|
+ field_labeled(label).should_not be_checked
+end
+
Then /^I should be on (.+)$/ do |page_name|
URI.parse(current_url).path.should == path_to(page_name)
end
+
+Then /^show me the page$/ do
+ save_and_open_page
+end

0 comments on commit 077d44f

Please sign in to comment.